:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --line: #e3e2dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --series: #2a78d6;
  --series-soft: #cfe1f7;
  --focus: #2a78d6;
  --warn-bg: #fff4d9;
  --warn-text: #6b4b00;
  --error: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --line: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --series: #3987e5;
    --series-soft: #203a5c;
    --focus: #3987e5;
    --warn-bg: #3a2e10;
    --warn-text: #f3d48a;
    --error: #f2877f;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "Noto Sans Thai", "Sukhumvit Set", "Thonburi", system-ui, sans-serif; font-size: 15px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 8px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.login-card h1 { font-size: 20px; margin-bottom: 8px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.login-card button { margin-top: 4px; padding: 10px; border: 0; border-radius: 8px; background: var(--series); color: #fff; font-weight: 600; cursor: pointer; }
.error { color: var(--error); min-height: 1.5em; font-size: 14px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 17px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.filters select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.segments { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segments button { padding: 5px 10px; border: 0; background: none; cursor: pointer; color: var(--text-2); }
.segments button[aria-pressed="true"] { background: var(--series); color: #fff; }
.quiet { padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; color: var(--text-2); }

.status { padding: 0 16px; color: var(--text-2); }
.status:not(:empty) { padding-top: 12px; }
.content { max-width: 1160px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.card { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card > h2 { font-size: 15px; font-weight: 600; }
.card > .sub { color: var(--text-2); font-size: 13px; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; }
.section-title { font-size: 16px; font-weight: 600; margin-top: 8px; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
.empty { color: var(--text-2); padding: 24px 0; text-align: center; }

.chart { width: 100%; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--text-2); font-size: 11px; }
.chart .bar { fill: var(--series); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--series-soft); fill-opacity: .5; }
details { margin-top: 10px; font-size: 13px; color: var(--text-2); }
summary { cursor: pointer; }

.bars { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(110px, 42%) 1fr auto; align-items: center; gap: 8px; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { height: 10px; }
.bars .fill { height: 100%; min-width: 2px; background: var(--series); border-radius: 0 4px 4px 0; }
.bars .num { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 13px; white-space: nowrap; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-2); font-size: 13px; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; padding: 6px 10px; background: var(--text); color: var(--bg); border-radius: 8px; font-size: 13px; white-space: pre-line; }
