:root{--bg:#f7f8fb;--line:#e7e9ef;--text:#171923;--muted:#727887;--shadow:0 10px 30px rgba(31,38,55,.07);--hour-height:30px}
*{box-sizing:border-box}
body{margin:0;font-family:Arial,"Noto Sans KR",sans-serif;background:var(--bg);color:var(--text);user-select:none}
button,select,input{font:inherit}
.app{display:grid;grid-template-columns:190px minmax(850px,1fr) 320px;grid-template-rows:70px 1fr;min-height:100vh}
.topbar{grid-column:1/-1;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;background:#fff;border-bottom:1px solid var(--line);padding:0 18px;position:sticky;top:0;z-index:20}
.brand{display:flex;align-items:center;gap:18px;font-weight:900}
.logo{font-size:30px;color:#7b3fe4;letter-spacing:-3px}
.logo span{color:#7ac943}
.week-pill{position:relative;padding:10px 18px;border:1px solid var(--line);border-radius:10px;font-weight:800;cursor:pointer;background:#fff}
#weekDateInput{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.top-actions{display:flex;gap:9px;justify-content:flex-end}
.btn{border:1px solid var(--line);background:#fff;border-radius:9px;padding:10px 14px;font-weight:800;cursor:pointer}
.btn.primary{background:linear-gradient(135deg,#8b59e8,#6f42cc);color:#fff;border:0}
.sidebar{background:#fff;border-right:1px solid var(--line);padding:16px 12px;display:flex;flex-direction:column}
.nav-item{width:100%;padding:13px 14px;border:0;background:transparent;border-radius:10px;font-weight:800;color:#4d5361;margin-bottom:6px;text-align:left;cursor:pointer}
.nav-item.active{background:#f0eaff;color:#7d4ce0}
.store-card{margin-top:auto;border:1px solid var(--line);border-radius:14px;padding:15px}
.store-card p{font-size:13px;color:var(--muted);line-height:1.7}
.main{padding:12px;overflow:auto}
.schedule-card,.side-card,.summary-card{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow)}
.schedule-wrap{display:grid;grid-template-columns:68px repeat(7,minmax(108px,1fr));min-width:950px;overflow:hidden}
.time-header,.day-header{height:46px;display:flex;align-items:center;justify-content:center;border-right:1px solid var(--line);border-bottom:1px solid var(--line);font-weight:900}
.day-header.sat{color:#2c74e8}
.day-header.sun{color:#e34b50}
.time-label{height:var(--hour-height);border-right:1px solid var(--line);border-bottom:1px solid #f0f1f5;font-size:12px;text-align:center;padding-top:3px}
.day-column{position:relative;height:calc(var(--hour-height)*24);border-right:1px solid var(--line);background:repeating-linear-gradient(to bottom,#fff 0,#fff calc(var(--hour-height) - 1px),#f0f1f5 var(--hour-height));cursor:crosshair}
.selection-box{position:absolute;left:3px;right:3px;border:2px dashed #7d4ce0;background:rgba(125,76,224,.12);border-radius:8px;pointer-events:none;z-index:4}
.shift{position:absolute;left:4px;right:4px;border-radius:9px;border:1px solid;display:flex;flex-direction:column;align-items:center;justify-content:center;font-weight:800;text-align:center;line-height:1.45;cursor:grab;z-index:5;transition:box-shadow .12s,transform .12s,outline .12s}
.shift small{font-weight:700}
.shift:hover{box-shadow:0 8px 18px rgba(40,50,75,.13)}
.shift.selected{outline:3px solid #5d37c7;outline-offset:2px;box-shadow:0 0 0 5px rgba(125,76,224,.15),0 12px 26px rgba(46,35,88,.18);z-index:8}
.shift.dragging{opacity:.86;cursor:grabbing;transform:scale(.99)}
.shift.invalid{outline:3px solid #e34b50;box-shadow:0 0 0 5px rgba(227,75,80,.15)}
.resize-handle{position:absolute;left:18%;right:18%;bottom:-3px;height:8px;border-radius:99px;background:rgba(39,28,70,.55);cursor:ns-resize;opacity:0;transition:opacity .12s}
.shift.selected .resize-handle,.shift:hover .resize-handle{opacity:1}
.right-panel{padding:12px 14px 12px 0;display:flex;flex-direction:column;gap:14px}
.side-card{padding:14px}
.side-title{display:flex;justify-content:space-between;align-items:center}
.staff-row{display:grid;grid-template-columns:12px minmax(52px,1fr) 64px 44px 24px 24px;align-items:center;gap:5px;width:100%;min-width:0;min-height:54px;padding:8px 0;border-top:1px solid var(--line);font-size:13px}
.staff-row .dot{width:11px;height:11px;border-radius:50%}
.staff-row b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
.staff-row span{white-space:nowrap;font-size:13px}
.staff-row .muted{color:#8b8b9c}
.icon-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;min-width:24px;padding:0;border:0;background:transparent;cursor:pointer;font-size:15px;line-height:1;border-radius:6px}
.icon-btn:hover{background:#f1f1f5}
.quick-card{margin-top:auto}
.quick-btn{width:100%;margin-top:9px;padding:11px;border:1px solid var(--line);background:#fff;border-radius:9px;text-align:left;font-weight:800}
.bottom-area{grid-column:2/-1;padding:0 14px 16px;display:grid;grid-template-columns:1.1fr 1.3fr .8fr;gap:14px}
.summary-card{padding:14px}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:9px}
.kpi{border:1px solid var(--line);border-radius:11px;padding:11px}
.kpi b{display:block;font-size:21px;margin-top:10px}
table{width:100%;border-collapse:collapse;font-size:12px}
th,td{padding:8px;border-bottom:1px solid var(--line);text-align:center}
.donut-wrap{position:relative;width:170px;margin:8px auto}
.donut{width:150px;height:150px;border-radius:50%;margin:0 auto;position:relative;background:#ddd;cursor:default}
.donut-center{position:absolute;inset:30px;background:#fff;border-radius:50%;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:4px;font-size:12px;pointer-events:none}
.donut-tooltip{position:absolute;display:none;z-index:15;min-width:145px;padding:9px 11px;border-radius:9px;background:#202532;color:#fff;font-size:12px;line-height:1.5;box-shadow:0 8px 22px rgba(0,0,0,.2);pointer-events:none}
.donut-tooltip.show{display:block}
.modal-backdrop{position:fixed;inset:0;background:rgba(20,24,35,.35);display:none;align-items:center;justify-content:center;z-index:50}
.modal-backdrop.show{display:flex}
.modal{width:min(420px,92vw);background:#fff;border-radius:16px;padding:20px}
.selection-info{color:var(--muted);background:#f7f5ff;border-radius:10px;padding:12px;font-weight:800}
.field{margin-top:14px}
.field label{display:block;font-size:13px;font-weight:800;margin-bottom:6px}
.field select,.field input[type="text"],.field input[type="number"]{width:100%;padding:11px;border:1px solid var(--line);border-radius:9px}
.field input[type="color"]{width:100%;height:44px;padding:4px;border:1px solid var(--line);border-radius:9px;background:#fff;cursor:pointer}
.modal-actions{display:flex;justify-content:flex-end;gap:9px;margin-top:18px}
.context-menu{position:fixed;min-width:150px;padding:6px;background:#fff;border:1px solid var(--line);border-radius:11px;box-shadow:0 18px 45px rgba(30,35,50,.2);display:none;z-index:100}
.context-menu.show{display:block}
.context-menu button{width:100%;border:0;background:#fff;text-align:left;padding:10px 12px;border-radius:8px;font-weight:800;cursor:pointer}
.context-menu button:hover{background:#f3f0ff}
.context-menu button.danger{color:#e34b50}
.toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%) translateY(20px);background:#202532;color:#fff;padding:11px 16px;border-radius:10px;font-weight:800;opacity:0;pointer-events:none;transition:.2s;z-index:120}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
@media(max-width:1100px){.app{grid-template-columns:160px minmax(760px,1fr)}.right-panel{display:none}.bottom-area{grid-column:2;grid-template-columns:1fr}.topbar{grid-template-columns:1fr auto}.top-actions{display:none}}


/* ===== 급여 산정 기간 ===== */
.salary-card{
  min-width:0;
}

.salary-card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:12px;
}

.salary-card-head h3{
  margin:0 0 5px;
}

.salary-note{
  margin:0;
  color:var(--muted);
  font-size:11px;
  line-height:1.45;
}

.salary-period{
  display:flex;
  align-items:flex-end;
  gap:7px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.salary-period label{
  display:grid;
  gap:4px;
  color:var(--muted);
  font-size:11px;
  font-weight:800;
}

.salary-period input{
  height:34px;
  padding:0 8px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--text);
  font-size:12px;
}

.salary-period .btn{
  height:34px;
  padding:0 12px;
  font-size:12px;
}

@media(max-width:1450px){
  .salary-card-head{
    display:block;
  }

  .salary-period{
    justify-content:flex-start;
    margin-top:10px;
  }
}


/* ===== 통계 / 설정 / 파일 저장 ===== */
.large-modal{
  width:min(760px,94vw);
  max-height:88vh;
  overflow:auto;
}

.modal-title-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}

.modal-title-row h2{
  margin:0;
}

.modal-subtitle{
  margin:6px 0 0;
  color:var(--muted);
  font-size:13px;
}

.modal-close-btn{
  width:34px;
  height:34px;
  border:0;
  border-radius:9px;
  background:#f3f4f7;
  font-size:24px;
  line-height:1;
  cursor:pointer;
}

.modal-close-btn:hover{
  background:#e9eaf0;
}

.stats-kpis{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  margin-top:20px;
}

.stats-kpi{
  border:1px solid var(--line);
  border-radius:12px;
  padding:13px;
}

.stats-kpi span{
  display:block;
  color:var(--muted);
  font-size:12px;
}

.stats-kpi b{
  display:block;
  margin-top:9px;
  font-size:20px;
}

.stats-section-title{
  margin:22px 0 10px;
  font-size:15px;
}

.stats-bars{
  display:grid;
  gap:11px;
}

.stats-bar-row{
  display:grid;
  grid-template-columns:80px 1fr 62px;
  align-items:center;
  gap:10px;
  font-size:13px;
}

.stats-bar-name{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-weight:800;
}

.stats-bar-track{
  height:12px;
  overflow:hidden;
  border-radius:99px;
  background:#eef0f4;
}

.stats-bar-fill{
  height:100%;
  min-width:2px;
  border-radius:99px;
}

.stats-bar-value{
  text-align:right;
  font-weight:800;
}

.stats-day-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:8px;
}

.stats-day-item{
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px 6px;
  text-align:center;
  font-size:12px;
}

.stats-day-item b{
  display:block;
  margin-top:7px;
  font-size:16px;
}

.field-help{
  display:block;
  margin-top:6px;
  color:var(--muted);
  font-size:11px;
}

@media(max-width:720px){
  .stats-kpis{grid-template-columns:repeat(2,1fr)}
  .stats-day-grid{grid-template-columns:repeat(4,1fr)}
}


@media print{
  .sidebar,.right-panel,.top-actions,.week-pill input,.modal-backdrop{
    display:none!important;
  }

  .app{
    display:block;
  }

  .topbar{
    position:static;
    display:flex;
    justify-content:space-between;
    padding:10px 0;
    border:0;
  }

  .main,.bottom-area{
    padding:0;
  }

  .bottom-area{
    display:grid;
    grid-template-columns:1fr;
  }

  .schedule-card,.summary-card{
    box-shadow:none;
    break-inside:avoid;
  }

  body{
    background:#fff;
  }
}


/* 급여표는 마우스로 드래그하여 엑셀에 복사할 수 있음 */
.salary-card table,
.salary-card th,
.salary-card td,
.salary-card table *{
  user-select:text;
  -webkit-user-select:text;
}
.salary-card tbody tr:hover{
  background:#faf9ff;
}


/* ===== 상단 매장명 ===== */
.brand-store-name{
  font-size:20px;
  font-weight:900;
  letter-spacing:-.5px;
  white-space:nowrap;
}



/* ===== 근무표 범위 선택 ===== */
.schedule-wrap{
  user-select:none;
}
.schedule-wrap.grid-copy-mode{
  cursor:crosshair;
}
.grid-selection-cell{
  position:absolute;
  pointer-events:none;
  z-index:8;
  background:rgba(62,126,255,.16);
  border:2px solid rgba(62,126,255,.7);
  box-sizing:border-box;
}
.day-column.copy-selected{
  outline:2px solid rgba(62,126,255,.65);
  outline-offset:-2px;
}
@media print{
  .grid-selection-cell{display:none!important;}
}


/* 빠른 작업 버튼은 실제 버튼처럼 포인터 표시 */
.quick-btn{cursor:pointer;}
.quick-btn:hover{background:#f7f5ff;border-color:#7d4ce0;}


/* ===== 엑셀식 근무 블록 다중 선택 ===== */
.drag-marquee{
  position:fixed;
  z-index:9998;
  pointer-events:none;
  box-sizing:border-box;
  border:2px solid #4f7cff;
  background:rgba(79,124,255,.12);
  border-radius:4px;
}
.shift.multi-selected{
  outline:3px solid #4f7cff !important;
  outline-offset:-3px;
  box-shadow:0 0 0 1px rgba(255,255,255,.85) inset,0 0 0 2px rgba(79,124,255,.25) !important;
  z-index:7;
}
/* 이전 시간칸 단위 선택 표시는 사용하지 않음 */
.grid-selection-cell{display:none!important;}
.day-column.copy-selected{outline:none!important;}


/* ===== 요청 보완 ===== */
.brand-store-name .cu-word{color:#7b3fe4;}
.brand-store-name .store-name-rest{color:#58b947;margin-left:1px;}
.store-card p{line-height:1.7;}
#businessNumberText{display:inline-block;white-space:nowrap;color:#5f6b7a;}


/* ===== 직원 목록 → 근무표 드래그 추가 ===== */
.staff-row{
  cursor:grab;
  user-select:none;
}
.staff-row:active{
  cursor:grabbing;
}
.staff-row.staff-dragging{
  opacity:.48;
}
.staff-row .icon-btn{
  cursor:pointer;
}
.day-column.drag-target{
  background:
    linear-gradient(rgba(126,76,217,.09),rgba(126,76,217,.09)),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 29px,
      rgba(126,76,217,.18) 29px,
      rgba(126,76,217,.18) 30px
    );
  outline:2px dashed #7e4cd9;
  outline-offset:-3px;
}


/* ===== 엑셀식 전체 영역 선택 보완 ===== */
.schedule-wrap,
.day-column,
.shift{
  cursor:crosshair;
}
.shift .resize-handle{
  cursor:ns-resize;
}
.drag-marquee{
  border:2px solid #2f6df6 !important;
  background:rgba(47,109,246,.18) !important;
  box-shadow:0 0 0 1px rgba(255,255,255,.55) inset;
  border-radius:2px !important;
}
.shift.multi-selected{
  outline:3px solid #2f6df6 !important;
  outline-offset:-3px;
}


/* ===== 드래그 선택 확실한 표시 ===== */
.shift.multi-selected{
  outline:4px solid #2368ff !important;
  outline-offset:-4px !important;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.95) inset,
    0 0 0 2px rgba(35,104,255,.28) !important;
  filter:saturate(1.05) brightness(.98);
}


/* ===== 선택 후 테두리 유지 확정 ===== */
.shift.multi-selected{
  position:absolute;
  outline:4px solid #2563ff !important;
  outline-offset:-4px !important;
  box-shadow:inset 0 0 0 2px #ffffff, 0 0 0 1px #2563ff !important;
  z-index:20 !important;
}
.shift.multi-selected::after{
  content:"";
  position:absolute;
  inset:0;
  border:3px solid #2563ff;
  border-radius:inherit;
  pointer-events:none;
  box-sizing:border-box;
}


/* ===== 클릭 선택 + 드래그 이동 최종 UX ===== */
.shift.selected,
.shift.multi-selected{
  outline:4px solid #2368ff !important;
  outline-offset:-4px !important;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.95) inset,
    0 0 0 2px rgba(35,104,255,.30) !important;
}
.shift.selected{
  cursor:grab !important;
}
.shift.selected:active{
  cursor:grabbing !important;
}
.day-column{
  cursor:crosshair;
}


/* ===== 다중 선택 그룹 이동 ===== */
.shift.multi-selected{
  cursor:grab !important;
}
body.dragging-group,
body.dragging-group *{
  cursor:grabbing !important;
  user-select:none !important;
}


/* ===== 1시간 단위 빈 근무시간 선택 ===== */
.empty-cell-selection{
  position:absolute;
  left:2px;
  right:2px;
  z-index:3;
  pointer-events:none;
  box-sizing:border-box;
  border:3px solid #2368ff;
  background:rgba(35,104,255,.13);
  box-shadow:0 0 0 1px rgba(255,255,255,.9) inset;
}

.shift{
  z-index:5;
}


/* ===== 다중 이동 겹침 경고 ===== */
.shift.multi-selected.invalid{
  outline:4px solid #e53935 !important;
  outline-offset:-4px !important;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.95) inset,
    0 0 0 4px rgba(229,57,53,.25) !important;
}


/* ===== 위·아래 양방향 시간 조절 손잡이 ===== */
.shift .resize-handle{
  position:absolute;
  left:18%;
  width:64%;
  height:8px;
  z-index:8;
  border-radius:999px;
  background:rgba(35,64,150,.58);
  opacity:.72;
  transition:opacity .12s, transform .12s;
}

.shift .resize-handle:hover{
  opacity:1;
  transform:scaleX(1.08);
}

.shift .resize-handle-top{
  top:2px;
  bottom:auto;
  cursor:ns-resize;
}

.shift .resize-handle-bottom{
  bottom:2px;
  top:auto;
  cursor:ns-resize;
}


/* ===== 리사이즈 손잡이 표시 방식 개선 ===== */

/* 기본 상태에서는 숨김 */
.shift .resize-handle{
  width:40%;
  left:30%;
  height:6px;
  opacity:0 !important;
  pointer-events:none;
  transform:scaleX(.85);
  transition:
    opacity .14s ease,
    transform .14s ease,
    background .14s ease,
    height .14s ease;
  background:rgba(60,70,90,.58);
}

/* 마우스를 블록 위에 올렸을 때만 회색 손잡이 표시 */
.shift:hover .resize-handle{
  opacity:.72 !important;
  pointer-events:auto;
  transform:scaleX(1);
}

/* 선택된 블록은 파란 손잡이 유지 */
.shift.selected .resize-handle,
.shift.multi-selected .resize-handle{
  opacity:1 !important;
  pointer-events:auto;
  transform:scaleX(1);
  background:#2368ff;
}

/* 실제로 손잡이를 잡고 있는 동안 더 강조 */
.shift:has(.resize-handle:active) .resize-handle{
  opacity:1 !important;
  height:8px;
  background:#1254e8;
  transform:scaleX(1.08);
}

/* hover만으로는 블록 전체가 지저분해지지 않도록 */
.shift:not(:hover):not(.selected):not(.multi-selected) .resize-handle{
  opacity:0 !important;
  pointer-events:none;
}
