:root {
  color-scheme: light;
  --surface-0: #f6f6f4;
  --surface-1: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ebeae6;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --link: #1c5cab;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --accent-bg: #eaf2fc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #33322f;
    --grid: #2a2a28;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9b9a92;
    --link: #86b6ef;
    --series-1: #3987e5;
    --series-2: #d95926;
    --accent-bg: #18263a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --border: #33322f;
  --grid: #2a2a28;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #9b9a92;
  --link: #86b6ef;
  --series-1: #3987e5;
  --series-2: #d95926;
  --accent-bg: #18263a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
a { color: var(--link); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 32px; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 20px 0 6px; }
h2 { font-size: 1.25rem; margin: 36px 0 12px; }
h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.sub { color: var(--text-secondary); margin: 0 0 16px; }
.ko { color: var(--text-muted); font-weight: 400; font-size: .85em; }
.note { color: var(--text-secondary); font-size: .9rem; }
.todo { background: #fff3cd; color: #5c4400; padding: 8px 12px; border-radius: 6px; }

.top { background: var(--surface-1); border-bottom: 1px solid var(--border); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text-primary); text-decoration: none; }
.top nav a { margin-left: 16px; color: var(--text-secondary); text-decoration: none; font-size: .95rem; }
.top nav a:first-child { margin-left: 0; }
.crumbs { font-size: .85rem; color: var(--text-muted); margin-top: 16px; }

.hero .lede { font-size: 1.08rem; color: var(--text-secondary); max-width: 760px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kpi-label { font-size: .8rem; color: var(--text-secondary); }
.kpi-value { font-size: 1.3rem; font-weight: 650; margin-top: 2px; }
.kpi-change { font-size: .8rem; color: var(--text-muted); }
.summary { background: var(--accent-bg); border-radius: 10px; padding: 4px 16px; }
.summary p { margin: 10px 0; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; }
@media (max-width: 520px) { .chart-grid { grid-template-columns: 1fr; } }
.figure { margin: 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.figure figcaption { display: flex; flex-direction: column; margin-bottom: 6px; }
.figure figcaption span { font-size: .8rem; color: var(--text-muted); }
.legend { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.sw-1 { background: var(--series-1); }
.sw-2 { background: var(--series-2); }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--text-muted); stroke-width: 1; }
svg.chart .tick { fill: var(--text-muted); font-size: 11px; }
svg.chart .label { fill: var(--text-primary); font-size: 12px; font-weight: 600; }
svg.chart .bar { fill: var(--series-1); }
svg.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
svg.chart .line-2 { stroke: var(--series-2); }
svg.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
svg.chart .dot-2 { fill: var(--series-2); }
svg.chart .pt { fill: var(--series-1); fill-opacity: .55; stroke: var(--surface-1); stroke-width: 1.5; }
svg.chart .pt:hover, svg.chart .pt:focus { fill-opacity: 1; outline: none; }
svg.chart .hit { fill: transparent; }
svg.chart .hit:focus { outline: none; }
svg.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; opacity: 0; pointer-events: none; }
svg.chart.active .crosshair { opacity: 1; }
.tip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 260px; padding: 6px 10px; border-radius: 6px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15); font-size: .85rem;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); }
.table-wrap.narrow { max-width: 420px; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
caption { text-align: left; padding: 8px 10px 0; font-weight: 600; font-size: .85rem; color: var(--text-secondary); }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--text-secondary); font-size: .8rem; }
tbody tr:last-child td { border-bottom: 0; }
td .ko { margin-left: 4px; }

.band { margin-bottom: 18px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0 0 10px; }
.facts div { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: .75rem; color: var(--text-secondary); }
.facts dd { margin: 0; font-weight: 600; }
.defs dt { font-weight: 600; margin-top: 10px; }
.defs dd { margin: 2px 0 0; color: var(--text-secondary); }

.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cards a { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); text-decoration: none; color: var(--text-primary); }
.cards span { display: block; color: var(--text-secondary); font-size: .85rem; }
.plain { padding-left: 20px; }
.plain li { margin: 6px 0; }
.more { font-weight: 600; }

.cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--accent-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin: 8px 0 8px; }
.cta p { margin: 4px 0 0; color: var(--text-secondary); font-size: .92rem; max-width: 640px; }
.cta-btn { display: inline-block; background: var(--link); color: var(--surface-1); font-weight: 600; text-decoration: none;
  padding: 9px 14px; border-radius: 8px; white-space: nowrap; }
.cta-line { font-size: .92rem; margin: 10px 0 0; }

.foot { border-top: 1px solid var(--border); background: var(--surface-1); padding: 20px 0 28px; margin-top: 24px; font-size: .9rem; }
.actor { background: var(--accent-bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.foot .meta { color: var(--text-muted); font-size: .8rem; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }

@media (max-width: 520px) {
  h1 { font-size: 1.4rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 1.05rem; }
  .top nav a { margin-left: 12px; }
  /* SVG text scales with the chart; enlarge it so axis labels stay readable at phone width */
  svg.chart .tick { font-size: 19px; }
  svg.chart .label { font-size: 21px; }
}
