:root {
  color-scheme: light;
  --side: #0f1729;
  --side-2: #182235;
  --side-text: #c7cfdd;
  --side-muted: #7d889c;
  --primary: #2563eb;
  --page: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e4e8ef;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #8a93a3;
  --s-other: #2a78d6;      /* 강사료 외 (categorical 1) */
  --s-lecture: #eb6834;    /* 강사료 (categorical 2) */
  --track: #dbe7fb;
  --fill: #2a78d6;
  --warn: #fab219;
  --warn-bg: #fff8e6;
  --warn-line: #f6dd9c;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good: #0ca30c;
  --chip-bg: #eef3fe;
  --row-hover: #f3f6fb;
  --focus: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --side: #0b1120; --side-2: #151d2e;
    --page: #111318; --surface: #1a1c22; --surface-2: #20232a; --line: #2c3039;
    --text: #eef0f4; --text-2: #b9bfcb; --text-3: #8790a0;
    --s-other: #3987e5; --s-lecture: #d95926; --track: #16325c; --fill: #3987e5;
    --warn-bg: #2d2615; --warn-line: #5c4a1c; --chip-bg: #1e2a42; --row-hover: #22262e; --focus: #6da7ec;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --side: #0b1120; --side-2: #151d2e;
  --page: #111318; --surface: #1a1c22; --surface-2: #20232a; --line: #2c3039;
  --text: #eef0f4; --text-2: #b9bfcb; --text-3: #8790a0;
  --s-other: #3987e5; --s-lecture: #d95926; --track: #16325c; --fill: #3987e5;
  --warn-bg: #2d2615; --warn-line: #5c4a1c; --chip-bg: #1e2a42; --row-hover: #22262e; --focus: #6da7ec;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- 레이아웃 ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: 236px; z-index: 30;
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column;
}
.main { flex: 1; min-width: 0; margin-left: 236px; }
.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); display: grid; gap: 1px; }
.brand strong { color: #fff; font-size: 18px; letter-spacing: -0.01em; }
.brand span { color: #5b9cff; font-size: 13px; font-weight: 600; }
.brand small { color: var(--side-muted); font-size: 11px; margin-top: 4px; }
.nav { padding: 14px 10px; display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; color: var(--side-text); }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.nav .count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(255,255,255,.1); color: #dbe3f0; font-variant-numeric: tabular-nums; }
.nav .count.warn { background: var(--warn); color: #1a1a19; font-weight: 700; }
.nav .count:empty { display: none; }
.side-foot { margin-top: auto; padding: 14px 10px 18px; }
.reload { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; padding: 11px; background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; }
.reload:hover { filter: brightness(1.08); }
.reload.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync { display: flex; align-items: center; gap: 6px; margin: 10px 4px 0; font-size: 11px; color: var(--side-muted); }
.sync #sync-time { margin-left: auto; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--side-muted); }
.dot.ok { background: #22c55e; }
.dot.demo { background: var(--warn); }
.dot.err { background: var(--critical); }
.scrim { position: fixed; inset: 0; background: rgba(15,23,41,.45); z-index: 25; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar .unit { margin-left: auto; font-size: 12px; color: var(--text-3); }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px; cursor: pointer; }
.content { padding: 24px 28px 48px; max-width: 1280px; }
.view { display: none; }
.view.active { display: grid; gap: 16px; }

/* ---------- 카드 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.head-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-card h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live { font-size: 11px; font-weight: 600; color: #15803d; background: #ecfdf3; border: 1px solid #b7ebc9; border-radius: 6px; padding: 2px 8px; }
.live.demo { color: #92400e; background: var(--warn-bg); border-color: var(--warn-line); }
.muted { color: var(--text-3); font-size: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sec { margin: 0 0 14px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head .sec { margin: 0; }
.sec i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-blue { background: var(--s-other); } .dot-green { background: #22c55e; } .dot-orange { background: var(--s-lecture); }
.note { margin: 0; color: var(--text-3); font-size: 12px; }
.more { color: var(--primary); font-size: 13px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.error { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }

/* stat 타일 */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-5 { grid-template-columns: repeat(5, 1fr); }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: block; min-width: 0; }
.view > .stats .stat { background: var(--surface); }
.stat.wide { grid-column: 1 / -1; }
.stat p { margin: 0; font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat b { display: block; font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat b .u { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.stat b.hero { font-size: 36px; line-height: 1.15; }
.stat small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-3); }
.stat .meter { margin-top: 10px; }
.c-blue { color: var(--primary); } .c-orange { color: #c2410c; } .c-red { color: var(--critical); }
.warn-stat { background: var(--warn-bg); border-color: var(--warn-line); cursor: pointer; }
.warn-stat:hover { border-color: var(--warn); }
.status-icon { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #1a1a19; background: var(--warn); flex: none; font-style: normal; }

.meter { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--fill); border-radius: 4px; }

/* 항목별 */
.items { display: grid; gap: 14px; }
.item { display: grid; grid-template-columns: 150px 1fr 240px; gap: 14px; align-items: center; }
.item-name { font-weight: 600; }
.item-name small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; }
.item-nums { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.item-nums .m { color: var(--text-3); }
.no-budget { color: var(--text-3); font-size: 12px; }

/* 범례 · 배지 */
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.s-lecture { background: var(--s-lecture); } .s-other { background: var(--s-other); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-style: normal; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; line-height: 1; padding: 4px 7px; border-radius: 5px; white-space: nowrap; background: var(--chip-bg); color: var(--text-2); border: 1px solid var(--line); }
.badge.lec { background: color-mix(in srgb, var(--s-lecture) 12%, var(--surface)); border-color: color-mix(in srgb, var(--s-lecture) 40%, var(--line)); color: var(--text); }
.badge.lec::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--s-lecture); }
.badge.plan { background: var(--surface-2); color: var(--text-3); font-weight: 500; }
.badge.club { background: color-mix(in srgb, #22c55e 12%, var(--surface)); border-color: color-mix(in srgb, #22c55e 40%, var(--line)); color: var(--text); }
.badge.none { background: var(--warn-bg); border-color: var(--warn-line); color: var(--text); }

/* 가로 누적 막대 */
.bars { display: grid; gap: 2px; }
.bar-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: center; padding: 6px 8px; border-radius: 8px; }
a.bar-row:hover { background: var(--row-hover); }
.bar-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar-label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; --label-room: 190px; }
.bar { display: flex; gap: 2px; height: 16px; flex: none; }
.seg { height: 100%; min-width: 2px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg.lecture { background: var(--s-lecture); } .seg.other { background: var(--s-other); }
.bar-value { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.bar-value .m { color: var(--text-3); font-size: 12px; margin-left: 4px; }

/* ---------- 부서 카드 ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; flex: 0 1 320px; color: var(--text-3); }
.search input { border: 0; outline: 0; background: transparent; padding: 9px 0; width: 100%; color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.chips button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.list-sum { margin: -4px 2px 0; }
.unit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ucard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, box-shadow .15s; }
.ucard:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); box-shadow: 0 6px 18px rgba(17,24,39,.06); }
.ucard-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ucard h3 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.35; }
.ucard .badges { justify-content: flex-end; }
.ubox { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; display: grid; gap: 7px; font-size: 13px; }
.urow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.urow .k { color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.urow .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.urow .v.big { font-size: 16px; }
.pill { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 6px; background: var(--chip-bg); color: var(--primary); }
.pill.o { background: color-mix(in srgb, var(--s-lecture) 14%, var(--surface)); color: #c2410c; }
.ubar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--track); }
.ubar .seg:first-child { border-radius: 4px 0 0 4px; }
.ubar .seg:last-child { border-radius: 0 4px 4px 0; }
.ubar .seg:only-child { border-radius: 4px; }
.ucard-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto; }
.ucard-foot a { color: var(--primary); font-weight: 600; }
.empty { padding: 28px; color: var(--text-3); text-align: center; grid-column: 1 / -1; }

.back { color: var(--primary); font-weight: 600; font-size: 13px; }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-bg); border-color: var(--warn-line); }
.notice p { margin: 0; color: var(--text-2); font-size: 13px; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.card > .table-wrap:only-child { border: 0; margin: -6px -8px; }
.table-scroll { max-height: 640px; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 180px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; position: sticky; bottom: 0; }
.tag-lec { display: inline-flex; align-items: center; gap: 5px; }
.tag-lec::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--s-lecture); }

/* 필터 */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters .search { flex: 1 1 220px; }
.filters select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; max-width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); padding: 0 4px; font-size: 13px; }

/* 월별 */
.months { position: relative; height: 260px; }
.m-grid { position: absolute; left: 60px; right: 0; border-top: 1px solid var(--line); }
.m-grid span { position: absolute; left: -60px; width: 52px; text-align: right; top: -9px; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.m-cols { position: absolute; left: 60px; right: 0; top: 8px; bottom: 28px; display: flex; align-items: flex-end; justify-content: space-around; }
.m-col { position: relative; height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.m-col .col { width: min(28px, 60%); background: var(--fill); border-radius: 4px 4px 0 0; min-height: 1px; }
.m-col .cap { font-size: 11px; margin-bottom: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-col .x { position: absolute; bottom: -22px; font-size: 12px; color: var(--text-2); }

.tip { position: fixed; z-index: 50; pointer-events: none; background: #111827; color: #fff; border-radius: 7px; padding: 8px 10px; font-size: 12px; line-height: 1.5; max-width: 260px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }

/* ---------- 반응형 ---------- */
@media (max-width: 1180px) {
  .unit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 960px) {
  .side { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 8px 0 24px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar .unit { display: none; }
  .unit-grid { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr; gap: 6px; }
  .item-nums { text-align: left; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-track { --label-room: 150px; }
  .bar-value .m { display: block; margin-left: 0; }
  .stats-3, .stats-5 { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 19px; }
  .stat b.hero { font-size: 30px; }
  .card { padding: 16px; }
  .search { flex: 1 1 100%; }
}

/* 표/그래프 전환 */
.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; background: var(--surface-2); }
.seg-toggle button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.seg-toggle button[aria-selected="true"] { background: var(--surface); color: var(--primary); font-weight: 700; box-shadow: 0 1px 3px rgba(17,24,39,.12); }
.strong { font-weight: 650; }
.items-tbl td { padding: 10px 12px; }
.rate { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.meter.mini { width: 90px; height: 6px; }
.foot-note { margin-top: 10px; }
[hidden] { display: none !important; }

/* 항목별 그래프 보기: 항목 카드 */
#items.items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.icard { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--surface-2); display: grid; gap: 10px; }
.icard-top { display: flex; align-items: center; gap: 8px; }
.icard-name { font-size: 15px; }
.icard-pct { margin-left: auto; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter.thick { height: 10px; border-radius: 5px; }
.icard-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.icard-nums.one { grid-template-columns: 1fr; }
.icard-nums > div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.icard-nums span { display: block; font-size: 11.5px; color: var(--text-3); }
.icard-nums b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.icard-nums b small { font-size: 11px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.icard-nums b.m { color: var(--text-2); font-weight: 600; }
.icard-nums .rem b { color: var(--primary); }
.icard.nob { background: var(--surface); border-style: dashed; }
@media (max-width: 960px) { #items.items { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .icard-nums { grid-template-columns: 1fr; } }
