:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #131a22;
  --border: #253242;
  --text: #e6e6e6;
  --muted: #9fb3c8;
  --red: #ff6b6b;
  --green: #8fd19e;
  --amber: #f5c542;
  --accent: #4da3ff;
  /* screen lightens what's underneath — reads as a glow on a dark bg */
  --auth-blend: screen;
  --auth-grid-tint: 14%;
  --auth-radial-tint: 16%;
  --auth-radar-tint: 22%;
}

/* Light theme — toggled via data-theme on <html>, persisted client-side
   in localStorage (see serving/static/theme.js). Same variable names so
   every component that already uses var(--bg)/var(--panel)/etc. picks
   this up automatically, no per-component light-mode overrides needed. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --border: #d3dce6;
  --text: #16202c;
  --muted: #55677d;
  --red: #c0392b;
  --green: #1e8e5a;
  --amber: #9c6f00;
  --accent: #1d6fd6;
  /* multiply darkens what's underneath — the light-mode equivalent of
     screen's glow effect; "screen" against a near-white bg is invisible.
     Tints are also boosted since a light accent tint reads much fainter
     against light gray than the same tint reads against near-black. */
  --auth-blend: multiply;
  --auth-grid-tint: 26%;
  --auth-radial-tint: 30%;
  --auth-radar-tint: 20%;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

main { padding: 1.25rem 1.5rem; }

/* Branding */
.brand { display: flex; align-items: baseline; gap: 0.4rem; }
.brand-mark {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
  background: linear-gradient(90deg, var(--accent), #7ee7c7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--muted); font-size: 0.9rem; }
.brand-logo { width: 1.5rem; height: 1.5rem; align-self: center; flex: none; }

/* Top navigation with tabs */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.tab-btn:hover { color: var(--text); background: #1c2b3a; }
.tab-btn.active { color: var(--text); background: #1c2b3a; border-color: var(--border); }

.tab-panel.hidden { display: none; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.logout-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}
.logout-link:hover { color: var(--text); }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.banner {
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin: 1rem 1.5rem;
  font-size: 0.85rem;
}

.banner-warn { background: #3a2f10; border: 1px solid var(--amber); color: var(--amber); }
.banner-error { background: #3a1414; border: 1px solid var(--red); color: var(--red); }
.banner-success { background: #14311f; border: 1px solid var(--green); color: var(--green); }
.hidden { display: none; }

.download-link {
  float: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
}
.download-link:hover { background: var(--accent); color: #06131f; }

#toast-container {
  position: fixed;
  top: 4.5rem;
  right: 1.5rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.15s ease-out;
}
.toast-success { background: #123a1e; border: 1px solid var(--green, #8fd19e); color: var(--green, #8fd19e); }
.toast-error { background: #3a1414; border: 1px solid var(--red); color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--panel, #10202f);
  border: 1px solid var(--border, #2a3a4a);
  border-radius: 8px;
  padding: 1.5rem;
  width: 90%;
  max-width: 480px;
}
.modal-card h2 { margin: 0 0 0.4rem 0; font-size: 1.05rem; }
.copy-row { display: flex; gap: 0.5rem; margin: 1rem 0 0.5rem 0; }
.copy-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  font-family: monospace;
}
.copy-row button, #token-modal-close {
  background: var(--accent);
  border: none;
  color: #06131f;
  font-weight: 700;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
}
#token-modal-close { background: transparent; border: 1px solid var(--border); color: var(--text); margin-top: 0.75rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.card-label { color: var(--muted); font-size: 0.8rem; }
.card-value { font-size: 1.7rem; font-weight: 700; margin-top: 0.2rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}

.panel h2 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.hint { display: block; font-weight: 400; font-size: 0.78rem; margin-top: 0.2rem; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* Pie/doughnut charts left alone in a grid-2 row would otherwise stretch
   to the full row width (single grid item = 1fr = 100%) \u2014 cap it so it
   stays a reasonable, centered size regardless of screen width. */
#chart-countries {
  max-width: 380px;
  max-height: 380px;
  margin: 0 auto;
  display: block;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

.chip-on { color: var(--green); border-color: var(--green); }
.chip-off { color: var(--muted); }

.selected-countries-block { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.4rem; }
.chip-removable {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.chip-removable button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.2rem;
}
.chip-removable button:hover { color: var(--red); }

.inline-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.inline-form button {
  background: #1c2b3a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.inline-form button:hover { background: #24384a; }
/* A disabled button must look disabled: otherwise a click that does nothing looks like a bug. */
.inline-form button:disabled { opacity: 0.5; cursor: not-allowed; }

.entry-list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }

.entry-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.entry-list button {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 0.8rem;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.settings-form input, .settings-form select, .settings-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: inherit;
}

.settings-form textarea { resize: vertical; }

.checkbox-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text);
}
.checkbox-row label { flex-direction: row; align-items: center; gap: 0.4rem; color: var(--text); }
.checkbox-row input { width: auto; }

.settings-form details {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.settings-form details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
}
.settings-form details label { margin-top: 0.5rem; }

.settings-form button {
  grid-column: 1 / -1;
  justify-self: start;
  background: var(--accent);
  border: none;
  color: #06131f;
  font-weight: 600;
  border-radius: 6px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}

.action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
  margin-right: 0.3rem;
}

.action-btn:hover { background: #1c2b3a; }
.action-btn.ack { color: var(--amber); }
.action-btn.resolve { color: var(--green); }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.55rem;
  text-align: left;
  white-space: nowrap;
}

td { white-space: normal; word-break: break-word; }

tr.blocked { color: var(--red); }
tr.allowed { color: var(--green); }
tr.firing { color: var(--red); }
tr.acknowledged { color: var(--amber); }
tr.resolved { color: var(--muted); }

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 1.5rem;
}

/* Auth pages (login / MFA) */
.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* safe: a form taller than the window (sign-up) starts at the top
     instead of being cut off above it. */
  justify-content: safe center;
  padding: 2rem 1rem;
  position: relative;
  /* Only sideways overflow is hidden, so tall pages still scroll. */
  overflow-x: hidden;
  isolation: isolate;
}

/* ---- Creative security-concept background ------------------------------
   Layered, theme-aware, pure CSS/SVG (no external images): a soft radial
   backdrop, a faint drifting grid (data/telemetry feel), a slow rotating
   radar-sweep, and a periodic scan-line beam — all sitting behind the
   .auth-card and the decorative shield/network SVG from
   _auth_background.html. Depicts, at a glance, what this platform does:
   a shield watching over a connected network in real time. */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden; /* the drifting grid is larger than the window */
  background:
    radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--accent) var(--auth-radial-tint), transparent), transparent 60%),
    var(--bg);
}

.auth-bg::before {
  /* Drifting grid */
  content: "";
  position: absolute;
  inset: -50%;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) var(--auth-grid-tint), transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) var(--auth-grid-tint), transparent) 1px, transparent 1px);
  background-size: 42px 42px;
  animation: auth-grid-drift 40s linear infinite;
  opacity: 0.5;
}

.auth-bg::after {
  /* Rotating radar sweep */
  content: "";
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg at 50% 35%, color-mix(in srgb, var(--accent) var(--auth-radar-tint), transparent), transparent 18%);
  animation: auth-radar-spin 9s linear infinite;
  mix-blend-mode: var(--auth-blend);
}

.auth-scanline {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 20%, transparent) 50%, transparent);
  height: 40%;
  animation: auth-scanline-sweep 6s ease-in-out infinite;
}

.auth-network {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  pointer-events: none;
}
.auth-network svg { width: min(70vmin, 620px); height: auto; }
.auth-network .node { animation: auth-node-pulse 3.2s ease-in-out infinite; transform-origin: center; }
.auth-network .link { stroke-dasharray: 6 6; animation: auth-link-flow 6s linear infinite; }
.auth-network .shield-glow { animation: auth-shield-pulse 4s ease-in-out infinite; }

