/* SpamGuard admin panel. Light by default, dark when the OS asks for it. */
:root {
    color-scheme: light;
    --page: #f4f7fb;
    --surface: #ffffff;
    --chart-surface: #fcfcfb;
    --ink: #0e1a2f;
    --ink-2: #52514e;
    --muted: #6b7486;
    --line: #e3e9f2;
    --grid: #e1e0d9;
    --baseline: #c3c2b7;
    --brand: #1f6feb;
    --brand-soft: #e8f0fe;
    --series-1: #2a78d6;
    --series-1-hover: #5598e7;
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --ok-bg: #e6f6ec;
    --ok-ink: #11602f;
    --error-bg: #fdecec;
    --error-ink: #9b1c1c;
    --radius: 14px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #161616;
        --chart-surface: #1a1a19;
        --ink: #ffffff;
        --ink-2: #c3c2b7;
        --muted: #898781;
        --line: #2c2c2a;
        --grid: #2c2c2a;
        --baseline: #383835;
        --brand: #5598e7;
        --brand-soft: #1c2b44;
        --series-1: #3987e5;
        --series-1-hover: #6da7ec;
        --ok-bg: #11301d;
        --ok-ink: #8fe0a8;
        --error-bg: #3a1414;
        --error-ink: #f3a3a3;
    }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; max-width: 340px; color: var(--ink-2); }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 22px; font-weight: 700; }
.brand span { color: var(--brand); }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--ink-2); padding: 8px 12px; border-radius: 10px; }
.sidebar nav a.active, .sidebar nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.who { margin-top: auto; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.content { padding: 28px 32px 48px; max-width: 1400px; width: 100%; }
.page-head { margin-bottom: 18px; }

.card, .chart-card, .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card { margin-bottom: 18px; overflow-x: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; margin-bottom: 18px; }
.notice { border-color: var(--warning); }

/* KPI row of stat tiles */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { display: flex; flex-direction: column; gap: 2px; }
.tile-label { color: var(--ink-2); font-size: 13px; }
.tile-value { font-size: 28px; font-weight: 600; }
.tile-caption { color: var(--muted); font-size: 12px; }

/* Status: colour dot + text label, never colour alone */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-good .status-dot { background: var(--good); }
.status-warning .status-dot { background: var(--warning); }
.status-serious .status-dot { background: var(--serious); }
.status-critical .status-dot { background: var(--critical); }
.risk { font-size: 12px; font-weight: 600; }
.risk-critical, .risk-high { color: var(--critical); }
.risk-medium { color: var(--serious); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
dl.facts { display: grid; grid-template-columns: minmax(180px, 40%) 1fr; gap: 6px 14px; margin: 0 0 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

/* Forms */
input, select, button { font: inherit; color: inherit; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], select {
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
input.narrow { width: 70px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
label.radio { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
legend { font-size: 13px; color: var(--ink-2); padding: 0 4px; }
button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--brand); border-color: var(--brand); color: #ffffff; font-weight: 600; }
button.link { border: none; background: none; padding: 0; color: var(--brand); }
button.link.danger { color: var(--critical); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.toolbar .grow { flex: 1 1 220px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; }
td.actions { display: flex; gap: 12px; }

/* Filters: one row above the content they scope */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.filters a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); background: var(--surface); }
.filters a.active { background: var(--brand); border-color: var(--brand); color: #ffffff; }
.pager { display: flex; justify-content: space-between; margin-top: 12px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--error-bg); color: var(--error-ink); }

/* Charts: thin columns, hairline grid, recessive axes */
.chart-card { background: var(--chart-surface); margin: 0; }
.chart-card figcaption { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-title { font-weight: 600; }
.chart-latest { color: var(--ink-2); font-size: 13px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--baseline); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11px; }
svg.chart .bar { fill: var(--series-1); }
svg.chart .hit { fill: transparent; }
svg.chart .mark { outline: none; cursor: default; }
svg.chart .mark:hover .bar, svg.chart .mark:focus .bar { fill: var(--series-1-hover); }
svg.chart .mark:focus .hit { stroke: var(--brand); stroke-width: 1; }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--brand); }
.chart-table table { max-width: 320px; }

.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }

/* Login */
body.public { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .content { padding: 18px 16px 40px; }
    .grid-2 { grid-template-columns: 1fr; }
}
