:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --muted: #64748b;
  --brand: #0b4f8a;
  --verified-bg: #dcfce7;
  --verified-fg: #166534;
  --computed-bg: #e0e7ff;
  --computed-fg: #3730a3;
  --mismatch-bg: #dc2626;
  --mismatch-fg: #ffffff;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 1.5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0; }
section { margin-bottom: 2rem; }
code { background: #edf2f7; padding: 0 4px; border-radius: 4px; }

.container { max-width: 1200px; margin: 0 auto; padding-inline: 16px; }

.topbar { background: var(--brand); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand span { font-weight: 400; opacity: .8; }
.nav { display: flex; gap: .25rem; }
.nav a { color: #fff; padding: .4rem .75rem; border-radius: 6px; opacity: .85; }
.nav a.active, .nav a:hover { background: rgba(255, 255, 255, .15); opacity: 1; text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--brand); }
.card-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.card-value { font-size: 1.9rem; font-weight: 700; margin-top: 4px; }
.card-value-sm { font-size: 1.05rem; }
.card-sub { color: var(--muted); font-size: .85rem; }
.card-alert { border: 2px solid var(--mismatch-bg); background: #fef2f2; }
.card-alert .card-value { color: var(--mismatch-bg); }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .75rem; gap: 1rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.row-mismatch { background: #fef2f2; }
.row-mismatch td:first-child { box-shadow: inset 3px 0 0 var(--mismatch-bg); }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); font-weight: 400; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; }
.breadcrumb { color: var(--muted); margin: 1rem 0 0; }
.event-type { font-weight: 600; font-size: .85rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.badge-verified { background: var(--verified-bg); color: var(--verified-fg); }
.badge-computed { background: var(--computed-bg); color: var(--computed-fg); }
.badge-mismatch { background: var(--mismatch-bg); color: var(--mismatch-fg); }
.badge-generated { background: #e0f2fe; color: #075985; }
.badge-used { background: #f1f5f9; color: #334155; }
.badge-anomaly { background: var(--warn-bg); color: var(--warn-fg); margin-left: 4px; cursor: help; }
.badge-none { background: #f1f5f9; color: var(--muted); }

.notice { background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius); padding: .6rem 1rem; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.filters select { min-width: 160px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font: inherit; color: var(--text); }
.filter-actions { display: flex; gap: 12px; align-items: center; }
.filters button { padding: 7px 16px; border: 0; border-radius: 6px; background: var(--brand); color: #fff; font: inherit; cursor: pointer; }

.footer { color: var(--muted); font-size: .8rem; padding-block: 2rem; }

@media (max-width: 600px) {
  h1 { font-size: 1.25rem; }
  .card-value { font-size: 1.5rem; }
  .filters label, .filters select { width: 100%; }
}

.error-text { white-space: pre-line; color: #991b1b; font-size: .8rem; margin-top: 4px; max-width: 48ch; }
.device-text { font-size: .75rem; color: var(--muted); margin-top: 2px; }
