:root {
  --bg: #f6f7f9;
  --fg: #1f2933;
  --muted: #6b7785;
  --border: #d8dee5;
  --card: #ffffff;
  --accent: #3478f6;
  --ok: #2ca87a;
  --warn: #d99100;
  --bad: #d04848;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  background: #1a2533;
  color: white;
  border-bottom: 1px solid #0c1320;
}
.topbar .brand { font-size: 16px; font-weight: 600; margin-right: 32px; }
.topbar .brand a { color: white; }
.topbar nav a { color: white; margin-right: 18px; opacity: 0.85; }
.topbar nav a:hover { opacity: 1; text-decoration: none; }
.topbar .user { margin-left: auto; font-size: 12px; opacity: 0.85; }
.topbar .user span { margin-right: 12px; }
.topbar .user a { color: #cbd6e2; }
main { max-width: 1100px; margin: 0 auto; padding: 24px; }
footer { text-align: center; padding: 24px; color: var(--muted); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.breadcrumb { color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--accent); }
table.rows { width: 100%; border-collapse: collapse; }
table.rows th, table.rows td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
table.rows thead th { background: #f0f2f5; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
table.rows td.num, table.rows th.num { text-align: right; font-variant-numeric: tabular-nums; }
code { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px; }
.rate-ok { color: var(--ok); }
.rate-warn { color: var(--warn); }
.rate-bad { color: var(--bad); }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { width: 200px; text-align: left; padding: 4px 8px 4px 0; color: var(--muted); font-weight: normal; }
table.kv td { padding: 4px 0; font-variant-numeric: tabular-nums; }
.badge { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #d6f3e7; color: var(--ok); }
.badge-warn { background: #fff0c4; color: var(--warn); }
.empty { color: var(--muted); font-style: italic; }
.error { color: var(--bad); }
.chart-note { color: var(--muted); margin: 0 0 12px; }
.flake-frequency-table { margin-top: 12px; }
.login-card {
  max-width: 380px;
  margin: 80px auto;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card label { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  margin-top: 4px;
}
.login-card button, .btn-secondary {
  margin-top: 16px;
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover, .btn-secondary:hover { filter: brightness(0.95); }
.btn-secondary { background: #e9edf2; color: var(--fg); margin-top: 0; display: inline-flex; align-items: center; justify-content: center; min-height: 34px; text-decoration: none; }
.login-card .hint { font-size: 12px; color: var(--muted); margin-top: 18px; }
.btn-link { color: var(--accent); font-size: 12px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.row-actions { white-space: nowrap; }
.row-actions a { margin-right: 8px; }
.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.inline-form label {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inline-form select, .inline-form input {
  min-width: 180px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: white;
  color: var(--fg);
}
.optimizer-kv td { white-space: normal; }
.rationale {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg);
}
.window-selector { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.window-selector a { padding: 4px 10px; color: var(--muted); font-size: 12px; text-decoration: none; }
.window-selector a.active { background: var(--accent); color: white; }
.window-selector a:hover { background: #f0f2f5; }
.window-selector a.active:hover { background: var(--accent); }
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
  gap: 8px;
}
.pagination-info { color: var(--muted); }
.pagination-links { display: inline-flex; gap: 6px; }
.pagination-links a, .pagination-links span {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
  background: var(--card);
}
.pagination-links span.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.pagination-links a:hover { background: #f0f2f5; }
/* Three-component stacked timestamp per architecture/GOOD_DESIGN.md.
   Server emits a UTC-only fallback inside .ts; client-side JS hydrates
   it with the relative-time line + local-tz line + UTC line. */
time.ts {
  display: inline-block;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  font-style: normal;
}
time.ts.ts-hydrated { display: inline-flex; flex-direction: column; }
.ts-empty { color: var(--muted); }
.ts-rel {
  font-weight: 600;
  color: var(--fg);
}
.ts-local, .ts-utc {
  color: var(--muted);
  font-size: 11px;
}
/* Cold-start / staleness banner. */
.banner {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  line-height: 1.45;
}
.banner code { background: rgba(0,0,0,0.06); padding: 0 4px; border-radius: 3px; }
.banner strong { margin-right: 6px; }
.banner-warn {
  background: #fff8df;
  border-color: #f0d989;
  color: #6f5300;
}
.banner-warn strong { color: var(--warn); }
.banner-error {
  background: #fde7e7;
  border-color: #f0a8a8;
  color: #6c1b1b;
}
.banner-error strong { color: var(--bad); }
.banner time.ts.ts-hydrated { margin-top: 4px; }