/* Edge Guard console — one stylesheet, no build step.
 *
 * Structure: design tokens, base, app shell, page header, components
 * (card, stat, table, badge, button, segmented control, form, alert, tabs,
 * disclosure, empty state, toolbar), auth pages, then responsive rules. Every
 * colour, radius, shadow, and space comes from a token, so the look changes
 * in one place. The Content Security Policy forbids inline styles: everything
 * visual lives here and is applied through classes.
 */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;

  /* Surfaces, darkest to lightest */
  --bg: #0a0e17;
  --bg-elevated: #0e1420;
  --surface: #121a28;
  --surface-2: #172133;
  --surface-3: #1d293e;
  --border: #233047;
  --border-strong: #2e3d57;

  /* Text */
  --text: #e7ecf4;
  --text-muted: #8d9bb3;
  --text-subtle: #66748c;

  /* Accent and status */
  --primary: #6e6bff;
  --primary-hover: #8380ff;
  --primary-soft: rgba(110, 107, 255, 0.14);
  --success: #2fca83;
  --success-soft: rgba(47, 202, 131, 0.13);
  --warning: #f5b544;
  --warning-soft: rgba(245, 181, 68, 0.14);
  --danger: #f06272;
  --danger-soft: rgba(240, 98, 114, 0.14);
  --info: #4cb5f5;
  --info-soft: rgba(76, 181, 245, 0.14);

  /* Shape and depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.35), 0 20px 48px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(110, 107, 255, 0.35);

  /* Space scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar-width: 236px;
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

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

code, .mono {
  font-family: var(--mono);
  font-size: 0.86em;
}
code {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

:focus-visible { outline: none; box-shadow: var(--ring); }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.inline-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-lg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------- shell */
/* The shell is exactly one screen tall: banners on top, then the sidebar and
   the main column side by side. Only the main column scrolls, so the banners,
   the sidebar, and the status bar stay in place. */
