/* ============================================================
   공용 디자인 시스템 — 6개 대시보드가 함께 씁니다.
   색/여백을 바꾸고 싶으면 아래 :root 변수만 고치세요.
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #fafbfe;
  --border: #e6e9f2;
  --text: #1a2233;
  --muted: #6b7690;
  --brand: #4f6cf7;
  --brand-soft: #eaefff;
  --green: #16b364;
  --red: #f04438;
  --amber: #f5a524;
  --grid: #eef1f8;
  --shadow: 0 1px 2px rgba(20,30,60,.04), 0 8px 24px rgba(20,30,60,.06);
  --radius: 16px;
  --c1: #4f6cf7; --c2: #16b364; --c3: #f5a524; --c4: #9b5de5;
  --c5: #f04438; --c6: #06b6d4; --c7: #ec4899; --c8: #64748b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --panel: #161b26;
    --panel-2: #1b2130;
    --border: #262d3d;
    --text: #e8ecf4;
    --muted: #93a0ba;
    --brand: #6d86ff;
    --brand-soft: #1c2540;
    --grid: #222a3a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", "Noto Sans KR", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ---- 전체 레이아웃 (사이드바 + 본문) ---- */
.app { display: flex; min-height: 100vh; align-items: stretch; }
.main { flex: 1; min-width: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 28px 64px; }

/* ---- 왼쪽 사이드바 (짙은 남색, 테마와 무관하게 항상 다크) ---- */
.sidebar {
  --s-text: #aab3dc; --s-active: #4a58d6; --s-line: rgba(255,255,255,.09);
  width: 248px; flex-shrink: 0;
  background: linear-gradient(185deg, #1d2340 0%, #241f4f 100%);
  color: var(--s-text);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; margin-bottom: 8px;
  border-bottom: 1px solid var(--s-line); text-decoration: none;
}
.sidebar .brand .logo {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: 18px; flex-shrink: 0;
}
.sidebar .brand-txt b {
  font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.2px;
  display: flex; align-items: center; gap: 6px;
}
.sidebar .brand-txt em {
  font-style: normal; font-size: 10px; font-weight: 600; color: #c3c9f0;
  background: rgba(255,255,255,.1); padding: 2px 6px; border-radius: 6px;
}
.sidebar .brand-txt .sub { font-size: 11.5px; color: #8b93c4; }
.sidebar .navlabel {
  font-size: 10.5px; color: #7e86b8; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; padding: 12px 12px 6px;
}
.sidebar a.a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--s-text); text-decoration: none; font-size: 14px; font-weight: 550; transition: .13s;
}
.sidebar a.a .ic { font-size: 16px; width: 20px; text-align: center; }
.sidebar a.a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.a.active { background: var(--s-active); color: #fff; font-weight: 700;
  box-shadow: 0 4px 12px rgba(74,88,214,.4); }
.sidebar .spacer { flex: 1; min-height: 12px; }

/* 하단 버튼 + 정보 블록 */
.sidebar .side-actions { display: flex; gap: 8px; padding: 6px 4px; }
.sidebar .side-actions button {
  flex: 1; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: #cdd3ec; background: rgba(255,255,255,.05); border: 1px solid var(--s-line);
  border-radius: 10px; padding: 9px 6px; transition: .13s;
}
.sidebar .side-actions button:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar .side-user {
  margin-top: 8px; padding: 11px 12px; border-radius: 12px; background: rgba(255,255,255,.04);
  border: 1px solid var(--s-line); display: flex; align-items: center; gap: 8px;
}
.sidebar .side-user .su-info { min-width: 0; flex: 1; }
.sidebar .side-user b {
  display: block; font-size: 12.5px; color: #fff; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .side-user span { font-size: 11px; color: #8b93c4; }
.sidebar .su-logout {
  flex-shrink: 0; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  color: #cdd3ec; background: rgba(255,255,255,.06); border: 1px solid var(--s-line);
  border-radius: 8px; padding: 6px 10px; transition: .13s;
}
.sidebar .su-logout:hover { background: rgba(255,255,255,.14); color: #fff; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center; gap: 4px; overflow-x: auto; overflow-y: hidden;
    padding: 10px 12px;
  }
  .sidebar .brand { display: none; }
  .sidebar .navlabel { display: none; }
  .sidebar .spacer, .sidebar .side-actions, .sidebar .side-user { display: none; }
  .sidebar a.a { white-space: nowrap; padding: 8px 12px; }
  .wrap { padding: 20px 18px 48px; }
}

/* ---- 상단 헤더 ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.topbar .title { display: flex; align-items: center; gap: 12px; }
.topbar .emoji {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-soft); font-size: 22px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
/* 사이드바가 내비게이션을 담당하므로 상단 '전체 메뉴' 버튼은 숨김 */
.topbar a.back { display: none; }

