.viz-root {
  color-scheme: light;
  --page: #f4f3f0;
  --surface-1: #fcfcfb;
  --border: #e3e2dd;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --series-1: #2a78d6;
  --series-1-hover: #1d63b8;
  --good: #0a7d32;
  --critical: #c62f2f;
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    color-scheme: dark;
    --page: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #96958c;
    --series-1: #3987e5;
    --series-1-hover: #62a2ee;
    --good: #3fbf6a;
    --critical: #ef7474;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif; }
.viz-root { min-height: 100vh; background: var(--page); color: var(--text-primary); padding: 20px 16px 48px; }
main, .gate form { max-width: 1040px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; color: var(--text-secondary); }
section { margin-top: 24px; }
.sub { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }

.gate { display: grid; place-items: center; min-height: 70vh; }
.gate form { width: 100%; max-width: 320px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 24px; display: grid; gap: 10px; }
.gate h1 { margin-bottom: 8px; }
.gate label { font-size: 13px; color: var(--text-secondary); }
.remember { display: flex; gap: 6px; align-items: center; }
input[type=password], input[type=date] { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 0; background: var(--series-1); color: #fff; cursor: pointer; }
button.ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.msg { min-height: 1.2em; margin: 0; font-size: 13px; color: var(--critical); }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.controls { display: flex; gap: 8px; align-items: center; }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile .value small { font-size: 14px; font-weight: 500; margin-left: 2px; color: var(--text-secondary); }
.tile .delta { font-size: 12px; margin-top: 6px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.delta .up { color: var(--good); font-weight: 600; }
.delta .down { color: var(--critical); font-weight: 600; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--text-secondary); border-radius: 0; padding: 6px 12px; font-size: 13px; }
.seg button[aria-selected=true] { background: var(--series-1); color: #fff; }
.chart-wrap { position: relative; }
#chart { width: 100%; height: 260px; display: block; }
#chart text { fill: var(--text-muted); font-size: 11px; }
#chart .grid { stroke: var(--grid); }
#chart .bar { fill: var(--series-1); }
#chart .bar.sel { fill: var(--series-1-hover); }
#chart .hit:hover + .bar, #chart .bar.hover { fill: var(--series-1-hover); }
.tip { position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / .12); white-space: nowrap; transform: translate(-50%, -100%); }
.tip b { display: block; font-size: 14px; margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--text-secondary); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--grid); }
tbody tr.sel { background: var(--grid); font-weight: 600; }
tbody td.closed { color: var(--text-muted); }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.sat { color: #2a78d6; } .sun { color: #d0453e; }

.hint { font-weight: 400; font-size: 12px; color: var(--text-muted); }
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .rank-grid { grid-template-columns: 1fr; } }
.card-title { font-size: 14px; margin: 0 0 10px; }
.card-title span { font-weight: 400; color: var(--text-secondary); margin-left: 4px; }
.rank-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 420px) { .rank-pair { grid-template-columns: 1fr; } }
.rank h3 { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 0 0 6px; }
.rank ol { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.rank .rk { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rank .nm { overflow-wrap: anywhere; }
.rank .ct { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank .ct::after { content: '皿'; font-weight: 400; font-size: 11px; color: var(--text-secondary); margin-left: 1px; }
.rank .note, .empty { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
