:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a1d21;
  --muted: #61686f;
  --line: #dfe3e8;
  --accent: #2f6fdb;
  --pass: #2e9e6b;
  --fail: #d1493f;
  --warn: #d98324;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --panel: #1c2024;
    --ink: #e8eaed;
    --muted: #98a1ab;
    --line: #2c3238;
    --accent: #6ea3f5;
    --pass: #4cbf8b;
    --fail: #e8695e;
    --warn: #e9a54a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

header .spacer { flex: 1; }

label.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

select, input[type="date"], button {
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel > h2 {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel > h2 .note {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.panel-body { padding: 16px; overflow-x: auto; }

/* Long tables scroll inside the panel rather than stretching the page.
   The header row stays put so the columns remain readable while scrolling. */
.panel-body.scroll { max-height: 520px; overflow-y: auto; padding-top: 0; }
.panel-body.scroll thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  box-shadow: inset 0 -1px 0 var(--line);
  padding-top: 12px;
}

/* Summary tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile .v.pass { color: var(--pass); }
.tile .v.fail { color: var(--fail); }

table { border-collapse: collapse; width: 100%; font-size: 13px; }

th, td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}

tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.bar {
  display: inline-block;
  height: 7px;
  border-radius: 3px;
  background: var(--pass);
  vertical-align: middle;
  min-width: 1px;
}
.bar.fail { background: var(--fail); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
}
.tag.pass { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 40%, transparent); }
.tag.fail { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 40%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

.muted { color: var(--muted); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

svg.chart { display: block; width: 100%; height: auto; }
svg.chart text { fill: var(--muted); font-size: 10px; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 0 16px 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }

/* Findings queue */
.panel > h2 .spacer { flex: 1; }
label.field.inline { font-weight: 400; text-transform: none; letter-spacing: 0; }

.finding {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.finding:last-child { border-bottom: none; }
.finding.decided { opacity: .55; }

.finding .sev {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
  text-align: center;
  justify-self: start;
}
.sev.critical { color: var(--fail);  border-color: color-mix(in srgb, var(--fail) 45%, transparent); }
.sev.high     { color: var(--fail);  border-color: color-mix(in srgb, var(--fail) 30%, transparent); }
.sev.medium   { color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.sev.low      { color: var(--muted); border-color: var(--line); }

.finding .title { font-weight: 600; }
.finding .meta  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.finding .why   { font-size: 13px; margin-top: 6px; }
.finding .fix   { font-size: 13px; margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--accent); }
.finding .actions { display: flex; gap: 6px; align-items: center; }
.finding .actions select { font-size: 12px; padding: 3px 6px; }
.finding .decision-note { font-size: 12px; color: var(--muted); white-space: nowrap; }

.ready   { color: var(--pass); font-weight: 600; }
.notready{ color: var(--warn); font-weight: 600; }

/* Class chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; background: var(--panel);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.chip.compliant .dot { background: var(--pass); }
.chip.forwarded .dot { background: #8aa4c8; }
.chip.suspect   .dot { background: var(--fail); }
.chip.blocked   .dot { background: var(--warn); }

/* Mailbox pull */
#pull-status { font-size: 12px; max-width: 44ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pull-status.busy { color: var(--accent); }
#pull-status.bad  { color: var(--fail); }
#pull-status.good { color: var(--pass); }
#pull:disabled { opacity: .55; cursor: default; }
