:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #17191c;
  --muted: #646b75;
  --border: #e2e5ea;
  --accent: #2459d6;
  --accent-text: #ffffff;
  --good-bg: #e7f6ec; --good: #17663a;
  --warn-bg: #fff4e0; --warn: #8a5300;
  --bad-bg: #fdecec;  --bad: #a1251f;
  --info-bg: #eaf0fd; --info: #2a4ea8;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Night: chosen with the Day/Night toggle (data-theme), or the system setting when no choice is saved. */
:root[data-theme="dark"] {
  --bg: #111317; --surface: #191c21; --text: #e8eaee; --muted: #9aa1ab; --border: #2a2f37;
  --accent: #6d95ff; --accent-text: #0b1020;
  --good-bg: #12301f; --good: #7fd6a2; --warn-bg: #352610; --warn: #f2c27a;
  --bad-bg: #3a1716; --bad: #ff9c94; --info-bg: #182540; --info: #9db8ff;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #191c21; --text: #e8eaee; --muted: #9aa1ab; --border: #2a2f37;
    --accent: #6d95ff; --accent-text: #0b1020;
    --good-bg: #12301f; --good: #7fd6a2; --warn-bg: #352610; --warn: #f2c27a;
    --bad-bg: #3a1716; --bad: #ff9c94; --info-bg: #182540; --info: #9db8ff;
    color-scheme: dark;
  }
}

/* Day/Night toggle */
.theme-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--bg); }
.theme-toggle button { font: inherit; font-size: .82rem; border: 0; background: transparent; color: var(--muted); padding: .25rem .65rem; border-radius: 999px; cursor: pointer; }
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.login-tools { position: fixed; top: 12px; right: 16px; }
.btn-small { padding: .2rem .6rem; font-size: .8rem; }
.row-actions { white-space: nowrap; text-align: right; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
h1, h2 { margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); font-weight: 400; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .01em; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a, .nav .soon { padding: .3rem .6rem; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.nav a.active { background: var(--info-bg); color: var(--info); font-weight: 600; }
.nav .soon { opacity: .55; cursor: default; }
.logout { margin: 0; }

/* layout */
.page { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page > * { min-width: 0; } /* wide tables scroll inside their panel instead of widening the page */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card-label { color: var(--muted); font-size: .85rem; }
.card-value { font-size: 1.8rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.card-value.small { font-size: 1.25rem; padding: .3rem 0; }
.card-sub { color: var(--muted); font-size: .8rem; min-height: 1.1em; }
.actions { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .55rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }

/* status */
.alert { padding: .7rem .9rem; border-radius: var(--radius); background: var(--info-bg); color: var(--info); }
.alert-good { background: var(--good-bg); color: var(--good); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.badge { display: inline-block; white-space: nowrap; padding: .05rem .45rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--info-bg); color: var(--info); }
.badge-classified, .badge-ok { background: var(--good-bg); color: var(--good); }
.badge-ignored, .badge-skipped { background: var(--border); color: var(--muted); }
.badge-unknown, .badge-partial, .badge-running { background: var(--warn-bg); color: var(--warn); }
.badge-failed { background: var(--bad-bg); color: var(--bad); }
/* matching: review kinds and link methods */
.badge-missing_pass { background: var(--bad-bg); color: var(--bad); }
.badge-ambiguous_accept, .badge-extra_pass, .badge-transfer_timing, .badge-delivery_timing { background: var(--warn-bg); color: var(--warn); }
.badge-accept_email { background: var(--good-bg); color: var(--good); }
.small { font-size: .82rem; }
.choices { display: grid; gap: .3rem; }
.choice { display: flex; align-items: center; justify-content: space-between; gap: .6rem; font-size: .85rem; }
.choice span { min-width: 0; overflow-wrap: anywhere; }

/* buttons and forms */
.btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: .45rem .9rem; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .6; cursor: progress; }
input { font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); margin-top: .25rem; }
label { display: block; margin-bottom: .9rem; font-size: .9rem; color: var(--muted); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.login-card .btn { width: 100%; margin-top: .3rem; padding: .6rem; }
.login-card .alert { margin-bottom: 1rem; }

@media (max-width: 640px) {
  .topbar { gap: .5rem; }
  .brand { flex: 1; }
  .theme-toggle button { padding: .2rem .5rem; }
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .nav a, .nav .soon { white-space: nowrap; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 10px 12px; }
  .card-value { font-size: 1.4rem; }
  .card-value.small { font-size: 1.05rem; }
  .card-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  th, td { padding: .4rem .4rem; }
}