.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.banners { flex: none; }
.shell > .auth { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.app {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s-5) var(--s-3);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-3) var(--s-6);
  color: var(--text);
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #7c79ff, #4d48d9);
  box-shadow: 0 4px 14px rgba(110, 107, 255, 0.35);
  color: #fff;
}
.brand-mark .icon { width: 18px; height: 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: var(--s-4) var(--s-3) var(--s-2);
  color: var(--text-subtle);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px var(--s-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav a[aria-current="page"] .icon { color: var(--primary-hover); }

.sidebar-footer {
  margin-top: auto;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
}
.who { flex: 1; min-width: 0; line-height: 1.25; }
.who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 0.78rem; color: var(--text-subtle); }

.main {
  /* The positioning context for everything inside, so absolutely positioned
     content (such as the visually hidden table labels) stays within the
     scrolling column instead of lengthening the document; a longer document
     would scroll the banners away on every anchor jump. */
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
@media (prefers-reduced-motion: no-preference) {
  .main { scroll-behavior: smooth; }
}

/* ------------------------------------------------------------- status bar */
.status-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 6px var(--s-8);
  background: rgba(10, 14, 23, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.status-bar::-webkit-scrollbar { display: none; }
/* The states and the numbers are two groups. On wide screens the bar
   wraps between them rather than clipping the last numbers; on narrow ones
   it scrolls. */
.status-group { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.status-metrics { margin-left: auto; }
@media (min-width: 901px) {
  .status-bar { flex-wrap: wrap; row-gap: 6px; }
}
.status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
}
.status-item::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
}
.status-item:hover { text-decoration: none; border-color: currentColor; }
.status-item.is-success { color: var(--success); }
.status-item.is-warning { color: var(--warning); }
.status-item.is-danger { color: var(--danger); }
.status-sep { width: 1px; height: 18px; margin: 0 var(--s-2); background: var(--border-strong); flex: none; }
.status-metric {
  padding: 3px var(--s-2);
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.status-metric > span { margin-right: 4px; color: var(--text-subtle); font-weight: 500; }
a.status-metric:hover { text-decoration: none; background: var(--surface-2); border-radius: var(--radius-sm); }
.status-metric.is-danger { color: var(--danger); }
.status-metric.is-warning { color: var(--warning); }
.status-version { margin-left: auto; padding-left: var(--s-4); color: var(--text-subtle); font-family: var(--mono); font-size: 0.75rem; }
.content {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-8) var(--s-10);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 10px var(--s-6);
  background: var(--danger-soft);
  border-bottom: 1px solid rgba(240, 98, 114, 0.35);
  color: #ffc9cf;
  font-weight: 500;
  text-align: center;
}
.banner.warn {
  background: var(--warning-soft);
  border-bottom-color: rgba(245, 181, 68, 0.35);
  color: #ffe2a8;
}
.banner a { color: inherit; text-decoration: underline; }
.banner > span { max-width: 90ch; }
.banner code { background: rgba(0, 0, 0, 0.25); border-color: transparent; color: inherit; }

/* ------------------------------------------------------------- page header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}
.page-header p { margin: var(--s-1) 0 0; color: var(--text-muted); max-width: 64ch; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.stack { display: flex; flex-direction: column; gap: var(--s-6); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--s-6); }

/* -------------------------------------------------------------------- card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card-header > :first-child { flex: 1 1 320px; min-width: 0; }
.card-header > :not(:first-child) { flex: none; }
.card-header h2 { display: flex; align-items: center; gap: var(--s-2); }
.card-header p { margin: 2px 0 0; color: var(--text-muted); font-size: 0.86rem; }
.card-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.card-body { padding: var(--s-5); }
.card-footer {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.84rem;
}
.card.danger { border-color: rgba(240, 98, 114, 0.35); }
.card.danger .card-header { border-bottom-color: rgba(240, 98, 114, 0.25); }

/* -------------------------------------------------------------------- stat */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--s-4);
}
.stat {
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.stat-label { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }
.stat-label .icon { width: 14px; height: 14px; }
a.stat-link { display: block; color: inherit; transition: border-color 120ms ease, background 120ms ease; }
a.stat-link:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.stat-value {
  margin-top: var(--s-1);
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-hint { margin-top: 2px; color: var(--text-subtle); font-size: 0.78rem; }
.stat.is-danger .stat-value { color: var(--danger); }
.stat.is-warning .stat-value { color: var(--warning); }
.stat.is-success .stat-value { color: var(--success); }

/* ------------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; }
/* A list that can grow long keeps to a bounded height and scrolls inside,
   so the cards below it stay in view. */
.table-scroll {
  max-height: min(480px, 60vh);
  overflow-y: auto;
  /* A shadow at the bottom while more rows are below: the cover scrolls with
     the content and hides the shadow once the end is reached. */
  background:
    linear-gradient(rgba(18, 26, 40, 0), var(--surface) 70%) 0 100% / 100% 40px no-repeat local,
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.55), transparent) 0 100% / 100% 16px no-repeat scroll,
    var(--surface);
}
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }
/* Cards reached by an anchor clear the sticky status bar. */
.card[id] { scroll-margin-top: 64px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th {
  padding: 10px var(--s-5);
  background: var(--bg-elevated);
  color: var(--text-subtle);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 11px var(--s-5);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.table .actions > * { vertical-align: middle; }
.table .num { text-align: right; }
.table .wrap-anywhere { overflow-wrap: anywhere; }
a.plain-link:hover { text-decoration: none; filter: brightness(1.15); }
.table.kv th {
  width: 240px;
  padding-top: 10px;
  padding-bottom: 10px;
  background: none;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
}
.table.kv tr:last-child th { border-bottom: 0; }

.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.cell-stack small { color: var(--text-subtle); font-size: 0.78rem; }
.cell-stack > code { align-self: flex-start; }

/* ------------------------------------------------------------------- badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.plain::before { display: none; }
.badge-success { color: var(--success); background: var(--success-soft); border-color: rgba(47, 202, 131, 0.28); }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: rgba(245, 181, 68, 0.28); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(240, 98, 114, 0.28); }
.badge-info { color: var(--info); background: var(--info-soft); border-color: rgba(76, 181, 245, 0.28); }
.badge-primary { color: var(--primary-hover); background: var(--primary-soft); border-color: rgba(110, 107, 255, 0.3); }
.badge-neutral { color: var(--text-muted); background: var(--surface-3); border-color: var(--border-strong); }

/* ------------------------------------------------------------------ button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 10px rgba(110, 107, 255, 0.3); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: #24324b; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #f37988; }
.btn-danger-ghost { background: transparent; color: var(--text-muted); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 0.84rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-icon.btn-xs { width: 22px; height: 22px; vertical-align: middle; }
.btn-icon.btn-xs .icon { width: 13px; height: 13px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; align-items: center; gap: var(--s-1); }

/* Segmented control: one click switches a rule's mode, no script needed. */
.segmented {
  display: inline-flex;
  padding: 3px;
  margin: 0;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.segmented button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-subtle);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.segmented button:hover { color: var(--text); background: var(--surface-2); }
.segmented button[aria-pressed="true"].mode-enforce { background: var(--danger-soft); color: var(--danger); }
.segmented button[aria-pressed="true"].mode-monitor { background: var(--warning-soft); color: var(--warning); }
.segmented button[aria-pressed="true"].mode-off { background: var(--surface-3); color: var(--text-muted); }

/* -------------------------------------------------------------------- form */
form { margin: 0; }
.inline-form { display: inline-flex; align-items: center; gap: var(--s-2); margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--s-4);
  align-items: start;
}
.form-grid .span-2 { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 0.82rem; font-weight: 550; color: var(--text-muted); }
.field small { color: var(--text-subtle); font-size: 0.76rem; }

.input, .select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover { border-color: #3a4c6b; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input-sm, .select-sm { height: 32px; font-size: 0.86rem; }
.table .input-sm { width: 13rem; }
.input-xs { width: 5.5rem; }
a.chip:hover { text-decoration: none; border-color: var(--primary); color: var(--primary-hover); }
.input-code {
  height: 48px;
  font-family: var(--mono);
  font-size: 1.35rem;
  letter-spacing: 0.3em;
  text-align: center;
}
input[type="file"].input { height: auto; padding: 8px; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

/* ------------------------------------------------------------------- alert */
.alert {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-5);
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 0.9rem;
}
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--danger-soft); border-color: rgba(240, 98, 114, 0.35); color: #ffc9cf; }
.alert-success { background: var(--success-soft); border-color: rgba(47, 202, 131, 0.35); color: #b8f2d5; }
.alert-warning { background: var(--warning-soft); border-color: rgba(245, 181, 68, 0.35); color: #ffe2a8; }
.alert-info { background: var(--info-soft); border-color: rgba(76, 181, 245, 0.35); color: #c5e7fd; }
.alert code { background: rgba(0, 0, 0, 0.25); border-color: transparent; color: inherit; }
.card .alert { margin: var(--s-4) var(--s-5) 0; }

/* -------------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  padding: 4px;
  margin-bottom: var(--s-6);
  width: fit-content;
  max-width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tabs a {
  padding: 7px 14px;
  border-radius: 7px;
  color: var(--text-muted);
  font-weight: 550;
  font-size: 0.88rem;
}
.tabs a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------- disclosure */
/* An "Add …" button in a card header that opens its form above the table.
   Built on <details>, so it works without any script. */
.add-panel > summary { list-style: none; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary .when-closed, .add-panel:not([open]) > summary .when-open { display: none; }
.panel {
  padding: var(--s-5);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.panel h3 { margin-bottom: var(--s-4); }

/* ------------------------------------------------------------- empty state */
.empty {
  padding: var(--s-10) var(--s-6);
  text-align: center;
  color: var(--text-muted);
}
.empty .icon { width: 28px; height: 28px; color: var(--text-subtle); margin-bottom: var(--s-2); }
.empty strong { display: block; color: var(--text); margin-bottom: var(--s-1); }

/* ----------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: flex-end;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.toolbar > .field { flex: 1 1 150px; }
.toolbar > .btn-group { flex: none; }
.toolbar.inline { align-items: center; justify-content: space-between; padding-top: var(--s-3); padding-bottom: var(--s-3); }
.toolbar.inline .field-label { color: var(--text-muted); }

.pager {
  display: flex;
  justify-content: flex-end;
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-success { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot-danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot-warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }

/* -------------------------------------------------------------- auth pages */
.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--s-6);
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(110, 107, 255, 0.16), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--s-8);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.auth-card.wide { max-width: 560px; }
.auth-card .brand { justify-content: center; padding: 0 0 var(--s-6); }
.auth-card h1 { font-size: 1.3rem; text-align: center; }
.auth-card .lead { margin: var(--s-2) 0 var(--s-6); color: var(--text-muted); text-align: center; }
.auth-card .stack { gap: var(--s-4); }
.auth-footer { margin-top: var(--s-5); text-align: center; font-size: 0.85rem; color: var(--text-subtle); }

.qr {
  display: grid;
  place-items: center;
  margin: 0 auto var(--s-4);
  padding: 12px;
  width: fit-content;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.qr img { display: block; }
.secret-box {
  padding: var(--s-3);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  text-align: center;
}
code.secret {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  white-space: normal;
}

.codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
  margin: 0 0 var(--s-5);
  padding: 0;
  list-style: none;
  counter-reset: code;
}
.codes li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  counter-increment: code;
}
.codes li::before { content: counter(code); width: 1.4em; color: var(--text-subtle); font-size: 0.75rem; text-align: right; }
.codes code { background: none; border: 0; padding: 0; font-size: 0.98rem; letter-spacing: 0.04em; }

/* ------------------------------------------------------------- utilities */
summary.add-toggle { cursor: pointer; list-style: none; }
summary.add-toggle::-webkit-details-marker { display: none; }
.btn > .when-closed, .btn > .when-open { display: inline-flex; align-items: center; gap: var(--s-2); }
.text-danger { color: var(--danger); }
.wrap-anywhere { overflow-wrap: anywhere; }
.form-hint { margin: var(--s-4) 0 0; color: var(--text-subtle); font-size: 0.82rem; }

/* Stat tiles inside a card, and a card footer that opens settings. */
.stats-inline { padding: var(--s-5); border-top: 1px solid var(--border); }
.stats-inline .stat { box-shadow: none; background: var(--bg-elevated); }
.settings-toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); cursor: pointer; }
.settings-panel[open] > .settings-toggle { border-bottom: 1px solid var(--border); }

/* A two-way switch made of links, such as All / With findings. */
.segmented {
  display: inline-flex;
  flex: none;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.segmented a { padding: 4px 10px; border-radius: 6px; color: var(--text-muted); font-size: 0.82rem; font-weight: 600; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current] { background: var(--surface-3); color: var(--text); }

/* Rule findings, one per line. */
.findings { margin: 0; padding: 0; list-style: none; font-size: 0.82rem; color: var(--text-muted); }
.findings li + li { margin-top: 2px; }
.findings code { margin-right: 4px; }

/* Monitored apps. */
.reasons { margin: 0; padding: 0; list-style: none; font-size: 0.85rem; }
.reasons li + li { margin-top: 2px; }
.alert .reasons { font-size: 0.9rem; }
.stack > .alert { margin: 0; }
.table tr.row-self td { background: var(--bg-elevated); }
.crumb { margin: 0 0 var(--s-1); font-size: 0.85rem; color: var(--text-subtle); }
.title-with-badge { display: flex; align-items: center; gap: var(--s-3); }
.title-with-badge .badge { font-size: 0.8rem; }
.token-card { border-color: rgba(110, 107, 255, 0.45); }
.token-card h2 { display: flex; align-items: center; gap: var(--s-2); }
.empty.compact { padding: var(--s-5); }
.setup p { margin: 0 0 var(--s-2); color: var(--text-muted); }
.setup pre {
  margin: 0 0 var(--s-4);
  padding: var(--s-3) var(--s-4);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 0.8rem;
  line-height: 1.6;
}
.setup pre code { background: none; border: 0; padding: 0; white-space: pre; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.push-right { margin-left: auto; }

/* A metric as a stat tile with its recent history. */
.trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-4);
  padding: var(--s-5);
}
.trend {
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.trend-value { margin: var(--s-1) 0 var(--s-2); font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; }
.trend.is-danger .trend-value { color: var(--danger); }
.trend.is-warning .trend-value { color: var(--warning); }
.trend-chart { height: 44px; }
.sparkline { display: block; width: 100%; height: 44px; overflow: visible; }
.spark-line { fill: none; stroke: var(--text-subtle); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--primary); stroke: var(--bg-elevated); stroke-width: 2; vector-effect: non-scaling-stroke; }
.trend.is-danger .spark-dot { fill: var(--danger); }
.trend.is-warning .spark-dot { fill: var(--warning); }
.spark-hit { fill: transparent; }
.spark-hit:hover { fill: rgba(255, 255, 255, 0.06); }

/* Alert switches, grouped by kind. */
.alert-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s-5); }
.alert-kind { margin: 0; padding: 0; border: 0; min-width: 0; }
.alert-kind legend { margin-bottom: var(--s-3); color: var(--text-subtle); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.check { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-2) 0; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.check span { display: flex; flex-direction: column; gap: 2px; }
.check small { color: var(--text-subtle); font-size: 0.8rem; }
.inline-field { margin-right: auto; min-width: 260px; }
.alert-list { margin-top: 4px; font-size: 0.82rem; color: var(--text-muted); }

/* Country codes as small chips, with the name on hover. */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
  cursor: default;
}

