:root {
  --bg: #f1f5f4;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #d6f2ec 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 0%, #e3ecff 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --line: #e4ebe9;
  --ink: #0f2a26;
  --ink-2: #52655f;
  --muted: #86988f;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: #ccfbf1;
  --accent: #6366f1;
  --warn: #d97706;
  --danger: #e11d48;
  --shadow: 0 1px 2px rgba(15,42,38,.05), 0 10px 30px -12px rgba(15,42,38,.18);
  --shadow-sm: 0 1px 2px rgba(15,42,38,.06), 0 4px 12px -8px rgba(15,42,38,.25);
  --radius: 16px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg) var(--bg-grad) no-repeat;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
  min-height: 100vh;
}
h2 { font-size: 19px; margin: 0 0 3px; letter-spacing: -.02em; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.is-hidden { display: none !important; }
.hide-sm { display: inline; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(14px, 4vw, 32px);
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; color: #fff;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  box-shadow: 0 6px 16px -6px rgba(15,118,110,.6);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: -.02em; }
.brand-text span { font-size: 11.5px; color: var(--muted); }
.appbar-actions { display: flex; align-items: center; gap: 10px; }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px;
  color: var(--brand); background: var(--brand-soft);
  padding: 6px 11px; border-radius: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 11px;
  padding: 9px 14px; display: inline-flex; align-items: center; gap: 7px;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 6px 16px -8px rgba(15,118,110,.8); }
.btn-primary:hover { box-shadow: 0 8px 20px -8px rgba(15,118,110,.9); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon { padding: 8px 11px; }

/* ---------- KPI strip ---------- */
.kpi-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  padding: 18px clamp(14px, 4vw, 32px) 4px;
  max-width: 1180px; margin: 0 auto; width: 100%;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 66px; height: 66px;
  border-radius: 50%; background: var(--brand-soft); opacity: .5;
}
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; position: relative; }
.kpi .kpi-val { font-size: 24px; font-weight: 800; letter-spacing: -.03em; margin-top: 4px; position: relative; }
.kpi .kpi-val small { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kpi.k-accent .kpi-val { color: var(--brand); }
.kpi.k-warn::after { background: #fde9c9; }
.kpi.k-warn .kpi-val { color: var(--warn); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 14px clamp(14px, 4vw, 32px) 0;
  max-width: 1180px; margin: 0 auto; width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 9px 15px; border-radius: 999px; white-space: nowrap;
  transition: all .15s ease;
}
.tab:hover { border-color: var(--brand-2); color: var(--brand); }
.tab.is-active { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; border-color: transparent; box-shadow: 0 6px 14px -8px rgba(15,118,110,.8); }

/* ---------- Layout wrap ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px clamp(14px, 4vw, 32px); width: 100%; }
.panel { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* ---------- Week nav ---------- */
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-label { font-weight: 700; font-size: 14px; min-width: 130px; text-align: center; }

/* ---------- Shift form ---------- */
.shift-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.shift-form select, .shift-form input, .emp-form input, .emp-form select {
  font: inherit; font-size: 13.5px; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.shift-form select:focus, .shift-form input:focus, .emp-form input:focus {
  outline: none; border-color: var(--brand-2); background: #fff;
  box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}
.shift-form .tilde { color: var(--muted); font-weight: 700; }

/* ---------- Schedule board ---------- */
.board-scroll { overflow-x: auto; scrollbar-width: thin; padding-bottom: 6px; }
.board {
  display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px;
  min-width: 780px;
}
.day-col {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; overflow: hidden;
}
.day-col.is-today { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(20,184,166,.25), var(--shadow-sm); }
.day-head {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--surface-2);
}
.day-head .dname { font-weight: 700; font-size: 13.5px; }
.day-head .ddate { font-size: 11.5px; color: var(--muted); }
.day-col.is-today .day-head .dname { color: var(--brand); }
.day-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.day-body.drop-hint { background: var(--brand-soft); }

/* ---------- Shift block ---------- */
.shift {
  border-radius: var(--radius-sm); padding: 9px 10px; position: relative;
  border-left: 4px solid var(--sc, var(--brand)); background: var(--sbg, #f0fdfa);
  box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, transform .06s ease;
}
.shift.drag-over { box-shadow: 0 0 0 2px var(--brand-2); transform: scale(1.02); }
.shift-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.shift-emp { font-weight: 700; font-size: 13px; }
.shift-time { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.shift-hours { font-size: 11px; color: var(--muted); margin-top: 1px; }
.shift-del {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 6px;
}
.shift-del:hover { color: var(--danger); background: #ffe4e6; }
.shift-tasks { display: flex; flex-direction: column; gap: 4px; margin-top: 7px; }
.shift-task {
  font-size: 11px; background: rgba(255,255,255,.7); border: 1px solid var(--line);
  border-radius: 7px; padding: 3px 7px; display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.shift-task .st-x { cursor: pointer; color: var(--muted); }
.shift-task .st-x:hover { color: var(--danger); }
.empty-hint { font-size: 11.5px; color: #b7c4bd; text-align: center; padding: 14px 4px; border: 1.5px dashed var(--line); border-radius: 10px; }

/* ---------- Task queue ---------- */
.task-queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.task-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow-sm); cursor: grab; position: relative;
  border-top: 3px solid var(--tc, var(--brand)); transition: transform .1s ease, box-shadow .15s ease;
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: .5; }
.task-emoji { font-size: 22px; }
.task-title { font-weight: 700; font-size: 14px; margin-top: 6px; }
.task-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.task-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; }
.chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.task-assign { font-size: 12px; font-weight: 600; color: var(--brand); background: none; border: 1px solid var(--brand-soft); border-radius: 9px; padding: 6px 10px; cursor: pointer; }
.task-assign:hover { background: var(--brand-soft); }
.legend { margin-top: 16px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-todo { background: var(--brand-2); } .dot-done { background: #cbd5cf; }

/* ---------- Employee form ---------- */
.emp-form { padding: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: end; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.emp-form .btn-primary { grid-column: 1 / -1; justify-content: center; padding: 11px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg-btn { flex: 1; font: inherit; font-size: 12.5px; font-weight: 600; border: none; background: transparent; color: var(--ink-2); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.seg-btn.is-active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.field-color { grid-column: 1 / -1; }
.color-row { display: flex; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.swatch.is-active { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

/* ---------- Employee grid ---------- */
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.emp-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.emp-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--ec, var(--brand)); }
.emp-card-top { display: flex; align-items: center; gap: 11px; }
.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; background: var(--ec, var(--brand)); flex-shrink: 0; }
.emp-name { font-weight: 700; font-size: 15px; }
.emp-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-top: 3px; display: inline-block; }
.emp-badge.part { background: #e0f2fe; color: #0369a1; }
.emp-badge.full { background: #ede9fe; color: #6d28d9; }
.emp-meta { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.emp-meta .row { display: flex; justify-content: space-between; }
.emp-meta .row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.emp-del { position: absolute; top: 12px; right: 12px; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 5px; border-radius: 7px; }
.emp-del:hover { color: var(--danger); background: #ffe4e6; }

/* ---------- Tables ---------- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 13px 16px; text-align: left; }
.data-table thead th { background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
.data-table td { border-bottom: 1px solid var(--line); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tfoot td { background: var(--surface-2); font-weight: 800; border-top: 2px solid var(--line); }
.data-table .name-cell { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.mini-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.pill-ot { background: #fde9c9; color: var(--warn); font-weight: 700; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.pill-ok { background: #dcfce7; color: #15803d; font-weight: 700; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.empty-row td { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- Assign sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(15,42,38,.4); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet { background: var(--surface); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 18px 18px 26px; box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: slideUp .28s cubic-bezier(.2,.8,.2,1); }
@keyframes slideUp { from { transform: translateY(100%);} to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head strong { font-size: 16px; }
.sheet-sub { margin: 4px 0 12px; }
.sheet-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.sheet-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); }
.sheet-item:hover { border-color: var(--brand-2); background: #fff; }
.sheet-item .si-emp { font-weight: 700; font-size: 14px; }
.sheet-item .si-time { font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(calc(100% + 36px));
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  z-index: 80; transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .2s ease; max-width: 90vw;
  opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (min-width: 981px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; max-width: 420px; }
}
@media (max-width: 640px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .emp-form { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  h2 { font-size: 17px; }
  .shift-form { gap: 6px; }
  .shift-form select, .shift-form input { flex: 1; min-width: 0; }
}
