:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raise: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --grid: #e9e8e2;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --wash: rgba(11, 11, 11, 0.04);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s1-wash: rgba(42, 120, 214, 0.10);
  --good: #006300;
  --bad: #c03030;
  --focus: #2a78d6;
  --heat-0: #eef4fc;
  --heat-1: #1c5cab;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raise: #222220;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --grid: #2c2c2a;
    --axis: #45443f;
    --border: rgba(255, 255, 255, 0.09);
    --wash: rgba(255, 255, 255, 0.05);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s1-wash: rgba(57, 135, 229, 0.16);
    --good: #3cbf3c;
    --bad: #ec6b6b;
    --heat-0: #1e2733;
    --heat-1: #5598e7;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --raise: #222220;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #8f8d86;
  --grid: #2c2c2a;
  --axis: #45443f;
  --border: rgba(255, 255, 255, 0.09);
  --wash: rgba(255, 255, 255, 0.05);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s1-wash: rgba(57, 135, 229, 0.16);
  --good: #3cbf3c;
  --bad: #ec6b6b;
  --heat-0: #1e2733;
  --heat-1: #5598e7;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.grow { flex: 1; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.login-card h1 { margin: 4px 0 0; font-size: 20px; font-weight: 650; }
.login-card p { margin: 0; }
.login-card input {
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--raise);
}
.login-card button {
  padding: 11px 12px; border-radius: 10px; border: 0; background: var(--s1); color: #fff; font-weight: 600; cursor: pointer;
}
.error { color: var(--bad); min-height: 1.2em; font-size: 14px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 650; white-space: nowrap; }
.app-select {
  font-weight: 600; border: 1px solid var(--border); background: var(--raise); border-radius: 8px;
  padding: 6px 28px 6px 10px; max-width: 46vw;
}
.icon-btn, .link-btn {
  border: 1px solid var(--border); background: transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.link-btn { color: var(--ink-2); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  text-decoration: none; padding: 10px 10px 12px; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--s1); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 14px; padding-bottom: 6px; }
.seg { display: inline-flex; background: var(--wash); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2);
  font-weight: 550; font-size: 14px;
}
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.custom { display: flex; gap: 8px; flex-wrap: wrap; }
.custom label { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.custom input, .filter select {
  border: 1px solid var(--border); background: var(--raise); border-radius: 8px; padding: 6px 8px; font-size: 14px;
}
.filter select { max-width: 160px; }
.range-label { font-size: 13px; margin-left: auto; }

/* page */
main { padding-top: 8px; padding-bottom: 24px; transition: opacity .15s; }
main.loading { opacity: .55; }
h2.page-title { font-size: 22px; font-weight: 650; margin: 10px 0 4px; letter-spacing: -0.01em; }
.lede { margin: 0 0 16px; color: var(--ink-2); max-width: 72ch; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  box-shadow: var(--shadow); min-width: 0; grid-column: span 12; position: relative;
}
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-8 { grid-column: span 8; }
@media (max-width: 860px) { .span-6, .span-4, .span-8 { grid-column: span 12; } }
.card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 620; }
.card .sub { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.card .note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* stat tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.tile .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile .value { font-size: 23px; }
  .tile { padding: 12px; }
}

/* definition box */
.def {
  border-left: 3px solid var(--s1); background: var(--surface); border-radius: 0 10px 10px 0;
  padding: 10px 14px; margin: 0 0 16px; font-size: 14px; color: var(--ink-2); max-width: 900px;
}
.def b { color: var(--ink); font-weight: 600; }
.def p { margin: 4px 0; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin: -4px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.legend i.box { width: 10px; height: 10px; border-radius: 3px; }
.tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--raise); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); min-width: 120px;
}
.tip .t-head { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tip .t-row { display: flex; align-items: center; gap: 8px; }
.tip .t-row b { font-variant-numeric: tabular-nums; font-weight: 650; }
.tip .t-row i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.tip .t-row span { color: var(--ink-2); }

/* bars in HTML (funnels, distributions) */
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 104px; align-items: center; gap: 10px; font-size: 13.5px; }
.bar-row .k { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row .v small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.track { height: 10px; background: var(--wash); border-radius: 5px; overflow: hidden; }
.fill { height: 100%; background: var(--s1); border-radius: 5px; min-width: 2px; }
.fill.s2 { background: var(--s2); }
.fill.s3 { background: var(--s3); }
@media (max-width: 520px) { .bar-row { grid-template-columns: 64px 1fr 88px; gap: 8px; } }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12.5px; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--wash); }
td.heat { text-align: center; font-variant-numeric: tabular-nums; border-bottom: 2px solid var(--surface); border-right: 2px solid var(--surface); border-radius: 4px; }
td.empty { color: var(--muted); text-align: center; }
tr.click { cursor: pointer; }
tr.sel td { background: var(--s1-wash); }
.flag { margin-right: 6px; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; background: var(--wash); color: var(--ink-2); }
.warn { color: var(--bad); font-weight: 600; }
details.tv { margin-top: 10px; font-size: 13px; }
details.tv summary { cursor: pointer; color: var(--muted); }
details.tv .table-wrap { margin-top: 8px; max-height: 320px; overflow: auto; }
.pager { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.pager button { border: 1px solid var(--border); background: var(--raise); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }
.spark { display: block; width: 120px; height: 26px; }
@media (max-width: 520px) { .spark { width: 72px; } }
.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); }
.foot { font-size: 12.5px; padding-bottom: 28px; }
.link-btn, .icon-btn { white-space: nowrap; flex: none; }
@media (max-width: 520px) {
  .top-row { gap: 8px; }
  .brand span { display: none; }
  .app-select { max-width: none; min-width: 0; flex: 1; }
  .top-row .grow { display: none; }
  .tiles > .tile:last-child:nth-child(odd) { grid-column: span 2; }
  .range-label { margin-left: 0; width: 100%; }
  .filter { flex: 1 1 40%; }
  .filter select { max-width: none; width: 100%; }
}
.bar-col { width: 30%; min-width: 90px; }
@media (max-width: 520px) { .bar-col { display: none; } }