/* ---- 데이터 상태 배너 ---- */
.status {
  font-size: 12.5px; padding: 9px 14px; border-radius: 10px; margin-bottom: 18px;
  display: inline-flex; align-items: center; gap: 8px;
}
.status.sample { background: #fff7e6; color: #8a5a00; border: 1px solid #ffe6ad; }
.status.live { background: #e9f9f0; color: #0a7a44; border: 1px solid #b8ecce; }
.status.err  { background: #fdecec; color: #b42318; border: 1px solid #f7c9c5; }
@media (prefers-color-scheme: dark) {
  .status.sample { background: #2a2411; color: #f5c563; border-color: #4a3c15; }
  .status.live { background: #0f2a1c; color: #4ade80; border-color: #1c4a30; }
  .status.err { background: #2c1414; color: #f79f97; border-color: #4a1f1c; }
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---- KPI 카드 줄 ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .kpis { grid-template-columns: 1fr; } }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
}
.kpi.warn { border-left: 3px solid var(--red); }
.kpi-ic {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px;
  background: var(--panel-2);
  background: color-mix(in srgb, var(--accent, var(--brand)) 15%, var(--panel));
}
.kpi-body { min-width: 0; }
.kpi .label { font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 750; letter-spacing: -.5px; }
.kpi .value .unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .trend { font-size: 12px; margin-top: 5px; font-weight: 600; display: inline-flex; gap: 4px; }
.kpi .trend.up { color: var(--green); }
.kpi .trend.down { color: var(--red); }
.kpi .trend.flat { color: var(--muted); }

/* ---- 차트 그리드 ---- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid .span2 { grid-column: span 2; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } .grid .span2 { grid-column: span 1; } }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 8px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 650; }
.card .hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.card svg { width: 100%; height: auto; display: block; overflow: visible; }

/* ---- 범례 ---- */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 2px 8px; }
.legend span { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---- 간단 표 ---- */
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 10px; }
table.mini th, table.mini td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--grid); }
table.mini th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.mini tr:last-child td { border-bottom: none; }
.bar-cell { position: relative; }
.bar-cell .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; opacity: .16; }

/* ---- SVG 요소 ---- */
.axis-label { fill: var(--muted); font-size: 11px; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.val-label { fill: var(--text); font-size: 11px; font-weight: 600; }

/* ---- 랜딩 페이지 ---- */
.hero { text-align: center; padding: 30px 0 24px; }
.hero h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.6px; }
.hero p { color: var(--muted); margin: 0; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .cards { grid-template-columns: 1fr; } }
a.nav {
  text-decoration: none; color: inherit; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); transition: .18s; display: block;
}
a.nav:hover { transform: translateY(-3px); border-color: var(--brand); }
a.nav .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; background: var(--brand-soft); margin-bottom: 14px; }
a.nav h2 { font-size: 17px; margin: 0 0 4px; }
a.nav p { font-size: 13px; color: var(--muted); margin: 0; }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 36px; }

/* ---- 버튼 ---- */
.btn {
  font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 9px 16px; border-radius: 10px; transition: .13s; display: inline-flex;
  align-items: center; gap: 6px; text-decoration: none;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); border: none; background: transparent; padding: 4px 8px; font-size: 12px; }
.btn.danger:hover { background: rgba(240,68,56,.1); }