@keyframes auth-grid-drift {
  from { transform: translate(0, 0); }
  to { transform: translate(42px, 42px); }
}
@keyframes auth-radar-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes auth-scanline-sweep {
  0% { transform: translateY(-60%); opacity: 0; }
  15% { opacity: 0.9; }
  50% { transform: translateY(60%); opacity: 0.9; }
  85% { opacity: 0; }
  100% { transform: translateY(60%); opacity: 0; }
}
@keyframes auth-node-pulse {
  0%, 100% { opacity: 0.55; r: 5; }
  50% { opacity: 1; r: 7; }
}
@keyframes auth-link-flow {
  to { stroke-dashoffset: -120; }
}
@keyframes auth-shield-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent)); }
  50% { filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 90%, transparent)); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-bg::before, .auth-bg::after, .auth-scanline,
  .auth-network .node, .auth-network .link, .auth-network .shield-glow {
    animation: none;
  }
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.auth-theme-toggle { position: fixed; top: 1rem; right: 1rem; z-index: 1; }

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent), 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

.auth-card .brand { justify-content: center; margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 1.2rem; margin: 0 0 0.4rem 0; }
.auth-subtitle { color: var(--muted); font-size: 0.85rem; margin: 0 0 1.25rem 0; }

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}
.auth-back-link:hover { color: var(--accent); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
}

.auth-form button {
  background: var(--accent);
  border: none;
  color: #06131f;
  font-weight: 700;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  margin-top: 0.4rem;
}

.qr-wrap { background: #fff; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.qr-wrap svg { width: 100%; height: auto; display: block; }
.manual-key { font-size: 0.8rem; color: var(--muted); word-break: break-all; margin-bottom: 1rem; }

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin: 1rem 0;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border, #2a3a4a);
}
.auth-divider span { padding: 0 0.75rem; }

.auth-sso-link {
  display: block;
  width: 100%;
  text-align: center;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.auth-sso-link:hover { background: var(--accent); color: #06131f; }

.auth-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 1.5rem;
}

/* Landing (public marketing) page — reuses the auth background layers for
   visual consistency, but scrolls normally instead of being a centered card. */
.landing-body {
  min-height: 100vh;
  padding: 3rem 1.5rem 2rem;
  position: relative;
}

.landing-hero {
  max-width: 760px;
  margin: 0 auto 3rem;
  text-align: center;
}
.landing-hero .brand { justify-content: center; margin-bottom: 1.5rem; }
.landing-hero h1 {
  font-size: 1.9rem;
  line-height: 1.3;
  margin: 0 0 1.25rem;
}
.landing-subtitle {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 2rem;
}

.policy-content {
  max-width: 720px;
  margin: 0 auto 3rem;
  position: relative;
  z-index: 1;
}
.policy-content .brand { margin-bottom: 1.5rem; }
.policy-content h1 { font-size: 1.6rem; margin: 0 0 0.75rem; }
.policy-content h2 { font-size: 1.1rem; color: var(--accent); margin: 1.75rem 0 0.5rem; }
.policy-content p, .policy-content li { color: var(--muted); line-height: 1.6; }
.policy-content ul, .policy-content ol { padding-left: 1.25rem; }
.policy-content h3 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }
.policy-content a { color: var(--accent); }
.policy-content a.brand { color: inherit; text-decoration: none; display: inline-flex; }
.policy-content code { font-size: 0.85em; }
.policy-content hr { border: 0; border-top: 1px solid var(--border, rgba(127,127,127,0.3)); margin: 2rem 0; }
.policy-notice {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid #e0a100;
  background: rgba(224, 161, 0, 0.12);
  border-radius: 6px;
}
.policy-notice p { margin: 0; color: inherit; }
.policy-nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0 0 1.5rem; font-size: 0.85rem; }
.policy-nav a { color: var(--muted); }
.policy-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.policy-table-wrap { overflow-x: auto; margin: 0.75rem 0 1rem; }
.policy-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 0.85rem; }
.policy-table th, .policy-table td { word-break: normal; overflow-wrap: normal; hyphens: manual; }
.policy-table th, .policy-table td {
  text-align: left; vertical-align: top;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border, rgba(127,127,127,0.3));
  color: var(--muted); line-height: 1.5;
}
.policy-table th { color: inherit; }
.auth-footer a { color: inherit; }
.auth-form label.auth-check {
  display: flex; flex-direction: row; align-items: flex-start; gap: 0.5rem;
  font-size: 0.8rem; line-height: 1.45;
}
.auth-form label.auth-check input { width: auto; margin-top: 0.2rem; flex: none; }
.auth-form label.auth-check a { color: var(--accent); }

.landing-cta {
  display: inline-block;
  background: var(--accent);
  color: #06131f;
  font-weight: 700;
  border-radius: 8px;
  padding: 0.85rem 1.75rem;
  text-decoration: none;
  font-size: 1rem;
}
.landing-cta:hover { filter: brightness(1.08); }

.landing-features {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.landing-feature {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}
.landing-feature h2 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
  color: var(--accent);
}
.landing-feature p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0;
}

.landing-pricing {
  max-width: 1080px;
  margin: 3rem auto 0;
  text-align: center;
  position: relative;
  z-index: 1;
}
.landing-pricing h2 { font-size: 1.4rem; margin: 0 0 0.5rem; }
.landing-pricing-note { max-width: 640px; margin: 0 auto 2rem; }

.landing-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  text-align: left;
}

.landing-plan-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.landing-plan-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.landing-plan-card h3 { margin: 0 0 0.4rem; color: var(--accent); font-size: 1.1rem; }
.landing-plan-price { margin: 0 0 1rem; font-size: 1.5rem; font-weight: 700; }
.landing-plan-period { font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.landing-plan-amount { white-space: nowrap; }
.landing-plan-annual { font-size: 0.8rem; color: var(--muted); margin: -0.25rem 0 0.75rem; }
.landing-plan-card ul { list-style: none; margin: 0 0 1.25rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.landing-plan-card li { color: var(--muted); font-size: 0.85rem; }

.landing-plan-cta {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #06131f;
  font-weight: 700;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  text-decoration: none;
  font-size: 0.9rem;
}
.landing-plan-cta:hover { filter: brightness(1.08); }

.landing-early-access {
  max-width: 1080px;
  margin: 3rem auto 0;
  text-align: center;
  position: relative;
  z-index: 1;
}
.landing-early-access h2 { font-size: 1.4rem; margin: 0 0 0.75rem; }
.landing-early-access .landing-subtitle { max-width: 680px; margin: 0 auto 1.5rem; }

.landing-early-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.landing-early-access-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: left;
}
.landing-early-access-item h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.landing-early-access-item p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0;
}

.landing-early-access-ctas {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
}
.landing-cta-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.landing-contact {
  max-width: 480px;
  margin: 3rem auto 2rem;
  text-align: center;
  position: relative;
  z-index: 1;
}
.landing-contact h2 { font-size: 1.4rem; margin: 0 0 0.5rem; }

.landing-contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
  margin-top: 1.5rem;
}
.landing-contact-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.landing-contact-form input, .landing-contact-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
}
.landing-contact-form button {
  background: var(--accent);
  border: none;
  color: #06131f;
  font-weight: 700;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
}


