:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #5f6673;
  --line: #e3e6eb;
  --accent: #2357d8;
  --accent-soft: #e8eefc;
  --green: #17803d;
  --green-soft: #e3f4e8;
  --yellow: #8a6100;
  --yellow-soft: #fdf3d8;
  --red: #b42318;
  --red-soft: #fde8e6;
  --bar: #6b8fe8;
  --radius: 10px;
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a21; --ink: #e8eaee; --muted: #9aa2b1; --line: #2a2f3a;
    --accent: #7aa2ff; --accent-soft: #1e2a47; --green: #5fd38a; --green-soft: #15301f;
    --yellow: #f2c35b; --yellow-soft: #3a2e10; --red: #ff8a80; --red-soft: #3d1a17; --bar: #4f74d6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a21; --ink: #e8eaee; --muted: #9aa2b1; --line: #2a2f3a;
  --accent: #7aa2ff; --accent-soft: #1e2a47; --green: #5fd38a; --green-soft: #15301f;
  --yellow: #f2c35b; --yellow-soft: #3a2e10; --red: #ff8a80; --red-soft: #3d1a17; --bar: #4f74d6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; margin: 0 6px 4px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a:hover { text-decoration: none; background: var(--accent-soft); }
.side-foot { position: absolute; bottom: 16px; left: 14px; right: 14px; font-size: 12px; color: var(--muted); }
.side-foot button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; cursor: pointer; }

main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12px; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { background: var(--accent-soft); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-row .fill { background: var(--bar); height: 100%; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.cols .col { flex: 1; background: var(--bar); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.cols-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.cols-x span { flex: 1; text-align: center; overflow: hidden; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 120px; }
.filters input[type="search"] { min-width: 240px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
tr:hover td { background: var(--accent-soft); }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; margin: 1px 2px 1px 0; }
.badge.GREEN { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.YELLOW { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
.badge.RED { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.active { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.closed { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.src { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.masked { color: var(--muted); font-style: italic; }

.doc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; }
.doc table { font-size: 13px; margin: 10px 0 16px; }
.doc table th { position: static; }
.doc code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.doc pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow: auto; }
.doc h1 { font-size: 20px; } .doc h2 { font-size: 17px; margin-top: 26px; } .doc h3 { font-size: 15px; }
.doc-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.doc-tabs a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); font-size: 13px; }
.doc-tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.err { color: var(--red); font-size: 13px; min-height: 18px; }
.loading { color: var(--muted); padding: 20px 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; margin-top: 8px; }
  .side-foot { position: static; margin-top: 8px; }
  main { padding: 16px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 56px; }
  .filters input[type="search"] { min-width: 0; width: 100%; }
}
