/* wtanalytics: white cards with a soft shadow on a light grey page, violet
   accent, 10 px radii, uppercase small stat labels, tabular numbers.
   Dynamic values (bar widths, gauge fills) arrive as custom properties set
   with setStyle(); there are no style attributes anywhere (CSP). */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #1b2330;
  --muted: #5b6676;
  --faint: #9aa5b6;
  --border: #d5dae2;
  --grid: #e3e7ed;
  --row-line: #f0f2f5;
  --accent: #5b4fd6;
  --accent-text: #ffffff;
  --accent-soft: #ecebfb;
  --accent-strong: #4a3fc0;
  --selected: #f1f0fd;
  --neutral-soft: #eef1f4;
  --series: #5b4fd6;
  --series-err: #d4432f;
  --series-compare: #9aa5b6;
  --ok: #1a7f37;
  --warn: #9a6700;
  --warn-dot: #d29a00;
  --bad: #c62828;
  --bar: #ecebfb;
  --bar-err: #fbe9e7;
  --bar-slow: #fdf3dc;
  --notice-bg: #fdf3dc;
  --notice-text: #7a5300;
  --danger-border: #f0c4c0;
  --focus: #4a3fc0;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 4px 14px rgba(16, 24, 40, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #181d26;
    --surface-2: #141920;
    --text: #e6eaf0;
    --muted: #9aa5b6;
    --faint: #6b7686;
    --border: #2f3a4a;
    --grid: #2a3442;
    --row-line: #222a36;
    --accent: #9d93ff;
    --accent-text: #120d33;
    --accent-soft: rgba(157, 147, 255, 0.16);
    --accent-strong: #b9b2ff;
    --selected: rgba(157, 147, 255, 0.12);
    --neutral-soft: #242c38;
    --series: #9d93ff;
    --series-err: #ff6b57;
    --series-compare: #6b7686;
    --ok: #4ac26b;
    --warn: #e3b341;
    --warn-dot: #e3b341;
    --bad: #ff7b72;
    --bar: rgba(157, 147, 255, 0.16);
    --bar-err: rgba(255, 123, 114, 0.16);
    --bar-slow: rgba(227, 179, 65, 0.16);
    --notice-bg: rgba(227, 179, 65, 0.14);
    --notice-text: #f0c96a;
    --danger-border: rgba(255, 123, 114, 0.45);
    --focus: #b9b2ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-pop: 0 6px 18px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { font-family: var(--font); font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; min-width: 320px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 30; }
.skip:focus { left: 0; }
.spacer { flex: 1 1 auto; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------ page layout */
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.footer { text-align: center; padding: 1.5rem 1rem; font-size: 0.85rem; color: var(--muted); }
.page-title { font-size: 1.15rem; margin: 0.25rem 0 1rem; }
main.narrow { max-width: 46rem; }

/* header (shell.js) */
.app-header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; max-width: 1200px; margin: 0 auto; padding: 0.9rem 1rem 0.6rem; }
.logo { display: inline-flex; line-height: 0; border-radius: 0.5rem; }
.logo img { width: 2rem; height: 2rem; }
.crumb { color: var(--muted); }
.crumb a { color: inherit; }
.crumb a:hover { color: var(--text); }
.back-link { color: var(--muted); text-decoration: none; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.back-link:hover { color: var(--text); border-color: var(--accent); }
.control { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.6rem; max-width: 16rem; }
.site-picker, .range-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.range-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.range-custom label { font-size: 0.85rem; color: var(--muted); }
.range-custom .form-error { flex-basis: 100%; }
.live-rate { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-rate:hover { color: var(--text); }
.live-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--ok); margin-right: 0.4rem; vertical-align: 1px; }
.live-value { color: var(--text); font-weight: 600; }