/* A collapsible reference list below a form. */
.reference { margin-top: var(--s-5); border-top: 1px solid var(--border); padding-top: var(--s-4); }
.reference > summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.reference > summary:hover { color: var(--text); }
.country-list {
  columns: 4 200px;
  column-gap: var(--s-5);
  margin: var(--s-3) 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.country-list li { padding: 2px 0; break-inside: avoid; }
.country-list code { margin-right: 6px; }
.country-code { font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted); }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--s-1); }
.table tr.is-selected td { background: var(--primary-soft); }
.panel-title { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-4); color: var(--text); font-weight: 600; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .status-bar { padding: 6px var(--s-4); }
  .sidebar {
    overflow: visible;
    border-right: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--s-2) var(--s-3);
    padding: var(--s-3) var(--s-4) 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; }
  .sidebar-footer { grid-column: 2; grid-row: 1; margin: 0; padding: 0; border-top: 0; }
  .who { display: none; }
  .nav {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--s-1);
    overflow-x: auto;
    margin: 0 calc(-1 * var(--s-4));
    padding: 0 var(--s-4) var(--s-2);
  }
  .nav-label { display: none; }
  .nav a { flex: none; padding: 7px 10px; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--primary); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .content { padding: var(--s-5) var(--s-4) var(--s-8); }
  .form-grid .span-2 { grid-column: auto; }
  .table.kv th { width: auto; }
  .banner { justify-content: flex-start; text-align: left; }
}
