:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  color: #152b32;
  background: #f3f6f5;
  --muted: #52646b;
  --line: #dce5e4;
  --sample: #92ccc4;
  --game: #eab878;
  --suspicious: #e7a0ad;
  --match: #5265a9;
  --missing: #e6edec;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid #25469a; outline-offset: 3px; }
.shell { width: min(1120px, calc(100% - 56px)); margin-inline: auto; }
.topbar { background: #15383a; color: #f5faf8; }
.topbar-inner { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-weight: 650; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 14px; height: 14px; border: 1px solid #a9d6c9; border-radius: 4px; box-shadow: inset 0 0 0 3px #15383a; background: #a9d6c9; }
.device { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 12px; color: #c5d9d6; }
.device label { flex: none; }
.device select { width: min(300px, 40vw); padding: 6px 8px; color: #f5faf8; background: #1c4a4b;
  border: 1px solid #698986; border-radius: 6px; }
.device button { color: #f5faf8; background: transparent; border: 1px solid #698986; border-radius: 6px; padding: 6px 8px; white-space: nowrap; }
.main { padding-block: 34px 28px; }
.page-title, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.page-title { align-items: center; margin-bottom: 22px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 4vw, 38px); line-height: 1.2; }
h2 { font-size: 17px; }
.page-title p, .panel-heading p, .footnote { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.65; }
.refresh { border: 1px solid #b7ccc7; border-radius: 7px; background: #fff; padding: 8px 13px; color: #204d4a; font-size: 13px; white-space: nowrap; }
.refresh:hover { background: #eaf5f0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat, .panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.stat { padding: 16px 18px; }
.stat h2 { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat p { font-size: clamp(18px, 3vw, 30px); font-weight: 650; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.panel { margin-bottom: 14px; padding: 19px 20px; }
.rule-panel { padding-block: 12px; }
.rule-panel summary { cursor: pointer; color: #204d4a; font-size: 14px; font-weight: 650; }
.rules-form { display: grid; gap: 6px; margin-top: 13px; max-width: 500px; }
.rules-form label { font-size: 13px; font-weight: 650; }
.rules-form p, .rules-form span, .report-picker, .metrics-summary { color: var(--muted); font-size: 12px; line-height: 1.45; }
.interval-form { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.interval-form input, .report-picker select, .login-form input { padding: 6px 8px; border: 1px solid #bacbca; border-radius: 6px; color: #173638; background: #fff; }
.interval-form input { width: 116px; }
.rules-form textarea { padding: 8px 9px; border: 1px solid #bacbca; border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.rules-actions { display: flex; align-items: center; gap: 10px; }
.rules-actions button { flex: none; border: 1px solid #194746; border-radius: 6px;
  background: #194746; color: #fff; font-size: 13px; padding: 6px 11px; }
.rules-actions button:disabled { opacity: .55; cursor: default; }
.panel-heading { margin-bottom: 14px; }
.filters { display: flex; align-items: flex-end; gap: 12px; }
.filters label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.filters select, .filters input { width: 100%; background: #fff; border: 1px solid #bacbca; border-radius: 6px; color: #173638; font-size: 13px; padding: 7px; }
.filters input { max-width: 190px; }
.chart-scroll, .table-scroll { overflow-x: auto; }
#timeline { min-width: 975px; display: grid; gap: 2px; }
.timeline-row { display: grid; grid-template-columns: 49px repeat(24, minmax(34px, 1fr)); gap: 3px; align-items: stretch; }
.chart-axis { margin-bottom: 3px; }
.chart-axis span, .date-label { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-axis span { align-content: end; padding-bottom: 2px; }
.chart-axis .axis-start { color: #113d3a; font-weight: 700; }
.date-label { position: sticky; left: 0; z-index: 1; background: #fff; align-content: center; }
.hour { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; height: 26px;
  border: 1px solid transparent; border-radius: 4px; background: #fff; padding: 2px 1px; }
.hour-start { border-left-color: #bccbc8; }
button.hour:hover, button.hour[aria-pressed="true"] { border-color: #294f52; }
.cell, .legend i { border: 1px solid transparent; border-radius: 2px; }
.cell { min-width: 0; }
.sample { background: var(--sample); }
.game { background: var(--game); }
.suspicious { background: var(--suspicious); }
.match { background: var(--match); }
.missing { background: var(--missing); }
.future { background: #fff; border-color: #e2e8e7 !important; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 15px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; }
#timeline-status { color: var(--muted); font-size: 12px; margin-top: 9px; min-height: 1.3em; }
.quarters:not([hidden]) { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.report-picker:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.metrics-summary { margin-bottom: 9px; }
.quarters .quarter { display: grid; gap: 3px; text-align: left; padding: 7px 9px; min-width: 0;
  border: 1px solid var(--line); border-left: 4px solid var(--quarter-accent, var(--missing));
  border-radius: 6px; background: #fff; color: #152b32; }
.quarter strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.quarter span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.quarters .quarter[aria-pressed="true"] { background: #f2f8f5; border-color: #285759; }
.quarter:disabled { cursor: default; background: #f6f8f7; }
.quarter.sample { --quarter-accent: var(--sample); }
.quarter.game { --quarter-accent: var(--game); }
.quarter.suspicious { --quarter-accent: var(--suspicious); }
.quarter.match { --quarter-accent: var(--match); }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 13px; white-space: nowrap; }
th, td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td:nth-child(2), td:nth-child(3) { font-variant-numeric: tabular-nums; }
.rule-match { display: inline-block; margin-left: 8px; padding: 2px 5px; border-radius: 4px;
  background: #fae9ed; color: #762d40; font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.footnote { padding-inline: 1px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding-block: 20px; }
.login-panel { width: min(100%, 420px); padding: 26px; }
.login-panel h1 { font-size: 27px; }
.login-form { display: grid; gap: 8px; margin-top: 20px; font-size: 14px; }
.login-form .rules-actions { margin-top: 8px; }

@media (max-width: 650px) {
  .shell { width: calc(100% - 28px); }
  .main { padding-top: 24px; }
  .panel { padding: 14px; }
  .panel-heading { flex-direction: column; gap: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .stat { padding: 9px; }
  .stat h2 { font-size: 11px; }
  .stat p { font-size: 16px; }
  .quarters:not([hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