/* avatar menu */
.menu-wrap { position: relative; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; padding: 0; border: 0; background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 600; display: grid; place-items: center; letter-spacing: 0.02em; }
.avatar:hover:not(:disabled) { border: 0; filter: brightness(1.08); }
.menu { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 20; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-pop); border: 1px solid var(--grid); padding: 0.35rem; width: max-content; min-width: 12rem; max-width: min(18rem, calc(100vw - 2rem)); }
.menu-id { display: flex; flex-direction: column; padding: 0.4rem 0.6rem; overflow-wrap: anywhere; }
.menu-id .muted { font-size: 0.85rem; }
.menu-sep { border: 0; border-top: 1px solid var(--grid); margin: 0.3rem 0; }
.menu-item { display: block; width: 100%; text-align: left; padding: 0.4rem 0.6rem; border-radius: 5px; color: var(--text); text-decoration: none; background: none; border: 0; font-size: 0.95rem; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--neutral-soft); border: 0; }
.menu-item.danger { color: var(--bad); }

/* dashboard tabs */
.page-tabs { display: flex; gap: 0.25rem; max-width: 1200px; margin: 0 auto; padding: 0 1rem; overflow-x: auto; scrollbar-width: none; box-shadow: inset 0 -1px 0 var(--border); }
/* Chevron on the edge where tabs run off (fade-start / fade-end set by shell.js): sticky flex items over a fade of the page background. */
.page-tabs::before, .page-tabs::after { display: none; position: sticky; z-index: 1; flex: none; align-self: stretch; width: 2.75rem; align-items: center; color: var(--muted); font-size: 1.4rem; pointer-events: none; }
.page-tabs::before { content: '\2039'; left: 0; margin-right: calc(-2.75rem - 0.25rem); justify-content: flex-start; padding-left: 0.2rem; background: linear-gradient(to right, var(--bg) 45%, transparent); }
.page-tabs::after { content: '\203a'; right: 0; margin-left: calc(-2.75rem - 0.25rem); justify-content: flex-end; padding-right: 0.2rem; background: linear-gradient(to left, var(--bg) 45%, transparent); }
.page-tabs.fade-start::before, .page-tabs.fade-end::after { display: flex; }
.page-tab { padding: 0.55rem 0.8rem; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.page-tab:hover { color: var(--text); }
.page-tab[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

/* admin layout: sidebar beside main */
body.layout-admin { display: grid; grid-template-columns: minmax(1rem, 1fr) 10rem minmax(0, calc(1200px - 12rem)) minmax(1rem, 1fr); grid-template-areas: "h h h h" ". nav main ." "f f f f"; column-gap: 1rem; align-content: start; }
body.layout-admin > .app-header { grid-area: h; width: 100%; }
body.layout-admin > .admin-nav { grid-area: nav; }
body.layout-admin > main { grid-area: main; max-width: none; margin: 0; padding: 0.5rem 0 1rem; min-width: 0; }
body.layout-admin > .footer { grid-area: f; }
.admin-nav { display: flex; flex-direction: column; gap: 0.15rem; padding-top: 0.5rem; }
.admin-nav-title { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 600; margin: 0.4rem 0.6rem 0.3rem; }
.admin-nav a { display: block; padding: 0.45rem 0.65rem; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; }
.admin-nav a:hover { color: var(--text); background: var(--neutral-soft); }
.admin-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------- surfaces */
.card, .panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; min-width: 0; }
.card-head, .panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.card-head h2, .card > h2 { font-size: 0.95rem; }
.card > h2 { margin-bottom: 0.75rem; }
.card-head .hint, .card-head .muted { font-size: 0.8rem; }
.card.danger { border: 1px solid var(--danger-border); }
.card.danger h2 { color: var(--bad); }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card-grid > .card { margin-bottom: 0; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin: 0.25rem 0 1rem; overflow-wrap: anywhere; }
.link-list { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.link-list li { margin: 0.2rem 0; }
.more { display: inline-block; margin-top: 0.5rem; font-size: 0.85rem; text-decoration: none; }
.more:hover { text-decoration: underline; }

/* notices and banners */
.banner { padding: 0.6rem 0.85rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); margin: 0.5rem 0 1rem; }
.banner.error { border-color: var(--bad); color: var(--bad); }
.notice, .banner.warn { background: var(--notice-bg); color: var(--notice-text); border: 0; border-radius: 8px; padding: 0.6rem 0.85rem; margin: 0 0 1rem; }

/* ---------------------------------------------------------------- controls */
button, input, select { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.8rem; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { border-color: var(--danger-border); color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.small { padding: 0.15rem 0.5rem; font-size: 0.85rem; }
a.button { display: inline-block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.8rem; color: inherit; text-decoration: none; text-align: center; }
a.button:hover { border-color: var(--accent); }
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
input, select { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; max-width: 100%; }
input:disabled, input[readonly] { color: var(--muted); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.session-row { justify-content: space-between; margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 0.4rem; max-width: 28rem; }
.stack label { font-weight: 600; margin-top: 0.4rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.actions.end { justify-content: flex-end; }
.form-error, .field-error { color: var(--bad); margin: 0.25rem 0 0; font-size: 0.9rem; }
.form-status { color: var(--ok); margin: 0.75rem 0 0; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* label / field pairs */
.form-grid { display: grid; grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr); gap: 0.6rem 1rem; align-items: center; }
.form-grid > label, .form-grid > .label { color: var(--muted); }
.form-grid input, .form-grid select { width: 100%; max-width: 26rem; }
.form-grid .field-error, .form-grid .hint { grid-column: 2; margin-top: -0.3rem; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem 1.5rem; width: min(24rem, 100%); margin: 0; border-top: 3px solid var(--accent); }
.login-brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.25rem; margin-bottom: 1.25rem; }
.login-mark { width: 2rem; height: 2rem; }
.login-box .stack { max-width: none; }
.login-box h2 { font-size: 1rem; margin-bottom: 0.25rem; }
.login-box .actions { margin-top: 0.75rem; }
.login-box button.primary, .login-box a.button.primary { width: 100%; box-sizing: border-box; }
.login-box input { width: 100%; }

/* ------------------------------------------------------------- status bits */
.pill { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); font-size: 0.85rem; }
.pill[data-state="live"] { color: var(--ok); border-color: var(--ok); }
.pill[data-state="reconnecting"], .pill[data-state="connecting"] { color: var(--warn); border-color: var(--warn); }
.pill[data-state="closed"] { color: var(--bad); border-color: var(--bad); }
.pill[data-state="live"]::before { content: "\25CF\00a0"; }

/* badges: accent by default; .neutral, .warn, .ok, .stale/.bad */
.badge { display: inline-block; font-size: 0.72rem; line-height: 1.5; padding: 0 0.5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); margin-left: 0.4rem; font-family: var(--font); font-weight: 500; vertical-align: 1px; white-space: nowrap; }
.badge:first-child { margin-left: 0; }
.badge.neutral { background: var(--neutral-soft); color: var(--muted); }
.badge.warn { background: var(--bar-slow); color: var(--warn); }
.badge.ok { background: transparent; box-shadow: inset 0 0 0 1px var(--ok); color: var(--ok); }
.badge.stale, .badge.bad { background: var(--bar-err); color: var(--bad); }

/* status dots: green healthy, amber warning, red stale */
.status-dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.45rem; vertical-align: 1px; background: var(--faint); }
.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--warn-dot); }
.status-dot.bad { background: var(--bad); }
.status-dot.gone { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.gone-note { font-size: 0.85rem; margin: 0 0 0.75rem; }

/* gauges: setStyle(fill, '--fill', '42%') */
.gauge { height: 0.4rem; background: var(--neutral-soft); border-radius: 3px; margin-top: 0.4rem; overflow: hidden; }
.gauge-fill { display: block; height: 100%; width: var(--fill, 0%); max-width: 100%; border-radius: 3px; background: var(--accent); }
.gauge-fill.warn { background: var(--warn-dot); }
.gauge-fill.bad { background: var(--bad); }

/* system page: one-line facts and pool gauges */
.fact { margin: 0 0 0.35rem; }
.fact b.num, .pool-head .num { font-variant-numeric: tabular-nums; }
.fact-list { margin: 0.25rem 0 0.5rem; padding-left: 1.1rem; }
.fact-list li { margin: 0.15rem 0; overflow-wrap: anywhere; }
.pool + .pool { margin-top: 0.75rem; }
.pool-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; }
.pool .gauge { display: block; }
.pool .hint { margin-top: 0.25rem; font-size: 0.8rem; }