/* Models tab (serving/static/models.js) */
.model-card { border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem 1rem; margin-bottom: 1rem; }
.model-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.model-facts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 0.6rem; font-size: 0.85rem; }
.model-facts b { font-weight: 600; }
.model-status { border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.75rem; border: 1px solid var(--border); }
.model-status.active, .model-status.promoted { color: var(--green); }
.model-status.rejected, .model-status.rolled_back { color: var(--red, #ff6b6b); }
.model-status.needs_review, .model-status.shadow, .model-status.shadow_started { color: var(--amber); }
.model-card table { width: 100%; font-size: 0.82rem; }
.model-card details { margin-top: 0.4rem; }

/* Info icons and their popover (serving/static/info.js) */
.tab-item { display: inline-flex; align-items: center; gap: 0.1rem; }
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.05rem; height: 1.05rem; min-width: 0; padding: 0; margin: 0 0.15rem;
  border: 1px solid var(--muted); border-radius: 50%;
  background: transparent; color: var(--muted);
  font: italic 600 0.68rem/1 Georgia, "Times New Roman", serif;
  cursor: pointer; vertical-align: middle; flex: none;
}
.info-btn:hover, .info-btn.open { color: var(--accent); border-color: var(--accent); }
.info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-info] > .info-btn { margin-left: 0.4rem; }
.info-btn-tab { opacity: 0.55; }
.tab-item:hover .info-btn-tab, .tab-btn.active + .info-btn-tab, .info-btn-tab.open, .info-btn-tab:focus-visible { opacity: 1; }
.info-pop {
  position: absolute; z-index: 1000; box-sizing: border-box;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 0.8rem 0.95rem; font-size: 0.85rem; line-height: 1.45;
}
.info-pop.hidden { display: none; }
.info-pop:focus { outline: none; }
.info-pop:focus-visible { outline: 2px solid var(--accent); }
.info-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.info-pop-head strong { font-size: 0.92rem; }
.info-pop-close {
  background: transparent; border: none; color: var(--muted); padding: 0 0.25rem;
  font-size: 1.15rem; line-height: 1; cursor: pointer; min-width: 0;
}
.info-pop-close:hover { color: var(--text); }
.info-pop p { margin: 0 0 0.45rem; }
.info-pop-label { margin-top: 0.55rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.info-pop-example { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.info-pop-example li { margin: 0.2rem 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------- Feedback ----
   Errors and confirmations (see the Feedback section of dashboard.js). */
.banner-error:not(.hidden) { display: flex; align-items: flex-start; gap: 0.75rem; font-weight: 600; }
.banner-error .banner-text { flex: 1; }
.banner-close, .toast-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  opacity: 0.8;
}
.banner-close:hover, .toast-close:hover { opacity: 1; }

#toast-container { max-width: min(420px, calc(100vw - 2rem)); }
.toast { align-items: flex-start; font-weight: 500; line-height: 1.35; }
.toast-icon {
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  border: 1.5px solid currentColor;
}
.toast-body { flex: 1; }
.toast-action {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.toast-error { border-width: 1px 1px 1px 4px; }
.toast-warn { background: #3a2f10; border: 1px solid var(--amber); border-left-width: 4px; color: var(--amber); }
.toast-info { background: var(--panel); border: 1px solid var(--accent); color: var(--text); }

/* A field the error is about: red outline that clears as you type. */
input.field-invalid, select.field-invalid, textarea.field-invalid {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 35%, transparent);
  outline: none;
}

/* The message right under a form. */
.form-feedback:empty { display: none; }
.form-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem 0.6rem;
  margin: 0.6rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.4;
}
.form-feedback-error { background: #3a1414; border: 1px solid var(--red); border-left-width: 4px; color: var(--red); font-weight: 600; }
.form-feedback-success { background: #14311f; border: 1px solid var(--green); border-left-width: 4px; color: var(--green); }
.form-feedback-warn { background: #3a2f10; border: 1px solid var(--amber); border-left-width: 4px; color: var(--amber); }
.form-feedback-info { background: var(--panel); border: 1px solid var(--accent); color: var(--text); }
.form-feedback-icon { font-weight: 800; }
.form-feedback-text { flex: 1 1 60%; }
.form-feedback-note { flex-basis: 100%; font-weight: 400; color: var(--muted); font-size: 0.82rem; }
.form-feedback-fix {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 4px;
  padding: 0.15rem 0.6rem;
  cursor: pointer;
}

/* While a form is being sent. */
form.is-busy button[disabled] { opacity: 0.7; cursor: progress; }

.error-text { color: var(--red) !important; font-weight: 600; }
.inline-warning {
  display: block;
  margin-top: 0.35rem;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--amber);
  font-size: 0.8rem;
}
.inline-warning button { margin-top: 0.35rem; display: block; }
.form-note { color: var(--green); }

/* Websites tab: DNS records as two steps. */
.dns-step { margin-bottom: 0.5rem; }
.dns-step strong { display: block; font-size: 0.8rem; margin-bottom: 0.15rem; }
.dns-record { margin: 0.1rem 0; }
.dns-or { color: var(--muted); font-size: 0.75rem; font-style: italic; margin: 0.1rem 0 0.1rem 0.5rem; }
.dns-choose {
  display: inline-block;
  margin: 0.1rem 0 0.2rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 700;
}

:root[data-theme="light"] .toast-success,
:root[data-theme="light"] .form-feedback-success { background: #e8f6ee; }
:root[data-theme="light"] .toast-error,
:root[data-theme="light"] .form-feedback-error,
:root[data-theme="light"] .banner-error { background: #fdecea; }
:root[data-theme="light"] .toast-warn,
:root[data-theme="light"] .form-feedback-warn { background: #fff6dd; }
.warn-text { color: var(--amber) !important; }

/* ------------------------------------------------- Protection switch ---- */
.protection-pill { background: transparent; cursor: pointer; font: inherit; font-weight: 700; }
.protection-pill.protection-block { color: var(--green); border-color: var(--green); }
.protection-pill.protection-monitor { color: var(--amber); border-color: var(--amber); }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
.choice-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.choice-card strong { font-size: 1rem; }
.choice-card span { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.choice-card:hover { border-color: var(--accent); }
.choice-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.choice-card.selected strong::before { content: "● "; color: var(--accent); }
.choice-card[data-enforcement="block"].selected { border-color: var(--green); }
.choice-card[data-enforcement="block"].selected strong::before { color: var(--green); }
.choice-card[data-enforcement="monitor"].selected { border-color: var(--amber); }
.choice-card[data-enforcement="monitor"].selected strong::before { color: var(--amber); }
.protection-detail { margin: 0.75rem 0 0; font-weight: 600; font-size: 0.9rem; }
.protection-detail.protection-block { color: var(--green); }
.protection-detail.protection-monitor { color: var(--amber); }

/* ------------------------------------------------------ Get started ---- */
.setup-panel { border-color: var(--accent); }
.setup-steps { list-style: none; margin: 0.75rem 0 0.5rem; padding: 0; display: grid; gap: 0.5rem; }
.setup-step { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; }
.setup-step.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.setup-step.done { opacity: 0.7; }
.setup-mark {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid var(--border);
}
.setup-step.current .setup-mark { border-color: var(--accent); color: var(--accent); }
.setup-step.done .setup-mark { border-color: var(--green); color: var(--green); }
.setup-text { flex: 1; display: flex; flex-direction: column; }
.link-button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 0.8rem; text-decoration: underline; }
/* Incident "Why" (roadmap item 10) */
.incident-why { margin-top: 0.25rem; font-size: 0.85rem; }
.incident-why summary { cursor: pointer; color: var(--accent); }
.incident-why ul { margin: 0.25rem 0 0.25rem 1rem; padding: 0; }
.incident-why .inline-form { gap: 0.4rem; margin-top: 0.3rem; }
.flash-highlight { outline: 3px solid var(--accent); outline-offset: 3px; transition: outline-color 0.3s; animation: flash-pulse 0.7s ease-out 2; }
@keyframes flash-pulse { 0% { box-shadow: 0 0 0 0 var(--accent); } 100% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { .flash-highlight { animation: none; } }
.plan-picker { border-radius: 8px; padding: 0.4rem; margin: -0.4rem; }

/* Settings labels: helper text sits under the label, above the box. */
.settings-form label > .hint { color: var(--muted); }

/* Sign-out warning, shown a minute before the idle timeout. */
.idle-warning {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: calc(100vw - 2rem);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  background: #3a2f10;
  border: 1px solid var(--amber);
  border-left-width: 4px;
  color: var(--amber);
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.idle-warning.hidden { display: none; }
:root[data-theme="light"] .idle-warning { background: #fff6dd; }

/* Forgot password link and reset pages */
.auth-forgot-row { display: flex; justify-content: flex-end; margin-top: -0.5rem; }
.auth-forgot { color: var(--accent); font-size: 0.8rem; text-decoration: none; }
.auth-forgot:hover, .auth-forgot:focus-visible { text-decoration: underline; }
.auth-links { margin-top: 1rem; font-size: 0.85rem; text-align: center; }
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
:root[data-theme="light"] .banner-success { background: #e8f6ee; color: #146c3a; }
:root[data-theme="light"] .banner-warn { background: #fff6e0; color: #7a5600; }

/* ------------------------------------------------ Settings side menu ---- */
/* Every setting lives in the Settings tab, one group at a time. */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.settings-nav {
  position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 0.2rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem;
}
.settings-nav-btn {
  text-align: left; background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 6px; padding: 0.55rem 0.7rem; font: inherit; font-size: 0.9rem; cursor: pointer;
}
.settings-nav-btn:hover { color: var(--text); background: rgba(77, 163, 255, 0.08); }
.settings-nav-btn.active { color: var(--text); background: rgba(77, 163, 255, 0.15); border-color: var(--accent); font-weight: 600; }
.settings-nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.settings-group-title { font-size: 1.25rem; margin: 0 0 0.35rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.settings-group-note { margin: 0 0 1rem; }
.settings-group > .panel:first-of-type, .settings-group > .settings-group-note + .panel { margin-top: 0.75rem; }
.role-badge {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; color: var(--amber);
  border: 1px solid var(--amber); border-radius: 999px; padding: 0.1rem 0.55rem;
}
.role-badge:empty { display: none; }
@media (max-width: 860px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .settings-nav-btn { white-space: nowrap; }
}
@media (max-width: 860px) {
  .topbar-right { flex-wrap: wrap; }
}

/* ------------------------------------------------------- Paged tables ---- */
.pager { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.pager button { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 6px;
  padding: 0.35rem 0.75rem; font: inherit; font-size: 0.85rem; cursor: pointer; }
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager-status { color: var(--muted); font-size: 0.85rem; flex: 1 1 14rem; text-align: center; }
.pager-size { color: var(--muted); font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.pager-size select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.2rem 0.35rem; }
.card-link { display: inline-block; margin-top: 0.4rem; font-size: 0.8rem; color: var(--accent); text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ------------------------------------------------------ Origin lock ---- */
.origin-lock-values { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.45rem 0.9rem; margin: 0 0 0.6rem; align-items: center; }
.origin-lock-values dt { color: var(--muted); font-size: 0.85rem; }
.origin-lock-values dd { margin: 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.origin-lock-values code { word-break: break-all; }
.copy-btn { background: transparent; border: 1px solid var(--border); color: var(--accent); border-radius: 6px;
  padding: 0.15rem 0.55rem; font: inherit; font-size: 0.78rem; cursor: pointer; }
.copy-btn:hover { border-color: var(--accent); }
.origin-lock-actions { margin: 0.6rem 0; }
.origin-lock-results { list-style: none; padding: 0; margin: 0.4rem 0; display: grid; gap: 0.4rem; }
.origin-lock-results li { border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; padding: 0.5rem 0.7rem; display: grid; gap: 0.2rem; }
.origin-lock-results strong { word-break: break-all; }
.origin-lock-locked { border-left-color: var(--green) !important; }
.origin-lock-open, .origin-lock-blocks_secops { border-left-color: var(--red) !important; }
.origin-lock-unreachable, .origin-lock-invalid { border-left-color: var(--amber) !important; }
.origin-lock-guide { margin-top: 0.8rem; border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem; }
.origin-lock-guide summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.origin-lock-guide label { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.8rem 0 0.4rem; color: var(--muted); font-size: 0.85rem; max-width: 28rem; }
.origin-lock-guide select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.5rem; font: inherit; }
.snippet-box { position: relative; }
.snippet-box pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem; overflow-x: auto;
  font-size: 0.8rem; line-height: 1.45; margin: 0.4rem 0; }
.snippet-box .copy-btn { position: absolute; top: 0.45rem; right: 0.45rem; background: var(--panel); }

/* ===================================================================
   App shell: grouped, collapsible left menu (2026-12-01).
   The menu buttons are the same .tab-btn[data-tab] buttons the tabs used,
   so every tab script, deep link and info icon keeps working.
   =================================================================== */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:root { --sidebar-w: 248px; --sidebar-w-collapsed: 68px; --hover: rgba(77, 163, 255, 0.10); --active: rgba(77, 163, 255, 0.16); }
:root[data-theme="light"] { --hover: rgba(29, 111, 214, 0.08); --active: rgba(29, 111, 214, 0.13); }

.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-main > main { flex: 1; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.9rem; padding: 0.9rem 0.7rem 1rem;
  scrollbar-width: thin;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; padding: 0.1rem 0.25rem 0.2rem; }
.sidebar-head .brand { min-width: 0; overflow: hidden; white-space: nowrap; }
.sidebar-collapse, .sidebar-open {
  flex: none; display: inline-grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer;
}
.sidebar-collapse:hover, .sidebar-open:hover { color: var(--text); background: var(--hover); }
.sidebar-collapse svg, .sidebar-open svg, .nav-icon, .kpi-icon, .activity-icon {
  width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none;
}
.sidebar-open { display: none; }

.sidebar-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); opacity: 0.85; padding: 0 0.6rem 0.35rem; white-space: nowrap;
}
.sidebar-viewing .tenant-view-pill, .sidebar-tenant {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 0.85rem;
}
.sidebar-viewing select {
  flex: 1; min-width: 0; background: transparent; color: var(--text); border: 0; font: inherit; cursor: pointer; padding: 0;
}
.sidebar-viewing select option { background: var(--panel); color: var(--text); }
.sidebar-tenant .nav-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav { display: flex; flex-direction: column; gap: 1rem; flex: 1; }
.sidebar-group { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-group-end { margin-top: auto; }
.sidebar-nav .tab-item { display: flex; align-items: center; gap: 0.15rem; }
.sidebar-nav .tab-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.65rem; text-align: left;
  padding: 0.5rem 0.6rem; border-radius: 8px; font-size: 0.88rem; color: var(--muted); border: 1px solid transparent;
}
.sidebar-nav .tab-btn .nav-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav .tab-btn:hover { color: var(--text); background: var(--hover); }
.sidebar-nav .tab-btn.active { color: var(--text); background: var(--active); border-color: transparent; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-nav .tab-btn:focus-visible, .nav-sub:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sidebar-nav .tab-btn.active .nav-icon { color: var(--accent); }
.sidebar-nav .info-btn-tab { opacity: 0; }
.sidebar-nav .tab-item:hover .info-btn-tab, .sidebar-nav .info-btn-tab:focus-visible, .sidebar-nav .info-btn-tab.open { opacity: 1; }
.nav-subs { display: flex; flex-direction: column; margin: 0.1rem 0 0 1.55rem; border-left: 1px solid var(--border); }
.nav-sub {
  text-align: left; background: transparent; border: 0; color: var(--muted); cursor: pointer;
  font-size: 0.8rem; padding: 0.3rem 0.7rem; border-radius: 0 6px 6px 0;
}
.nav-sub:hover { color: var(--text); background: var(--hover); }
.nav-sub.active { color: var(--accent); background: var(--active); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }

/* Collapsed: icons only. Labels stay for screen readers via title/aria. */
.sidebar-collapsed .sidebar { padding-left: 0.55rem; padding-right: 0.55rem; }
.sidebar-collapsed .sidebar-head { flex-direction: column; }
.sidebar-collapsed .sidebar-head .brand-mark, .sidebar-collapsed .sidebar-head .brand-sub,
.sidebar-collapsed .sidebar-label, .sidebar-collapsed .nav-text, .sidebar-collapsed .nav-subs,
.sidebar-collapsed .sidebar-nav .info-btn-tab, .sidebar-collapsed .sidebar-viewing select { display: none; }
.sidebar-collapsed .sidebar-nav .tab-btn { justify-content: center; padding: 0.6rem 0; }
.sidebar-collapsed .sidebar-viewing .tenant-view-pill, .sidebar-collapsed .sidebar-tenant { justify-content: center; padding: 0.5rem 0; }
.sidebar-collapsed .sidebar-nav { gap: 0.6rem; }
.sidebar-collapsed .sidebar-collapse svg { transform: scaleX(-1); }

/* Top bar now sits above the page, beside the menu. */
.app-main .topbar { position: sticky; top: 0; z-index: 20; padding: 0.6rem 1.5rem; flex-wrap: nowrap; }
.topbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumb-root { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.crumb-root:empty, .crumb-root:empty + .crumb-sep { display: none; }
.crumb-sep { color: var(--border); }
.crumb-current { color: var(--text); font-weight: 600; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.app-main .banner { margin: 1rem 1.5rem 0; }

/* ------------------------------------------------ Security Overview --- */
.overview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 0.25rem 0 1rem; }
.page-title { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
.page-sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.86rem; }
.status-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  font-size: 0.78rem; font-weight: 600; padding: 0.25rem 0.65rem; border-radius: 999px; border: 1px solid var(--border);
}
.status-chip[hidden] { display: none; }
.status-chip::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.status-chip.status-block { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.status-chip.status-monitor { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 0.9rem; min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 1.55rem; font-weight: 700; margin-top: 0.3rem; font-variant-numeric: tabular-nums; }
.kpi-bad .kpi-value, .kpi-bad .kpi-icon { color: var(--red); }
.kpi-good .kpi-value, .kpi-good .kpi-icon { color: var(--green); }
.kpi-warn .kpi-value, .kpi-warn .kpi-icon { color: var(--amber); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.overview-grid .panel { margin: 0; }
.panel-compact h2 { margin-bottom: 0.75rem; }
.donut-wrap { position: relative; height: 180px; max-width: 220px; margin: 0 auto; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.donut-center span { color: var(--muted); font-size: 0.78rem; }
.donut-legend { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.82rem; }
.donut-legend span::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.35rem; background: currentColor; }
.legend-bad { color: var(--red); }
.legend-good { color: var(--green); }

.reason-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.bar-row { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.84rem; margin-bottom: 0.3rem; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row b { font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--border) 70%, transparent); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.country-bars .bar-fill { background: color-mix(in srgb, var(--accent) 55%, var(--green)); }
.bars-empty, .activity-empty { color: var(--muted); font-size: 0.85rem; list-style: none; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li:not(.activity-empty) { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.activity-list li:first-child { border-top: 0; }
.activity-icon { color: var(--muted); }
.activity-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.activity-title { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-meta { color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint-inline { color: var(--muted); font-size: 0.76rem; font-weight: 400; }
.activity-status { font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.activity-status.status-bad { color: var(--red); }
.activity-status.status-warn { color: var(--amber); }

/* ---------------------------------------------- ML Model Governance --- */
.model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 1rem; }
.model-grid .model-card { margin: 0; border-radius: 10px; padding: 1rem; background: var(--bg); }
.model-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.model-card-head h3 { margin: 0; font-size: 1rem; }
.model-file { margin: 0.3rem 0 0.75rem; color: var(--muted); font-size: 0.82rem; word-break: break-all; }
.model-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.kpi-mini { background: var(--panel); padding: 0.6rem 0.75rem; }
.kpi-mini .kpi-value { font-size: 1.25rem; }
.model-honest { margin: 0.75rem 0 0.25rem; font-size: 0.86rem; }
.model-shadow { margin: 0.5rem 0; font-size: 0.84rem; }
.model-row { display: flex; justify-content: space-between; gap: 0.75rem; border-top: 1px solid var(--border); margin-top: 0.75rem; padding-top: 0.6rem; font-size: 0.86rem; }
.model-row span { color: var(--muted); }
.model-actions { margin-top: 0.6rem; }
.lifecycle { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.lifecycle li { counter-increment: step; position: relative; padding: 0 0 1rem 2.6rem; display: flex; flex-direction: column; gap: 0.15rem; }
.lifecycle li::before {
  content: counter(step); position: absolute; left: 0; top: -0.1rem; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.lifecycle li:not(:last-child)::after { content: ""; position: absolute; left: 0.86rem; top: 1.75rem; bottom: 0.1rem; width: 1px; background: var(--border); }
.lifecycle li b { font-size: 0.9rem; }
.lifecycle li span { color: var(--muted); font-size: 0.82rem; }
.lifecycle li.step-now::before { background: var(--accent); color: #fff; }
.step-tag { font-style: normal; font-size: 0.74rem; color: var(--amber); }

/* -------------------------------------------------------- Responsive --- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .app-shell, .app-shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 60;
    transform: translateX(-105%); transition: transform 0.2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 55; }
  .sidebar-collapse { display: none; }
  .sidebar-open { display: inline-grid; }
  /* The collapsed choice is for wide screens; the phone drawer always shows labels. */
  .sidebar-collapsed .sidebar-label, .sidebar-collapsed .nav-text, .sidebar-collapsed .sidebar-viewing select { display: revert; }
  .sidebar-collapsed .nav-subs { display: flex; }
  .sidebar-collapsed .sidebar-nav .tab-btn { justify-content: flex-start; padding: 0.5rem 0.6rem; }
  .sidebar-collapsed .sidebar-head { flex-direction: row; }
  .sidebar-collapsed .sidebar-head .brand-mark, .sidebar-collapsed .sidebar-head .brand-sub { display: revert; }
  .app-main .topbar { padding: 0.55rem 1rem; }
  .topbar-right a.logout-link[href*="password"], .topbar-right .pill:not(.protection-pill), .topbar-right .dot { display: none; }
  .crumb-root, .crumb-sep { display: none; }
  main { padding: 1rem; }
  .app-main .banner { margin: 0.75rem 1rem 0; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .kpi-value { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ------------------------------------- Customer overview (2026-12-01) --- */
.nav-badge {
  margin-left: auto; padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); background: color-mix(in srgb, var(--amber) 10%, transparent);
}
.nav-sub .nav-badge { margin-left: 0.4rem; }
.sidebar-collapsed .nav-badge { display: none; }
.sidebar-tenant .nav-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-org-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-org-plan { font-size: 0.72rem; color: var(--muted); }

.overview-top { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 1rem; margin-bottom: 1rem; align-items: start; }
.overview-top > .panel { margin: 0; }
.overview-top-provider, .overview-top:has(> .usage-panel.hidden) { grid-template-columns: minmax(0, 1fr); }
.overview-pair { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 1rem; margin-bottom: 1rem; align-items: start; }
.overview-pair > .panel { margin: 0; }
.overview-pair:has(> #websites-panel.hidden) { grid-template-columns: minmax(0, 1fr); }

/* Plan and usage card */
.plan-head { display: grid; gap: 0.35rem; margin: 0.4rem 0 0.8rem; }
.plan-line { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.88rem; }
.plan-line span { color: var(--muted); }
.plan-line b { text-align: right; }
.plan-badge { display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.plan-badge-trial { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.plan-badge-ended { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.usage-meters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.7rem; margin: 0.4rem 0; }
.usage-meter { display: flex; flex-direction: column; gap: 0.3rem; }
.usage-meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.86rem; }
.usage-meter-head strong { font-variant-numeric: tabular-nums; font-weight: 600; }
.usage-bar { height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 22%, transparent); overflow: hidden; }
.usage-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.usage-bar.warn > span { background: var(--amber); }
.usage-bar.full > span { background: var(--red); }
.usage-meter .hint { margin: 0; }
.after-trial { margin-top: 0.8rem; padding: 0.6rem 0.75rem; border: 1px dashed var(--border); border-radius: 8px; }
.after-trial h3 { margin: 0 0 0.35rem; font-size: 0.86rem; }
.after-trial ul { margin: 0; padding-left: 1.1rem; font-size: 0.84rem; color: var(--muted); display: grid; gap: 0.2rem; }
.plan-link { margin-top: 0.4rem; font-size: 0.84rem; color: var(--accent); }

/* Security protection status */
.engine-list { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.engine { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.55rem 0; border-top: 1px solid var(--border); }
.engine:first-child { border-top: 0; }
.engine-dot { flex: none; width: 0.6rem; height: 0.6rem; margin-top: 0.38rem; border-radius: 50%; background: var(--muted); }
.engine-main { flex: 1; min-width: 0; }
.engine-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.2rem 0.75rem; }
.engine-top b { font-size: 0.9rem; }
.engine-status { font-size: 0.8rem; font-weight: 600; }
.engine .hint { margin: 0.1rem 0 0; font-size: 0.8rem; }
.engine-link { flex: none; margin-top: 0.15rem; color: var(--accent); }
.engine-on .engine-dot { background: var(--green); }
.engine-on .engine-status { color: var(--green); }
.engine-watch .engine-dot { background: var(--amber); }
.engine-watch .engine-status { color: var(--amber); }
.engine-off .engine-status, .engine-unavailable .engine-status { color: var(--muted); }
.engine-off .engine-dot, .engine-unavailable .engine-dot { background: transparent; border: 1px solid var(--muted); }
.engine-upgrade .engine-dot { background: transparent; border: 1px solid var(--accent); }
.engine-upgrade .engine-status { color: var(--accent); }

/* Protected websites */
.website-list { list-style: none; margin: 0; padding: 0; }
.site { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0; border-top: 1px solid var(--border); }
.site:first-child { border-top: 0; }
.site-main { display: flex; flex-direction: column; min-width: 0; }
.site-main b { overflow-wrap: anywhere; }
.site-main .hint { font-size: 0.8rem; }
.site-state { flex: none; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid currentColor; }
.site-protected .site-state { color: var(--green); }
.site-pending .site-state { color: var(--amber); }
.site-error .site-state { color: var(--red); }

/* Traffic decision */
.decision { font-weight: 600; font-size: 0.82rem; }
.decision-blocked { color: var(--red); }
.decision-throttled { color: var(--amber); }
.decision-allowed { color: var(--muted); }

/* Custom rule lifecycle */
.rule-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.25rem 0 0.9rem; padding: 0; }
.rule-steps li { font-size: 0.8rem; padding: 0.2rem 0.6rem 0.2rem 0.25rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.rule-steps li b { display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; margin-right: 0.3rem; border-radius: 50%; font-size: 0.7rem; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.rule-cards { display: grid; gap: 0.75rem; margin-top: 1rem; }
.rule-card { border: 1px solid var(--border); border-left-width: 3px; border-radius: 10px; padding: 0.8rem 1rem; }
.rule-card.rule-enforcing { border-left-color: var(--green); }
.rule-card.rule-report_only, .rule-card.rule-pending_approval { border-left-color: var(--amber); }
.rule-card.rule-draft { border-left-color: var(--accent); }
.rule-card.rule-disabled { border-left-color: var(--muted); opacity: 0.85; }
.rule-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.rule-card-head h3 { margin: 0; font-size: 0.98rem; overflow-wrap: anywhere; }
.rule-status { font-size: 0.76rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 999px; background: color-mix(in srgb, var(--muted) 16%, transparent); }
.rule-status-enforcing { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.rule-status-report_only, .rule-status-pending_approval { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.rule-status-draft { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.rule-def { margin: 0.45rem 0; font-size: 0.88rem; }
.rule-def code { overflow-wrap: anywhere; }
.rule-progress { list-style: none; display: flex; margin: 0.4rem 0 0.6rem; padding: 0; }
.rule-progress li { flex: 1; position: relative; padding-top: 0.9rem; font-size: 0.72rem; color: var(--muted); text-align: center; }
.rule-progress li::before { content: ""; position: absolute; top: 0.25rem; left: 0; right: 0; height: 3px; background: var(--border); }
.rule-progress li::after { content: ""; position: absolute; top: 0; left: 50%; width: 0.6rem; height: 0.6rem; margin-left: -0.3rem; border-radius: 50%; background: var(--panel); border: 2px solid var(--border); }
.rule-progress li.done { color: var(--text); }
.rule-progress li.done::before, .rule-progress li.done::after { background: var(--green); border-color: var(--green); }
.rule-progress li.now { color: var(--accent); font-weight: 700; }
.rule-progress li.now::after { border-color: var(--accent); background: var(--accent); }
.rule-subhead { font-size: 0.86rem; margin: 0.5rem 0 0.3rem; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.check { display: flex; gap: 0.5rem; font-size: 0.84rem; }
.check-icon { flex: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 700; }
.check-pass .check-icon { color: var(--green); border: 1px solid var(--green); }
.check-warn .check-icon { color: var(--amber); border: 1px solid var(--amber); }
.check-fail .check-icon { color: var(--red); border: 1px solid var(--red); }
.check-skipped .check-icon { color: var(--muted); border: 1px solid var(--muted); }
.rule-validation.stale { opacity: 0.65; }
.rule-examples { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--muted); }
.rule-approval { font-size: 0.86rem; margin: 0.4rem 0; padding: 0.45rem 0.6rem; border-radius: 6px; background: color-mix(in srgb, var(--amber) 10%, transparent); }
.rule-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.rule-actions [data-danger] { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.rule-history { margin-top: 0.6rem; font-size: 0.84rem; }
.owasp-edition { font-weight: 400; color: var(--muted); font-size: 0.8em; }

/* Protect a website, step by step */
.wizard-pick { margin: 0.25rem 0 0.6rem; }
.wizard-steps { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.wizard-step { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; }
.wizard-step.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.wizard-step.done { opacity: 0.72; }
.wizard-step.current .setup-mark { border-color: var(--accent); color: var(--accent); }
.wizard-step.done .setup-mark { border-color: var(--green); color: var(--green); }
.wizard-body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.wizard-body .dns-record { overflow-wrap: anywhere; font-size: 0.82rem; }
.wizard-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.wizard-actions button.secondary { background: transparent; }

/* Wallet protection policies */
.wallet-policy fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 0.75rem; padding: 0.6rem 0.8rem 0.75rem; }
.wallet-policy legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; }
.wallet-policy legend .hint { display: block; font-weight: 400; }
.hold-options { display: grid; gap: 0.8rem; }
.hold-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.4rem 1rem; }
.hold-group h4 { margin: 0 0 0.35rem; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hold-group .hint { margin: 0 0 0.4rem; }
#wizard-site { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.5rem; font-size: 0.85rem; margin-left: 0.4rem; }
.wizard-pick label { font-size: 0.88rem; }
.hold-option { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.84rem; }
.hold-option input { margin-top: 0.2rem; }
.hold-option span { display: flex; flex-direction: column; }
.hold-option b { font-weight: 600; }
.hold-edge em { font-style: normal; font-size: 0.76rem; }
.check-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; }
.check-line .hint { flex-basis: 100%; }
.advanced-json { margin: 0.5rem 0 1rem; }
.advanced-json summary { cursor: pointer; font-weight: 600; }

@media (max-width: 1100px) {
  .overview-top, .overview-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .rule-progress li { font-size: 0; }
  .rule-progress li.now { font-size: 0.7rem; }
  .site { flex-wrap: wrap; }
}
.wizard-actions button:not(.link-button) {
  background: var(--accent); border: 1px solid var(--accent); color: #fff; border-radius: 6px;
  padding: 0.35rem 0.8rem; font-size: 0.82rem; cursor: pointer;
}
.wizard-actions button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.wizard-actions .link-button, .rule-actions .link-button { color: var(--accent); }
.rule-actions .action-btn { font-size: 0.8rem; padding: 0.3rem 0.65rem; }
.rule-actions .action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.wallet-policy .inline-form button[type=submit] { background: var(--accent); border-color: var(--accent); color: #fff; }
/* .hint sets display: block after .hidden in this file; keep hidden hints hidden. */
.hint.hidden { display: none; }

/* ===================================== Phones, tablets and touch (2026-12-02) ===
   Breakpoints: 860px and below the menu is a slide-in drawer (above);
   640px and below data tables become one card per row (labels come from
   serving/static/responsive.js); "pointer: coarse" is any touch screen,
   whatever its width, and gets finger-sized controls. */

/* Phones must not enlarge some text on their own ("font boosting"), and
   the page never scrolls sideways: wide content scrolls inside its box. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; }
img, svg, canvas, video { max-width: 100%; }
.panel, .kpi, .modal-card { min-width: 0; }
main pre, main code { overflow-wrap: anywhere; white-space: pre-wrap; }
.table-wrap, .policy-table-wrap { -webkit-overflow-scrolling: touch; max-width: 100%; }

/* Theme toggle: icon and words are separate (theme.js) so narrow bars can
   show the icon only. */
.theme-toggle-icon { display: inline-block; }
.theme-toggle { gap: 0.35rem; }

/* Account box at the foot of the menu: only used in the phone/tablet drawer. */
.sidebar-account { display: none; }

/* Modals fit the screen and scroll inside themselves. */
.modal-card { max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; }

/* Narrow desktop and landscape tablet (sidebar still visible). */
@media (max-width: 1200px) and (min-width: 861px) {
  .topbar-right .pill:not(.protection-pill), .topbar-right .dot { display: none; }
  .topbar-right .theme-toggle .theme-toggle-text { display: none; }
  .topbar-right { flex-wrap: nowrap; flex: none; }
  .topbar-left { flex: 1 1 auto; min-width: 0; }
  .topbar-right .pill, .topbar-right .logout-link { white-space: nowrap; }
  .topbar-right .protection-pill { font-size: 0.8rem; }
}

/* Tablet portrait and phones: the drawer. */
@media (max-width: 860px) {
  .sidebar { height: 100vh; height: 100dvh; overscroll-behavior: contain; }
  .sidebar-account {
    display: flex; flex-direction: column; gap: 0.4rem;
    border-top: 1px solid var(--border); padding: 0.8rem 0.35rem 0.2rem;
  }
  .sidebar-account .sidebar-label { padding-left: 0.25rem; }
  .sidebar-account-name { font-size: 0.88rem; font-weight: 600; padding: 0 0.25rem; overflow-wrap: anywhere; }
  .sidebar-account-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .sidebar-account-actions .theme-toggle, .sidebar-account-actions .logout-link {
    display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  }
  .app-main .topbar { gap: 0.5rem; }
  .topbar-left { flex: 1 1 auto; }
  .crumbs { flex: 1 1 auto; }
  .crumb-current { overflow: hidden; text-overflow: ellipsis; }
  .topbar-left { min-width: 0; }
  .topbar-right { flex: none; flex-wrap: nowrap; gap: 0.5rem; }
  .topbar-right .theme-toggle .theme-toggle-text { display: none; }
  .topbar-right .protection-pill { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; font-size: 0.8rem; }
  /* Long settings forms: two-up rows stack. */
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .overview-head { flex-wrap: wrap; }
  /* Inputs at 16px stop iPhones zooming the page in on every tap. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px; }
}

/* Phones. */
@media (max-width: 600px) {
  main { padding: 0.85rem 0.75rem 1.5rem; }
  .app-main .topbar { padding: 0.5rem 0.75rem; }
  .app-main .banner { margin: 0.6rem 0.75rem 0; }
  /* Theme, Change password and Sign out live in the menu's account box. */
  .topbar-right .theme-toggle, .topbar-right .logout-link { display: none; }
  .topbar-right .protection-pill { font-size: 0.72rem; padding: 0.3rem 0.6rem; max-width: 52vw; }
  .panel { padding-left: 0.85rem; padding-right: 0.85rem; }
  .page-title { font-size: 1.2rem; }
  .kpi { padding: 0.65rem 0.7rem; }
  .kpi-label { white-space: normal; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .card { padding: 0.75rem; min-width: 0; }
  .card-value { font-size: 1.3rem; overflow-wrap: normal; hyphens: auto; }
  .card-value#fraud-mode { font-size: 1.05rem; }
  .donut-wrap { height: 160px; }
  .pager { justify-content: space-between; }
  .pager-status { order: -1; flex-basis: 100%; text-align: left; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input, .inline-form select { flex: 1 1 100%; min-width: 0; width: 100%; }
  .copy-row { flex-wrap: wrap; }
  .copy-row input { flex: 1 1 100%; min-width: 0; }
  .modal-overlay { align-items: flex-end; }
  .modal-card { width: 100%; max-width: none; border-radius: 14px 14px 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
  .settings-nav { margin: 0 -0.75rem; padding: 0 0.75rem; scrollbar-width: none; }
}

/* Data tables become cards (one per row) on phones. */
@media (max-width: 640px) {
  table.rt, table.rt > tbody, table.rt > tbody > tr, table.rt > tbody > tr > td { display: block; width: 100%; }
  table.rt { border-collapse: separate; }
  table.rt > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  table.rt > tbody > tr {
    border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
    padding: 0.45rem 0.75rem; margin: 0 0 0.6rem;
  }
  table.rt > tbody > tr > td {
    border: 0; padding: 0.28rem 0; white-space: normal; overflow-wrap: anywhere; word-break: normal;
    display: grid; grid-template-columns: minmax(5.5rem, 36%) minmax(0, 1fr); gap: 0.65rem; align-items: start;
  }
  table.rt > tbody > tr > td::before {
    content: attr(data-label); color: var(--muted); font-size: 0.74rem; font-weight: 600; padding-top: 0.1rem;
  }
  table.rt > tbody > tr > td:not([data-label]) { display: block; }
  table.rt > tbody > tr > td:not([data-label])::before { content: none; }
  /* Empty cells add nothing to a card. */
  table.rt > tbody > tr > td[data-label]:empty { display: none; }
  table.rt > tbody > tr > td > * { min-width: 0; max-width: 100%; }
  table.rt > tbody > tr > td input, table.rt > tbody > tr > td select { width: 100%; }
  table.rt > tbody > tr > td button, table.rt > tbody > tr > td .action-btn { margin: 0 0.35rem 0.35rem 0; }
  .table-wrap > table.rt, .policy-table-wrap > table.rt { min-width: 0; }
}

/* Tablets: tables keep normal columns but never split an IP address or a
   date mid-word; a table too wide for the screen scrolls inside its box. */
@media (min-width: 641px) and (max-width: 1100px) {
  .table-wrap > table { width: max-content; min-width: 100%; }
  .table-wrap > table td { word-break: normal; overflow-wrap: normal; max-width: 18rem; }
  .table-wrap > table td button, .table-wrap > table td .action-btn { white-space: nowrap; }
}

/* Touch screens: controls big enough for a finger (about 40-44px). */
@media (pointer: coarse) {
  button, .tab-btn, .action-btn, .logout-link, .theme-toggle, select,
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]) { min-height: 40px; }
  .sidebar-nav .tab-btn { min-height: 44px; }
  .logout-link, .theme-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-sub { min-height: 40px; display: flex; align-items: center; }
  .sidebar-open { width: 2.75rem; height: 2.75rem; }
  .sidebar-collapse { width: 2.4rem; height: 2.4rem; }
  .pill.protection-pill { min-height: 36px; display: inline-flex; align-items: center; }
  .pager button { min-height: 40px; }
  .pager-size select { min-height: 36px; }
  input[type=checkbox], input[type=radio] { width: 1.2rem; height: 1.2rem; }
  /* Small text-style buttons and "i" icons keep their look but get a
     finger-sized invisible hit area. */
  .link-button, .info-btn { position: relative; min-height: 0; }
  .link-button::after, .info-btn::after { content: ""; position: absolute; inset: -12px -8px; }
  .link-button { padding: 0.35rem 0; }
  /* Hover-only menu "i" icons would never show on a touch screen. */
  .sidebar-nav .info-btn-tab { opacity: 0.55; }
  .info-btn-tab { opacity: 0.8; }
}
/* Drop-downs in inline forms match the text boxes beside them (they were
   the browser's grey default, which is hard to read on dark and on phones). */
.inline-form select {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  padding: 0.4rem 0.6rem; font-size: 0.85rem;
}
@media (max-width: 860px) { .inline-form select { font-size: 16px; } }

/* Platform admin: one client's billing (platform_billing.js) */
.client-billing-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.client-billing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.75rem; margin: 0.75rem 0 1rem; }
.card-value-sm { font-size: 0.95rem; font-weight: 600; margin-top: 0.25rem; line-height: 1.35; overflow-wrap: anywhere; }
.card-value-sm .hint { font-weight: 400; }
.client-billing-sub { font-size: 0.95rem; margin: 1.1rem 0 0.4rem; }
.client-billing-form { max-width: 520px; grid-template-columns: 1fr; }
.client-billing-form > .hint { margin: -0.3rem 0 0.2rem; }
.client-billing-form label.hidden { display: none; }
#client-billing-errors .banner { margin: 0.4rem 0; }

/* Audit trail tab (static/audit.js) */
.audit-filters { flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.audit-filters input[type="search"] { min-width: 14rem; }
.audit-export { margin-left: auto; display: inline-flex; gap: 12px; }
#audit-table .audit-target { max-width: 18rem; overflow-wrap: anywhere; }
#audit-table .audit-more { padding: 2px 10px; font-size: 0.85em; }
#audit-table tr.audit-detail td { background: var(--ds-unset-bg, rgba(127, 127, 127, 0.08)); }
.audit-detail-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85em; max-height: 22rem; overflow: auto; }

/* ============================================ Light mode design pass (2026-12-02) ===
   Dark mode is untouched: every rule here is scoped to data-theme="light".
   Colours below meet WCAG AA (4.5:1) for text on both white panels and the
   page background: muted 7.0:1, accent 5.5:1, green 5.3:1, amber 5.8:1,
   red 6.1:1 (checked against #f3f6fa). */
:root[data-theme="light"] {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --border: #d5dde7;
  --text: #0f172a;
  --muted: #475569;
  --red: #b42318;
  --green: #067647;
  --amber: #8a5300;
  --accent: #175cd3;
  --hover: #eef3fb;
  --active: #e3ecfb;
  --surface-2: #f8fafc;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);
}
:root[data-theme="light"] body { background: var(--bg); color: var(--text); }

/* Structure: white bars and cards that stand off the grey page. */
:root[data-theme="light"] .sidebar { background: #ffffff; border-right-color: var(--border); box-shadow: 1px 0 0 rgba(15, 23, 42, 0.02); }
:root[data-theme="light"] .app-main .topbar { background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(8px); border-bottom-color: var(--border); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
:root[data-theme="light"] .panel,
:root[data-theme="light"] .card,
:root[data-theme="light"] .kpi,
:root[data-theme="light"] .settings-nav,
:root[data-theme="light"] .model-grid .model-card { background: var(--panel); border-color: var(--border); box-shadow: var(--shadow-sm); }
:root[data-theme="light"] .model-grid .model-card { background: var(--surface-2); }
:root[data-theme="light"] .modal-card { box-shadow: var(--shadow-md); }

/* Type: real headings and heavy numbers. */
:root[data-theme="light"] .page-title { color: var(--text); font-weight: 700; }
:root[data-theme="light"] .panel h2 { color: var(--text); font-weight: 650; font-size: 1rem; }
:root[data-theme="light"] .panel h2 .hint { color: var(--muted); font-weight: 400; }
:root[data-theme="light"] .kpi-label, :root[data-theme="light"] .card-label { color: var(--muted); font-weight: 500; }
:root[data-theme="light"] .kpi-value, :root[data-theme="light"] .card-value { color: var(--text); font-weight: 750; letter-spacing: -0.01em; }
:root[data-theme="light"] .kpi-bad .kpi-value, :root[data-theme="light"] .kpi-bad .kpi-icon { color: var(--red); }
:root[data-theme="light"] .kpi-good .kpi-value, :root[data-theme="light"] .kpi-good .kpi-icon { color: var(--green); }
:root[data-theme="light"] .kpi-warn .kpi-value, :root[data-theme="light"] .kpi-warn .kpi-icon { color: var(--amber); }
:root[data-theme="light"] .kpi-icon { color: var(--muted); }
:root[data-theme="light"] .engine-top b { color: var(--text); }
:root[data-theme="light"] .hint, :root[data-theme="light"] .page-sub { color: var(--muted); }

/* Menu: clear group labels and an obvious current page. */
:root[data-theme="light"] .sidebar-label { color: #64748b; opacity: 1; }
:root[data-theme="light"] .sidebar-nav .tab-btn { color: #334155; font-weight: 500; }
:root[data-theme="light"] .sidebar-nav .tab-btn .nav-icon { color: #64748b; }
:root[data-theme="light"] .sidebar-nav .tab-btn:hover { background: var(--hover); color: var(--text); }
:root[data-theme="light"] .sidebar-nav .tab-btn.active {
  background: var(--active); color: #0b3d91; font-weight: 650; box-shadow: inset 3px 0 0 var(--accent);
}
:root[data-theme="light"] .sidebar-nav .tab-btn.active .nav-icon { color: var(--accent); }
:root[data-theme="light"] .nav-sub { color: #475569; }
:root[data-theme="light"] .nav-sub:hover { color: var(--accent); background: var(--hover); }
:root[data-theme="light"] .nav-sub.active { color: var(--accent); background: var(--active); }
:root[data-theme="light"] .nav-subs { border-left-color: #cbd5e1; }
:root[data-theme="light"] .sidebar-viewing .tenant-view-pill, :root[data-theme="light"] .sidebar-tenant { background: var(--surface-2); border-color: var(--border); }
:root[data-theme="light"] .sidebar-collapse, :root[data-theme="light"] .sidebar-open { color: #475569; border-color: var(--border); background: #fff; }
:root[data-theme="light"] .settings-nav-btn { color: #334155; }
:root[data-theme="light"] .settings-nav-btn.active { background: var(--active); color: #0b3d91; border-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
:root[data-theme="light"] .crumb-root { color: var(--muted); }
:root[data-theme="light"] .crumb-sep { color: #94a3b8; }

/* Links and small buttons that looked faint. */
:root[data-theme="light"] .link-button { color: var(--accent); font-weight: 600; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:root[data-theme="light"] .link-button:hover { color: #0b3d91; }
:root[data-theme="light"] .card-link, :root[data-theme="light"] .app-main main a:not(.download-link):not(.logout-link):not([class*="btn"]) { color: var(--accent); }
:root[data-theme="light"] .download-link:hover { color: #fff; }
:root[data-theme="light"] .info-btn { color: #64748b; border-color: #94a3b8; }
:root[data-theme="light"] .info-btn:hover, :root[data-theme="light"] .info-btn.open { color: var(--accent); border-color: var(--accent); }
:root[data-theme="light"] .logout-link, :root[data-theme="light"] .theme-toggle { color: #334155; background: #fff; border-color: var(--border); }
:root[data-theme="light"] .logout-link:hover, :root[data-theme="light"] .theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* Buttons and boxes that used dark-mode colours. */
:root[data-theme="light"] .tab-btn:hover, :root[data-theme="light"] .tab-btn.active { background: var(--active); }
:root[data-theme="light"] .action-btn:hover { background: var(--hover); }
:root[data-theme="light"] .inline-form button { background: #fff; color: var(--text); border-color: #b8c4d3; font-weight: 600; }
:root[data-theme="light"] .inline-form button:hover { background: var(--hover); border-color: var(--accent); color: var(--accent); }
:root[data-theme="light"] input:not([type=checkbox]):not([type=radio]):not([type=range]),
:root[data-theme="light"] select, :root[data-theme="light"] textarea { background-color: #fff; border-color: #b8c4d3; color: var(--text); }
:root[data-theme="light"] input::placeholder, :root[data-theme="light"] textarea::placeholder { color: #8391a5; }
:root[data-theme="light"] .sidebar-viewing select { background: transparent; }

/* Status: tinted pills instead of thin coloured outlines. */
:root[data-theme="light"] .protection-pill.protection-block, :root[data-theme="light"] .status-chip.status-block {
  color: var(--green); background: #ecfdf3; border-color: #abefc6;
}
:root[data-theme="light"] .protection-pill.protection-monitor, :root[data-theme="light"] .status-chip.status-monitor {
  color: var(--amber); background: #fffaeb; border-color: #fedf89;
}
:root[data-theme="light"] .pill { background: #fff; color: #334155; border-color: var(--border); }
:root[data-theme="light"] .role-badge { background: #fffaeb; border-color: #fedf89; }
:root[data-theme="light"] .nav-badge { color: var(--amber); background: #fffaeb; border-color: #fedf89; }

/* Tables: a header band and row separators you can see. */
:root[data-theme="light"] th { background: var(--surface-2); color: #334155; font-weight: 650; }
:root[data-theme="light"] th, :root[data-theme="light"] td { border-bottom-color: #e2e8f0; }
:root[data-theme="light"] tbody tr:hover > td { background: #f8fafc; }
:root[data-theme="light"] .bar-track { background: #e2e8f0; }
@media (max-width: 640px) {
  :root[data-theme="light"] table.rt > tbody > tr { background: #fff; border-color: var(--border); box-shadow: var(--shadow-sm); }
  :root[data-theme="light"] table.rt > tbody > tr > td { background: transparent; }
}
:root[data-theme="light"] .brand-mark { background: linear-gradient(90deg, #175cd3, #0e7c6b); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="light"] .brand-sub { color: #334155; }
/* Accent-filled buttons: white text reads 5.5:1 on the light-mode blue
   (the dark navy text used in dark mode is too dim on it). */
:root[data-theme="light"] .copy-row button, :root[data-theme="light"] #token-modal-close,
:root[data-theme="light"] .settings-form button:not(.secondary):not(.link-button):not(.action-btn),
:root[data-theme="light"] .auth-form button, :root[data-theme="light"] .landing-cta,
:root[data-theme="light"] .landing-plan-cta, :root[data-theme="light"] .landing-contact-form button,
:root[data-theme="light"] .auth-sso-link:hover { color: #fff; }