/* ---- 상태 뱃지 ---- */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: #e9f9f0; color: #0a7a44; }
.badge.warn { background: #fff2e6; color: #b45309; }
.badge.pend { background: #fdecec; color: #b42318; }
.badge.cash { background: #eef6ff; color: #1d6fd8; }
@media (prefers-color-scheme: dark) {
  .badge.ok { background: #0f2a1c; color: #4ade80; }
  .badge.warn { background: #2a1f10; color: #f5a524; }
  .badge.pend { background: #2c1414; color: #f79f97; }
  .badge.cash { background: #10233d; color: #6db2ff; }
}

/* ---- 작업 내역 표 ---- */
table.jobs { width: 100%; border-collapse: collapse; font-size: 13px; }
table.jobs th, table.jobs td { padding: 10px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: middle; }
table.jobs th { color: var(--muted); font-weight: 600; font-size: 11.5px; white-space: nowrap; }
table.jobs td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.jobs td.title { min-width: 220px; }
table.jobs tr:last-child td { border-bottom: none; }
table.jobs tr:hover td { background: var(--panel-2); }
.table-scroll { overflow-x: auto; }

/* ---- 모달 (작업 추가) ---- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,20,40,.5); display: none;
  align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--panel); border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.4); padding: 24px 24px 20px;
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .msub { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel-2); color: var(--text); font-size: 13.5px; font-family: inherit; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }
.modal-foot .right { display: flex; gap: 10px; }
.calc-hint { font-size: 12px; color: var(--muted); }

/* ---- 급여명세서 ---- */
.slip-title { font-size: 20px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.slip-meta { font-size: 12.5px; color: var(--muted); text-align: center; }
.slip-net {
  display: flex; align-items: center; justify-content: space-between; margin-top: 14px;
  padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--brand);
  font-size: 14px; font-weight: 700;
}
.slip-net b { font-size: 20px; }

@media print {
  .sidebar, .no-print { display: none !important; }
  body.slip .wrap { display: none !important; }
  body.slip .modal-back:not(#slipModal) { display: none !important; }
  body.slip #slipModal {
    position: static !important; display: block !important; background: none !important; padding: 0 !important;
  }
  body.slip #slipModal .modal { box-shadow: none !important; max-width: 100% !important; max-height: none !important; }
  body.slip .app, body.slip .main { display: block !important; }
}

/* ---- 인사 달력 ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.cal-title { font-size: 15px; font-weight: 700; }
.cal-nav { display: flex; gap: 6px; }
.cal-legend { display: flex; gap: 10px; flex-wrap: wrap; }
.cal-legend span { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 9px; height: 9px; border-radius: 3px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-dow.sun { color: var(--red); }
.cal-dow.sat { color: var(--brand); }
.cal-cell { min-height: 82px; border: 1px solid var(--border); border-radius: 9px; padding: 5px 5px 3px; background: var(--panel-2); overflow: hidden; }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.cal-day { font-size: 11.5px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.cal-leave { display: block; border-radius: 5px; padding: 2px 6px; margin-bottom: 3px; font-size: 10.5px;
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-leave.annual   { background: #e6f0ff; color: #1d6fd8; }
.cal-leave.vacation { background: #e9f9f0; color: #0a7a44; }
.cal-leave.sick     { background: #fdecec; color: #b42318; }
.cal-leave.half     { background: #fff2e6; color: #b45309; }
.cal-leave.etc      { background: var(--panel); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .cal-leave.annual   { background: #10233d; color: #6db2ff; }
  .cal-leave.vacation { background: #0f2a1c; color: #4ade80; }
  .cal-leave.sick     { background: #2c1414; color: #f79f97; }
  .cal-leave.half     { background: #2a1f10; color: #f5a524; }
}
@media (max-width: 640px) {
  .cal-cell { min-height: 60px; font-size: 10px; }
  .cal-leave { font-size: 9px; padding: 1px 4px; }
}

/* ---- 세금 계산 ---- */
.tax-controls { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn {
  font: inherit; cursor: pointer; border: none; background: transparent; color: var(--muted);
  padding: 8px 18px; border-radius: 9px; font-weight: 700; font-size: 13.5px; text-align: center; line-height: 1.25;
}
.seg-btn small { display: block; font-weight: 500; opacity: .85; font-size: 10.5px; margin-top: 1px; }
.seg-btn.active { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(79,108,247,.35); }
.tax-bracket { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.tax-bracket th, .tax-bracket td { padding: 7px 8px; border-bottom: 1px solid var(--grid); text-align: right; }
.tax-bracket th:first-child, .tax-bracket td:first-child { text-align: left; }
.tax-bracket th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.tax-bracket tr.on td { background: var(--brand-soft); font-weight: 700; color: var(--brand); }
.tax-disc { font-size: 11.5px; color: var(--muted); margin-top: 12px; line-height: 1.6; }

/* ---- 로그인 화면 ---- */
.auth-bg {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(185deg, #1d2340 0%, #241f4f 100%);
}
.auth-card {
  width: 100%; max-width: 390px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 34px 30px; box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.auth-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-logo .logo {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.auth-card h1 { text-align: center; font-size: 21px; margin: 0 0 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.auth-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); color: var(--text); font-size: 14px; outline: none; transition: .13s;
}
.auth-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.auth-btn {
  width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--brand);
  color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; transition: .13s;
  display: block; text-align: center; text-decoration: none; margin-top: 4px;
}
.auth-btn:hover { filter: brightness(1.05); }
.auth-btn:disabled { opacity: .6; cursor: default; }
.auth-btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); margin-top: 10px; }
.auth-err { color: var(--red); font-size: 13px; min-height: 18px; margin: 2px 0 6px; }
.auth-note { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.auth-info {
  background: var(--brand-soft); color: var(--brand); font-size: 13px; padding: 12px 14px;
  border-radius: 10px; margin-bottom: 14px; line-height: 1.5; text-align: center;
}