/* --------------------------------------------------------------- stat strip */
/* <div class="stat-strip"> of .stat (a <button aria-pressed> when it selects
   the chart metric). Delta colours say good/bad, not up/down. */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.25rem 0; margin: 0 0 0.75rem; }
.stat { display: block; text-align: left; padding: 0.5rem 0.9rem; border: 0; border-left: 1px solid var(--grid); border-radius: 0; background: none; color: var(--text); min-width: 0; }
.stat:first-child { border-left-color: transparent; }
button.stat { cursor: pointer; border-radius: 8px; }
button.stat:hover:not(:disabled) { border-color: var(--grid); background: var(--neutral-soft); }
button.stat:first-child:hover:not(:disabled) { border-left-color: transparent; }
.stat[aria-pressed="true"], .stat.selected { background: var(--selected); color: var(--text); border-left-color: transparent; border-radius: 8px; }
button.stat[aria-pressed="true"]:hover:not(:disabled) { background: var(--selected); border-left-color: transparent; }
.stat[aria-pressed="true"] + .stat, .stat.selected + .stat { border-left-color: transparent; }
.stat-label, .stat-value, .stat-sub { display: block; }
.stat-label { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.45rem; font-weight: 600; margin-top: 0.2rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value small { font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.stat-value.bad { color: var(--bad); }
.stat-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta { font-size: 0.78rem; font-weight: 500; margin-left: 0.35rem; white-space: nowrap; color: var(--muted); }
.delta.good { color: var(--ok); }
.delta.bad { color: var(--bad); }
.delta[data-dir="up"]::before { content: "\2197\00a0"; }
.delta[data-dir="down"]::before { content: "\2198\00a0"; }

/* -------------------------------------------------------- top-N with bars */
/* <ol class="top-list [err|slow]"><li class="top-row"> label + value; the bar
   width comes from setStyle(row, '--share', '62%'). */
.top-list { list-style: none; margin: 0; padding: 0; }
.top-row { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.3rem 0.5rem; margin: 0.15rem 0; font-size: 0.88rem; border-radius: 4px; isolation: isolate; }
.top-row::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--share, 0%); max-width: 100%; background: var(--bar); border-radius: 4px; z-index: -1; }
.top-list.err .top-row::before { background: var(--bar-err); }
.top-list.slow .top-row::before { background: var(--bar-slow); }
.top-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
a.top-label:hover { text-decoration: underline; }
.top-label.mono { font-family: var(--mono); font-size: 0.8rem; }
.top-value { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.top-empty { color: var(--muted); font-size: 0.88rem; padding: 0.3rem 0.5rem; }
.top-list + .hint, .top-empty + .hint { margin-top: 0.5rem; font-size: 0.8rem; }

/* ------------------------------------------------------------------ charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .axis-line { stroke: var(--border); stroke-width: 1; }
.chart .area { fill: var(--series); fill-opacity: 0.1; stroke: none; }
.chart .line, .chart .line-err, .chart .line-compare { fill: none; stroke: var(--series); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-err { stroke: var(--series-err); stroke-width: 1.5; }
.chart .line-compare { stroke: var(--series-compare); stroke-width: 1.5; stroke-dasharray: 5 4; stroke-linecap: butt; }
.chart .rule { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Attack bands sit under the series; the series let clicks through to them. */
.chart .band { fill: var(--series-err); fill-opacity: 0.13; }
.chart .band.clickable { cursor: pointer; }
.chart .band.clickable:hover { fill-opacity: 0.24; }
.chart .area, .chart .line, .chart .line-err, .chart .line-compare, .chart .rule, .chart .dot, .chart .grid-line { pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.swatch { display: inline-block; width: 1rem; height: 0; border-top: 2px solid var(--series); margin-right: 0.35rem; vertical-align: 3px; }
.swatch.err { border-top-color: var(--series-err); }
.swatch.compare { border-top: 2px dashed var(--series-compare); }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--grid); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.85rem; box-shadow: var(--shadow-pop); white-space: nowrap; transform: translate(-50%, -100%); }
.tooltip div { font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted); text-align: center; padding: 5rem 1rem; margin: 0; }
.chart + .hint { margin-top: 0.6rem; }

/* --------------------------------------------------------------- all sites */
/* sites-page.js: compact cards, four per row at 1200 px; the left edge is
   the site's status (data-status ok | warn | bad | none). */
.sites-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.75rem; margin: 0.25rem 0 1rem; }
.sites-head .page-title { margin: 0; }
.sites-head > .muted, .sites-sort label { font-size: 0.85rem; }
.sites-sort { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.site-card { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border-left: 4px solid var(--faint); padding: 0.6rem 0.9rem 0.6rem; }
.site-card[data-status="ok"] { border-left-color: var(--ok); }
.site-card[data-status="warn"] { border-left-color: var(--warn-dot); }
.site-card[data-status="bad"] { border-left-color: var(--bad); }
.site-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; min-width: 0; }
.site-card-head h2 { font-size: 0.98rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-name { color: var(--text); text-decoration: none; }
.site-name:hover { text-decoration: underline; }
.site-note { font-weight: 400; font-size: 0.8rem; }
.site-live { flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.site-live .live-dot { width: 0.45rem; height: 0.45rem; margin-right: 0.3rem; }
.site-live[data-idle="true"] .live-dot { background: var(--faint); }
.spark { display: block; width: 100%; height: 1.75rem; overflow: visible; }
.spark-line { fill: none; stroke: var(--series); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--series); fill-opacity: 0.12; stroke: none; }
.site-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 0.75rem; margin: 0; }
.site-stat { min-width: 0; }
.site-stat dt { font-size: 0.65rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.site-stat dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-stat-value { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.site-stat .delta { margin-left: 0.3rem; font-size: 0.72rem; }
.site-foot { margin-top: auto; font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.site-foot:hover { color: var(--text); }
.site-unavailable { flex: 1 1 auto; color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0; }
.sites-legend .status-dot { margin-left: 0.25rem; }

/* ------------------------------------------------------------------ tables */
.table-wrap { position: relative; overflow-x: auto; margin-bottom: 1rem; } /* relative: keeps .sr-only cells inside the scroller */
.card .table-wrap:last-child { margin-bottom: 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--row-line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; border-bottom-color: var(--grid); }
th[aria-sort] { cursor: pointer; }
.sort-btn { background: none; border: 0; border-radius: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.sort-btn:hover:not(:disabled) { border: 0; color: var(--text); }
th[aria-sort="ascending"]::after { content: "\00a0\25B4"; }
th[aria-sort="descending"]::after { content: "\00a0\25BE"; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
td.key { overflow-wrap: anywhere; min-width: 8rem; max-width: 32rem; font-family: var(--mono); font-size: 0.85rem; }
td.actions-cell { display: table-cell; }
td.actions-cell button { margin: 0 0.25rem 0.25rem 0; }
tr.link-row { cursor: pointer; }
.row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
td.chevron { color: var(--faint); text-align: right; width: 1.5rem; }
tr.link-row:hover td { background: var(--surface-2); }
/* Clients page: the instance name is the button that opens its detail panel. */
.instance-btn { background: none; border: 0; border-radius: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.instance-btn:hover:not(:disabled) { border: 0; text-decoration: underline; }
.instance-btn[aria-expanded="true"] { font-weight: 600; }
.client-panel { border-top: 1px solid var(--grid); margin-top: 1rem; padding-top: 0.75rem; }
.client-panel h3 { font-size: 0.85rem; margin: 0.75rem 0 0.25rem; }
/* Attacks: the notice under the Overview chart and the detail panel's lists. */
.attack-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; margin-top: 0.6rem; font-size: 0.85rem; }
.attack-notice .badge { margin-left: 0; }
.attack-notice .more { margin: 0 0 0 auto; }
.attack-btn { font: inherit; font-size: 0.8rem; font-variant-numeric: tabular-nums; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--danger-border); background: var(--surface); color: var(--text); cursor: pointer; }
.attack-btn[aria-expanded="true"] { background: var(--bar-err); border-color: var(--bad); }
.attack-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 1.5rem; }
.attack-country, .top-label.other { color: var(--muted); font-family: var(--font); }
td.instance { white-space: nowrap; overflow-wrap: normal; }
td.time { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 0.85rem; }
.share-cell { display: inline-flex; flex-direction: column; align-items: stretch; min-width: 4.5rem; text-align: right; }
.share-cell .gauge { height: 0.3rem; margin-top: 0.2rem; }
td .badge { vertical-align: 1px; }

/* ----------------------------------------------- dialogs and one-time secrets */
dialog { background: var(--surface); color: var(--text); border: 0; border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 1.25rem; width: min(30rem, calc(100% - 2rem)); }
dialog > h2 { margin-bottom: 1rem; }
dialog .form-grid .secret-row { margin: 0; flex-wrap: nowrap; }
dialog .form-grid .secret-row input { flex: 1 1 auto; min-width: 0; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.secret-box { border: 2px solid var(--warn); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 1rem 0; background: var(--surface); }
.secret-box .warning { color: var(--warn); font-weight: 600; }
.secret-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.secret-row code { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 0.25rem 0.5rem; border-radius: 4px; overflow-wrap: anywhere; user-select: all; }
.secret-box h4 { margin: 1rem 0 0.25rem; }
.integration-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.75rem; margin: 0.5rem 0; }
.integration-block summary { cursor: pointer; font-weight: 600; }
.integration-block pre { font-family: var(--mono); font-size: 0.85rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem; margin: 0.4rem 0; max-height: 24rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.check-list { display: grid; gap: 0.3rem; margin: 0.5rem 0; max-height: 14rem; overflow-y: auto; }
.check-list label { display: flex; gap: 0.5rem; align-items: center; font-weight: normal; margin: 0; }
.site-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.4rem 1rem; }
.site-form-grid label { display: block; font-weight: 600; margin-top: 0.4rem; }
.site-form-grid input { width: 100%; }


/* ------------------------------------------------------------------ mobile */
@media (max-width: 720px) {
  /* logo and avatar share the first row; pickers wrap below */
  .app-header > .logo { order: -2; flex: 1 0 calc(100% - 4rem); }
  .app-header > .menu-wrap { order: -1; }
  .app-header > .spacer { display: none; }
  body.layout-admin { grid-template-columns: minmax(0, 1fr); grid-template-areas: "h" "nav" "main" "f"; column-gap: 0; }
  body.layout-admin > main { padding: 0.5rem 1rem 1rem; }
  .admin-nav { flex-direction: row; gap: 0.25rem; overflow-x: auto; padding: 0 1rem; box-shadow: inset 0 -1px 0 var(--border); }
  .admin-nav-title { display: none; }
  .admin-nav a { white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-strip { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
}

@media (max-width: 480px) {
  main { padding: 0.75rem; }
  .app-header { padding: 0.75rem 0.75rem 0.5rem; }
  .page-tabs { padding: 0 0.75rem; }
  .card, .panel { padding: 0.85rem; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { border-left-color: transparent; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .form-grid .field-error, .form-grid .hint { grid-column: 1; margin-top: 0; }
  .form-grid > label { margin-top: 0.5rem; }
  .control { max-width: 12rem; }
}

@media (prefers-reduced-motion: no-preference) {
  button, .page-tab, .admin-nav a { transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
}
.range-step { display: flex; align-items: center; gap: 0.25rem; }
.range-step button { min-width: 2rem; padding: 0.25rem 0.5rem; }
.range-step button:disabled { opacity: 0.4; cursor: default; }
.range-label { min-width: 6.5rem; text-align: center; font-size: 0.9rem; }
