/* ============================================================================
   GapSync — application console design system (ported per ADR-003).
   Themeable. LIGHT by default, DARK via :root[data-theme="dark"].
   Surfaces/lines/inks/glass are tokenized and flip between themes; semantic
   accents (emerald/amber/red/sky) stay constant. Status/severity semantic
   tokens live in tokens.css; GapSync component skeletons in components.css.
   ========================================================================== */

:root {
  /* ---------- LIGHT (default) ---------- */
  --bg-0:  #e9f2f8;
  --bg-1:  #eef6fb;
  --bg-2:  #f4fbff;
  --bg-stop: #f4fbff;
  --bg-grad-1: rgba(47, 157, 104, 0.14);
  --bg-grad-2: rgba(224, 168, 62, 0.16);

  --panel:       rgba(255, 255, 255, 0.94);
  --panel-2:     rgba(247, 251, 255, 0.97);
  --panel-3:     rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --glass-blur:  16px;

  --sidebar-grad: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 251, 255, 0.97));
  --topbar-bg:    rgba(255, 255, 255, 0.82);
  --hero-grad:    linear-gradient(140deg, rgba(255, 255, 255, 0.98), rgba(243, 251, 255, 0.95));
  --map-bg:       radial-gradient(1000px 720px at 50% 40%, #eef5f0 0%, #e2ebe6 82%);
  --overlay-strong:  rgba(255, 255, 255, 0.9);
  --overlay-stronger: rgba(255, 255, 255, 0.96);
  --toast-crit-bg:   rgba(253, 240, 239, 0.97);
  --thumb-bg:  #e8f0ec;
  --video-bg:  #05090a;            /* video letterbox: dark in BOTH themes */
  --video-scrim: rgba(4, 9, 6, 0.72);
  --input-bg:  #ffffff;
  --raise:       rgba(19, 33, 51, 0.045);
  --raise-hover: rgba(47, 157, 104, 0.09);
  --row-hover:   rgba(47, 157, 104, 0.07);
  --sink:        rgba(19, 33, 51, 0.1);
  --crest-inset: rgba(255, 255, 255, 0.35);
  --crest-shadow: 0 6px 16px rgba(13, 31, 52, 0.22);

  --line:      rgba(29, 57, 88, 0.14);
  --line-2:    rgba(29, 57, 88, 0.22);
  --border:    var(--line-2); /* theme-aware alias for legacy `var(--border,#e5e7eb)` usages */
  --line-soft: rgba(29, 57, 88, 0.08);

  --ink:     #132133;
  --ink-dim: #33475f;
  --muted:   rgba(37, 58, 83, 0.72);
  --faint:   #5c6b7d;

  --emerald:       #1f8a52;
  --emerald-2:     #0f7d49;
  --emerald-dim:   #0b6a3a;
  --emerald-bright:#2f9d68;
  --amber:  #9a6b0f;
  --gold:   #b8860b;
  --red:    #dc2626;
  --red-2:  #c0271f;
  --red-ink:#8a1f16;
  --sky:    #2166b8;
  --violet: #6d5cd6;
  --ink-on-accent: #ffffff;
  --link-hover: #0b6a3a;
  --selection: rgba(47, 157, 104, 0.18);

  --nav-on-ink: #0b3d28;
  --nav-on-bg:  linear-gradient(100deg, rgba(47, 157, 104, 0.18) 0%, rgba(47, 157, 104, 0.04) 100%);

  --glow-emerald: 0 0 10px rgba(47, 157, 104, 0.3);
  --glow-red:     0 0 10px rgba(220, 38, 38, 0.3);
  --shadow:    0 18px 34px rgba(13, 31, 52, 0.12);
  --shadow-sm: 0 10px 24px rgba(13, 31, 52, 0.1);
  --emerald-btn-shadow: 0 8px 20px rgba(11, 106, 58, 0.24);

  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --ease: 220ms cubic-bezier(0.22, 0.61, 0.36, 1);

  --sans:    'Plus Jakarta Sans', system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Sora', 'Plus Jakarta Sans', system-ui, sans-serif;
  --mono:    'DM Mono', ui-monospace, 'Cascadia Code', 'Consolas', monospace;
}

:root[data-theme="dark"] {
  /* ---------- DARK ---------- */
  --bg-0:  #05090a;
  --bg-1:  #081210;
  --bg-2:  #0b1a15;
  --bg-stop: #071410;
  --bg-grad-1: rgba(47, 157, 104, 0.16);
  --bg-grad-2: rgba(224, 168, 62, 0.10);

  --panel:       rgba(13, 26, 21, 0.72);
  --panel-2:     rgba(20, 36, 29, 0.66);
  --panel-3:     rgba(9, 18, 14, 0.85);
  --panel-solid: #0f1d18;

  --sidebar-grad: linear-gradient(180deg, rgba(11, 24, 19, 0.86), rgba(7, 15, 12, 0.9));
  --topbar-bg:    rgba(8, 16, 13, 0.7);
  --hero-grad:    linear-gradient(140deg, rgba(17, 32, 26, 0.9), rgba(10, 20, 16, 0.82));
  --map-bg:       radial-gradient(1000px 720px at 50% 40%, #0d1f18 0%, #060f0a 82%);
  --overlay-strong:   rgba(7, 15, 11, 0.82);
  --overlay-stronger: rgba(7, 15, 11, 0.94);
  --toast-crit-bg:    rgba(46, 12, 12, 0.95);
  --thumb-bg:  #070f0a;
  --input-bg:  rgba(0, 0, 0, 0.28);
  --raise:       rgba(255, 255, 255, 0.03);
  --raise-hover: rgba(255, 255, 255, 0.05);
  --row-hover:   rgba(47, 157, 104, 0.06);
  --sink:        rgba(0, 0, 0, 0.4);
  --crest-inset: rgba(255, 255, 255, 0.12);
  --crest-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);

  --line:      rgba(120, 190, 158, 0.14);
  --line-2:    rgba(120, 190, 158, 0.24);
  --line-soft: rgba(120, 190, 158, 0.08);

  --ink:     #e9f5ee;
  --ink-dim: #b3ccbf;
  --muted:   #7f9d8e;
  --faint:   #5f7a6c;

  --emerald:       #2f9d68;
  --emerald-2:     #38d08a;
  --emerald-dim:   #1f6f4a;
  --emerald-bright:#38d08a;
  --amber:  #e0a83e;
  --gold:   #d9a441;
  --red:    #f0564f;
  --red-2:  #ff7a72;
  --red-ink:#f7c2bf;
  --sky:    #4aa3e0;
  --violet: #9b8cff;
  --link-hover: #6fe6ac;
  --selection: rgba(56, 208, 138, 0.28);

  --nav-on-ink: #ffffff;
  --nav-on-bg:  linear-gradient(100deg, rgba(47, 157, 104, 0.28) 0%, rgba(47, 157, 104, 0.04) 100%);

  --glow-emerald: 0 0 16px rgba(56, 208, 138, 0.45);
  --glow-red:     0 0 16px rgba(240, 86, 79, 0.5);
  --shadow:    0 18px 44px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.3);
  --emerald-btn-shadow: 0 8px 20px rgba(31, 111, 74, 0.28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 82% -12%, var(--bg-grad-1) 0, transparent 60%),
    radial-gradient(900px 520px at 8% -20%, var(--bg-grad-2) 0, transparent 62%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 58%, var(--bg-stop) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 240ms ease, color 240ms ease;
}
a { color: var(--emerald-2); text-decoration: none; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 11px; }
::selection { background: var(--selection); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ============================================================================ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  background: linear-gradient(130deg, var(--emerald) 0%, var(--emerald-dim) 100%);
  color: var(--ink-on-accent) !important;
  font-family: var(--sans); font-weight: 700; font-size: 14px; letter-spacing: 0.01em; cursor: pointer;
  transition: transform var(--ease), box-shadow var(--ease), filter var(--ease);
  box-shadow: var(--emerald-btn-shadow);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn.ghost { background: var(--raise); color: var(--ink) !important; border-color: var(--line-2); box-shadow: none; }
.btn.ghost:hover { background: var(--raise-hover); border-color: var(--emerald); }
.btn.wide { width: 100%; }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.danger { background: linear-gradient(130deg, var(--red) 0%, #a5322d 100%); box-shadow: 0 8px 20px rgba(165, 50, 45, 0.28); }

/* Theme toggle */
.theme-toggle {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--raise);
  color: var(--ink-dim); cursor: pointer; transition: all var(--ease); padding: 0;
}
.theme-toggle:hover { border-color: var(--emerald); color: var(--emerald-2); background: var(--raise-hover); }
.theme-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }

/* ============================================================================ Pills / tags */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.02em; border: 1px solid var(--line-2); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.pill.up   { background: rgba(47, 157, 104, 0.14); color: var(--emerald-2); border-color: rgba(47, 157, 104, 0.4); }
.pill.down { background: rgba(240, 86, 79, 0.14);  color: var(--red-2);     border-color: rgba(240, 86, 79, 0.4); }
.pill.warn { background: rgba(224, 168, 62, 0.16); color: var(--amber);     border-color: rgba(224, 168, 62, 0.4); }
.tag { font-family: var(--mono); font-size: 11px; color: var(--amber); border: 1px solid rgba(224, 168, 62, 0.4);
  border-radius: 6px; padding: 1px 7px; background: rgba(224, 168, 62, 0.1); letter-spacing: 0.03em; }
.chip { display: inline-block; background: var(--raise); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 2px 11px; font-size: 12px; margin: 0 5px 5px 0; color: var(--ink-dim); }

/* ============================================================================ Console shell */
body.console { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; min-height: 100dvh; }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 16px;
  background: var(--sidebar-grad); border-right: 1px solid var(--line); backdrop-filter: blur(var(--glass-blur)); overflow: hidden; }

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 6px; }
.crest, .crest.sm { display: inline-grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(150deg, var(--emerald) 0%, #123a28 100%); border: 1px solid rgba(56, 208, 138, 0.4);
  color: #f4fff9; font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: 0.06em;
  box-shadow: inset 0 1px 0 var(--crest-inset), var(--crest-shadow); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 15px; letter-spacing: 0.02em; color: var(--ink); }
.brand-sub  { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; margin-top: 2px; }

.scope-pill { margin: 14px 6px 6px; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--line-2);
  background: rgba(47, 157, 104, 0.08); display: flex; align-items: center; gap: 9px; }
.scope-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald-bright); box-shadow: var(--glow-emerald); flex: 0 0 auto; }
.scope-copy { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.scope-copy strong { font-size: 12px; color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-copy span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; flex: 0 0 auto; }
/* The scroll region wraps the nav AND the operational-posture rail so both
   scroll together; only the brand (top) and the sign-out (bottom) stay fixed. */
.sidebar-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; padding-right: 4px; margin-right: -4px; }
.sidebar-rail { margin-top: auto; }   /* keep posture pinned near the bottom when content fits, scroll when it doesn't */
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.sidebar-scroll { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.sidebar-foot { flex: 0 0 auto; }
.nav-group { margin-bottom: 6px; }
.nav-group-title { padding: 6px 10px 5px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px;
  color: var(--ink-dim); font-size: 13.5px; font-weight: 500; position: relative;
  transition: background var(--ease), color var(--ease), transform var(--ease); }
.nav-item:hover { background: var(--raise-hover); color: var(--ink); text-decoration: none; transform: translateX(2px); }
.nav-item.on { background: var(--nav-on-bg); color: var(--nav-on-ink); font-weight: 700; }
.nav-item.on::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--emerald-bright); box-shadow: var(--glow-emerald); }
.nav-ico { width: 20px; height: 20px; flex: 0 0 auto; display: grid; place-items: center; color: var(--emerald-2); }
.nav-ico svg { width: 18px; height: 18px; fill: currentColor; }
.nav-item:not(.on) .nav-ico { color: var(--muted); }
.nav-item .nav-badge { margin-left: auto; font-family: var(--mono); font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: rgba(240, 86, 79, 0.18); color: var(--red-2); border: 1px solid rgba(240, 86, 79, 0.4); }

.posture-rail { margin: 16px 6px 0; padding: 13px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); }
.posture-rail .rail-title { margin: 0 0 10px; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.rail-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.rail-item:last-child { margin-bottom: 0; }
.rail-item span { color: var(--muted); }
.rail-item strong { color: var(--emerald-2); font-family: var(--mono); font-weight: 500; font-size: 12px; }
.rail-item strong.warn { color: var(--amber); }
.rail-item strong.crit { color: var(--red-2); }

.sidebar-foot { margin-top: 14px; padding: 0 6px; }
.sidebar-logout { margin-top: 12px; }
.sidebar-logout button { width: 100%; height: 40px; border-radius: 11px; border: 1px solid rgba(240, 86, 79, 0.34);
  background: rgba(240, 86, 79, 0.08); color: var(--red-ink); font-family: var(--sans); font-size: 13px; font-weight: 700; cursor: pointer; transition: all var(--ease); }
.sidebar-logout button:hover { background: rgba(240, 86, 79, 0.16); border-color: rgba(240, 86, 79, 0.5); }
.site-badge { display: inline-block; font-family: var(--mono); font-size: 10.5px; color: var(--amber);
  border: 1px solid rgba(224, 168, 62, 0.4); border-radius: 6px; padding: 1px 8px; margin-bottom: 5px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: env(safe-area-inset-top) 26px 0; height: calc(66px + env(safe-area-inset-top)); background: var(--topbar-bg); border-bottom: 1px solid var(--line); backdrop-filter: blur(var(--glass-blur)); }
.page-heading { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.page-title { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.live-indicator { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid rgba(47, 157, 104, 0.4); background: rgba(47, 157, 104, 0.1); font-size: 12px; color: var(--ink-dim); }
.live-indicator::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--emerald-bright); box-shadow: var(--glow-emerald); animation: livePulse 2.4s ease-in-out infinite; }
.live-indicator.offline { border-color: rgba(240, 86, 79, 0.4); background: rgba(240, 86, 79, 0.1); }
.live-indicator.offline::before { background: var(--red); box-shadow: var(--glow-red); animation: none; }
.clock { color: var(--ink-dim); font-family: var(--mono); font-size: 13px; letter-spacing: 0.03em; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.who-name { font-size: 13px; font-weight: 600; }
.who-role { font-size: 10.5px; color: var(--amber); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.drawer-id { display: none; flex-direction: column; gap: 2px; padding: 4px 6px 12px; }
.drawer-id .who-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.drawer-id .who-role { font-size: 10.5px; color: var(--amber); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.content { padding: 26px; }
.content > * { animation: liftIn 520ms var(--ease) both; }

@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes liftIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .content > *, .reveal { animation: none !important; transition: none !important; } }

/* ============================================================================ Hero panel */
.hero-panel { position: relative; overflow: hidden; display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px;
  padding: 24px; margin-bottom: 22px; border-radius: var(--radius-xl); border: 1px solid rgba(224, 168, 62, 0.3);
  background: radial-gradient(600px 300px at 100% 0%, rgba(47, 157, 104, 0.12), transparent 70%), var(--hero-grad); box-shadow: var(--shadow-sm); }
.hero-panel::after { content: ''; position: absolute; right: -110px; bottom: -130px; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 208, 138, 0.12), transparent 70%); pointer-events: none; }
.hero-eyebrow { margin: 0; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--amber); font-weight: 700; }
.hero-panel h1, .hero-panel h2 { margin: 10px 0 8px; font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.12; text-wrap: balance; color: var(--ink); }
.hero-copy { margin: 0; color: var(--ink-dim); max-width: 62ch; line-height: 1.6; }
.hero-chipset { display: grid; gap: 10px; align-content: center; }
.hero-chip { border-radius: 13px; border: 1px solid var(--line-2); padding: 11px 13px; background: var(--raise); }
.hero-chip span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.hero-chip strong { display: block; margin-top: 5px; font-size: 15px; color: var(--ink); font-family: var(--mono); }

/* ============================================================================ Cards & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px;
  backdrop-filter: blur(calc(var(--glass-blur) - 4px)); box-shadow: var(--shadow-sm);
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease); }
.card:hover { border-color: var(--line-2); }
.card-h { font-size: 14px; margin: 0 0 16px; color: var(--ink); font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-h::before { content: ''; width: 3px; height: 14px; border-radius: 2px; background: linear-gradient(var(--emerald-2), var(--emerald-dim)); }
.card-h .h-meta { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--muted); font-family: var(--mono); }
.grid-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-cards.six { grid-template-columns: repeat(6, 1fr); }
.section-head { margin: 0 0 4px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 18px; }

.card.stat { position: relative; overflow: hidden; text-align: left; border-top: 3px solid rgba(47, 157, 104, 0.5); }
.card.stat::after { content: ''; position: absolute; right: -32px; top: -32px; width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 208, 138, 0.12), transparent 70%); pointer-events: none; }
.stat-num { font-family: var(--mono); font-weight: 500; font-size: clamp(1.5rem, 1rem + 1.6vw, 2rem); font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em; line-height: 1.1; color: var(--ink); }
.stat-num.amber { color: var(--amber); }
.stat-num.green { color: var(--emerald-2); }
.stat-num.red   { color: var(--red-2); }
.stat-num.sky   { color: var(--sky); }
.stat-label { color: var(--muted); font-size: 11.5px; margin-top: 8px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-foot { margin-top: 10px; font-size: 12px; color: var(--ink-dim); }
.card.stat { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 13h4v8H3zM10 9h4v12h-4zM17 5h4v16h-4z'/%3E%3C/svg%3E"); --stat-tint: rgba(47,157,104,0.9); --stat-bg: rgba(47,157,104,0.14); }
.card.stat > .stat-badge { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 10px; background: var(--stat-bg); display: grid; place-items: center; z-index: 1; }
.card.stat > .stat-badge::before { content: ''; width: 18px; height: 18px; background: var(--stat-tint); -webkit-mask: var(--stat-ico) no-repeat center / contain; mask: var(--stat-ico) no-repeat center / contain; }
.stat-drones     { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h5v5l-2.5 2.5L12 12l.5-.5L15 9V4h5v5l-3.5 3.5L15 14l-2 2-2-2-1.5-1.5L4 9V4Zm3 12h10v2H7v-2Zm4 3h2v2h-2v-2Z'/%3E%3C/svg%3E"); --stat-tint: rgba(31,138,82,0.95); --stat-bg: rgba(47,157,104,0.14); border-top-color: rgba(47,157,104,0.5); }
.stat-incidents  { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 1 21h22L12 2Zm0 5 7.5 13h-15L12 7Zm-1 4h2v4h-2v-4Zm0 6h2v2h-2v-2Z'/%3E%3C/svg%3E"); --stat-tint: rgba(154,107,15,0.95); --stat-bg: rgba(224,168,62,0.16); border-top-color: rgba(224,168,62,0.5); }
.stat-detections { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5C5 5 1 12 1 12s4 7 11 7 11-7 11-7-4-7-11-7Zm0 12a5 5 0 1 1 0-10 5 5 0 0 1 0 10Zm0-2.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z'/%3E%3C/svg%3E"); --stat-tint: rgba(192,39,31,0.9); --stat-bg: rgba(240,86,79,0.12); border-top-color: rgba(240,86,79,0.45); }
.stat-coverage   { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5 7 13 7 13s7-8 7-13a7 7 0 0 0-7-7Zm0 9.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5Z'/%3E%3C/svg%3E"); --stat-tint: rgba(47,127,208,0.9); --stat-bg: rgba(47,127,208,0.12); border-top-color: rgba(47,127,208,0.45); }
.stat-link       { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3C7 3 2.7 5 0 8l2 2c2.2-2.4 6-4 10-4s7.8 1.6 10 4l2-2C21.3 5 17 3 12 3Zm0 6c-3 0-5.7 1.2-7.6 3.2l2 2C7.7 12.9 9.7 12 12 12s4.3.9 5.6 2.2l2-2C17.7 10.2 15 9 12 9Zm0 6c-1.4 0-2.6.6-3.5 1.5L12 20l3.5-3.5C14.6 15.6 13.4 15 12 15Z'/%3E%3C/svg%3E"); --stat-tint: rgba(31,138,82,0.95); --stat-bg: rgba(47,157,104,0.14); border-top-color: rgba(47,157,104,0.5); }
.stat-status     { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.7 8 11 4.6-1.3 8-6 8-11V5l-8-3Zm-1.2 13L7 11.2l1.4-1.4 2.4 2.4 4.8-4.8L17 8.8 10.8 15Z'/%3E%3C/svg%3E"); --stat-tint: rgba(154,107,15,0.95); --stat-bg: rgba(224,168,62,0.16); border-top-color: rgba(224,168,62,0.5); }
.stat-users      { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm7 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm-7 2c-3 0-7 1.5-7 4.2V20h11v-2.8C13 15.5 12 13 9 13Zm7 .3c.9.8 1.5 1.9 1.5 3.9V20H22v-2.5c0-2.4-3.2-4-6-4.2Z'/%3E%3C/svg%3E"); --stat-tint: rgba(47,127,208,0.9); --stat-bg: rgba(47,127,208,0.12); border-top-color: rgba(47,127,208,0.45); }
.stat-audit      { --stat-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h9l5 5v15H6V2Zm8 1.5V8h4.5L14 3.5ZM8 12h8v1.6H8V12Zm0 4h8v1.6H8V16Zm0-8h4v1.6H8V8Z'/%3E%3C/svg%3E"); --stat-tint: rgba(109,92,214,0.9); --stat-bg: rgba(109,92,214,0.12); border-top-color: rgba(109,92,214,0.45); }

.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 14px 8px 0; vertical-align: top; width: 96px; font-size: 13px; }
.kv td { padding: 8px 0; font-size: 14px; }

.perms { margin-top: 14px; }
.perms summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.perms summary:hover { color: var(--ink); }
.perm-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.perm { background: var(--raise); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 11px; color: var(--muted); font-family: var(--mono); }

.milestones { list-style: none; margin: 0; padding: 0; }
.milestones li { padding: 8px 0 8px 26px; position: relative; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line-soft); }
.milestones li:last-child { border-bottom: 0; }
.milestones li::before { content: '○'; position: absolute; left: 2px; color: var(--line-2); }
.milestones li.done { color: var(--ink-dim); }
.milestones li.done::before { content: '●'; color: var(--emerald-2); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line-2);
  position: sticky; top: 0; background: var(--panel-solid); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
table.data tr:hover td { background: var(--row-hover); }
table.data td.mono, table.data .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ============================================================================ Enterprise dashboard components */
/* Posture band */
.posture-band { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.posture-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; border: 1px solid; }
.posture-badge::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.posture-badge.ok   { color: var(--emerald-2); border-color: rgba(47,157,104,0.4); background: rgba(47,157,104,0.1); }
.posture-badge.warn { color: var(--amber);     border-color: rgba(224,168,62,0.4); background: rgba(224,168,62,0.12); }
.posture-badge.crit { color: var(--red-2);      border-color: rgba(240,86,79,0.45); background: rgba(240,86,79,0.12); }

/* Horizontal bar chart rows */
.bars { display: grid; gap: 11px; margin-top: 4px; }
.bar-row { display: grid; grid-template-columns: 116px 1fr auto; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-row .bl { color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.bar-track { height: 9px; background: var(--sink); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--emerald), var(--emerald-bright)); min-width: 2px; transition: width var(--ease); }
.bar-fill.amber { background: linear-gradient(90deg, #b9791a, var(--amber)); }
.bar-fill.red   { background: linear-gradient(90deg, #a5322d, var(--red)); }
.bar-fill.sky   { background: linear-gradient(90deg, #2565b0, var(--sky)); }
.bar-fill.violet{ background: linear-gradient(90deg, #4b3bb0, var(--violet)); }
.bar-fill.muted { background: linear-gradient(90deg, var(--faint), var(--muted)); }
.bar-row .bv { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); font-size: 12px; min-width: 26px; text-align: right; }

/* Donut (conic) */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { --p: 0; --c: var(--emerald); width: 108px; height: 108px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--sink) 0); display: grid; place-items: center; position: relative; }
.donut::before { content: ''; position: absolute; inset: 13px; border-radius: 50%; background: var(--panel); }
.donut .donut-c { position: relative; text-align: center; line-height: 1.1; }
.donut .donut-c b { display: block; font-family: var(--mono); font-size: 20px; color: var(--ink); }
.donut .donut-c span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.legend { display: grid; gap: 8px; font-size: 12.5px; }
.legend .lg-row { display: flex; align-items: center; gap: 8px; color: var(--ink-dim); }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.legend .lg-v { margin-left: auto; font-family: var(--mono); color: var(--ink); }

/* Gauge ring (e.g., MFA %) */
.gauge { --p: 0; --c: var(--emerald); width: 92px; height: 92px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 3.6deg), var(--sink) 0); display: grid; place-items: center; position: relative; }
.gauge::before { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: var(--panel); }
.gauge b { position: relative; font-family: var(--mono); font-size: 18px; color: var(--ink); }

/* Segmented funnel bar */
.funnel { display: flex; height: 14px; border-radius: 8px; overflow: hidden; margin: 10px 0; border: 1px solid var(--line); }
.funnel span { display: block; height: 100%; }
.funnel .f-pending  { background: rgba(224,168,62,0.6); }
.funnel .f-verified { background: var(--emerald); }
.funnel .f-dismissed{ background: var(--sink); }
.funnel-key { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.funnel-key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* Compact metric rows */
.metrics { display: grid; gap: 0; }
.metric { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.metric:last-child { border-bottom: 0; }
.metric .m-l { color: var(--muted); }
.metric .m-v { font-family: var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.metric .m-v.green { color: var(--emerald-2); } .metric .m-v.amber { color: var(--amber); } .metric .m-v.red { color: var(--red-2); }

/* Activity feed */
.feed { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; max-height: 340px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.feed li:last-child { border-bottom: 0; }
.feed .f-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--emerald-bright); }
.feed .f-dot.amber { background: var(--amber); } .feed .f-dot.red { background: var(--red); } .feed .f-dot.sky { background: var(--sky); }
.feed .f-body { min-width: 0; }
.feed .f-act { color: var(--ink); font-weight: 600; }
.feed .f-meta { color: var(--muted); display: block; margin-top: 1px; }
.feed .f-time { color: var(--faint); font-family: var(--mono); font-size: 11px; white-space: nowrap; }

/* Integrity / status tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--panel-2); }
.tile .t-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .t-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.tile .t-v { font-family: var(--mono); font-size: 18px; color: var(--ink); margin-top: 6px; }
.tile .t-s { font-size: 11.5px; margin-top: 4px; color: var(--ink-dim); }
.badge-ok { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(47,157,104,0.14); color: var(--emerald-2); border: 1px solid rgba(47,157,104,0.4); text-transform: uppercase; letter-spacing: 0.04em; }
.badge-warn { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(224,168,62,0.16); color: var(--amber); border: 1px solid rgba(224,168,62,0.4); text-transform: uppercase; letter-spacing: 0.04em; }
.badge-crit { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(240,86,79,0.14); color: var(--red-2); border: 1px solid rgba(240,86,79,0.45); text-transform: uppercase; letter-spacing: 0.04em; }

/* ============================================================================ Live map */
.content:has(.map-wrap) { padding: 0; }
.map-wrap { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 66px); }
.map-stage { position: relative; overflow: hidden; background: var(--map-bg); }
#map-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.map-hud { position: absolute; top: 16px; left: 16px; background: var(--overlay-strong); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 12px 14px; backdrop-filter: blur(6px); box-shadow: var(--shadow-sm); }
.hud-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 13px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 8px currentColor; }
.conn-dot.online { background: var(--emerald-bright); color: var(--emerald-bright); }
.conn-dot.connecting { background: var(--amber); color: var(--amber); }
.conn-dot.offline { background: var(--red); color: var(--red); }
.map-legend { position: absolute; bottom: 16px; left: 16px; display: flex; gap: 16px; align-items: center; background: var(--overlay-strong);
  border: 1px solid var(--line-2); border-radius: 12px; padding: 8px 14px; backdrop-filter: blur(6px); font-size: 12px; }
.map-legend i.lg { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.lg.ok { background: var(--emerald-bright); } .lg.warn { background: var(--red); } .lg.site { background: var(--amber); }
.lg.nofly { background: transparent; border: 1px solid var(--red); }

.track-panel { border-left: 1px solid var(--line); background: var(--panel-3); display: flex; flex-direction: column; min-height: 0; backdrop-filter: blur(var(--glass-blur)); }
.track-head { display: flex; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.track-list { overflow-y: auto; flex: 1; padding: 10px; }
.track-empty { text-align: center; padding: 44px 12px; font-size: 13px; color: var(--muted); }
.track { padding: 11px 13px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; margin-bottom: 6px; transition: background var(--ease), border-color var(--ease); }
.track:hover { background: var(--panel-2); }
.track.on { background: var(--panel-2); border-color: var(--emerald); }
.track-top { display: flex; justify-content: space-between; align-items: center; }
.track-id { font-weight: 600; font-size: 13px; font-family: var(--mono); }
.track-mode { font-size: 11px; color: var(--amber); font-family: var(--mono); }
.track-bar { height: 5px; background: var(--sink); border-radius: 3px; margin: 8px 0 5px; overflow: hidden; }
.track-fill { display: block; height: 100%; background: var(--emerald-bright); }
.track-fill.low { background: var(--red); }
.track-fill.breach { background: var(--red); }
.track-meta { color: var(--muted); font-size: 12px; }
.track.breach { border-color: var(--red); }
.track-cmd, .cmd-bar { border-top: 1px solid var(--line); padding: 14px 16px; }
.brk { color: var(--red); }
.cmd-sel { margin-bottom: 8px; }
.cmd-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.cbtn { background: var(--raise); border: 1px solid var(--line-2); color: var(--ink); border-radius: 9px; padding: 9px; font-size: 13px; font-family: var(--mono); cursor: pointer; transition: all var(--ease); }
.cbtn:hover:not(:disabled) { background: var(--emerald); border-color: var(--emerald-2); color: var(--ink-on-accent); }
.cbtn.goto:hover:not(:disabled) { background: var(--sky); border-color: var(--sky); color: #fff; }
.cbtn.danger:hover:not(:disabled) { background: var(--red); border-color: var(--red); color: #fff; }
.cbtn.ok:hover:not(:disabled) { background: var(--emerald); border-color: var(--emerald-2); color: var(--ink-on-accent); }
.cbtn:disabled { opacity: 0.4; cursor: not-allowed; }
.goto-hint { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: rgba(74, 163, 224, 0.16);
  border: 1px solid var(--sky); color: var(--ink); padding: 9px 18px; border-radius: 10px; font-size: 13px; backdrop-filter: blur(4px); }
.goto-hint.hidden { display: none; }

.toasts { position: absolute; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; z-index: 20; }
.toast { max-width: 340px; padding: 11px 15px; border-radius: 11px; font-size: 13px; border: 1px solid var(--line-2);
  background: var(--overlay-stronger); color: var(--ink); opacity: 0; transform: translateY(8px); transition: 0.25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.crit { border-color: var(--red); background: var(--toast-crit-bg); }
.toast.ok { border-color: var(--emerald); }
.toast.info { border-color: var(--sky); }

/* ============================================================================ Detections */
.det-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.det-tabs { display: flex; gap: 7px; }
.det-tab { padding: 8px 15px; border-radius: 10px; border: 1px solid var(--line-2); color: var(--muted); font-size: 13px; transition: all var(--ease); }
.det-tab:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.det-tab.on { background: linear-gradient(130deg, var(--emerald), var(--emerald-dim)); color: var(--ink-on-accent); border-color: var(--emerald-2); }
.det-tab .cnt { font-family: var(--mono); font-size: 11px; opacity: 0.85; margin-left: 5px; }
.det-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.det-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform var(--ease), border-color var(--ease); }
.det-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.det-card.status-verified { border-color: var(--emerald); }
.det-card.status-dismissed { opacity: 0.55; }
.det-thumb { position: relative; height: 156px; background: var(--thumb-bg); display: grid; place-items: center; }
.det-thumb img { width: 100%; height: 100%; object-fit: cover; }
.det-noimg { color: var(--muted); font-size: 12px; }
.det-conf { position: absolute; top: 9px; right: 9px; font-family: var(--mono); font-size: 12px; padding: 2px 9px; border-radius: 7px; background: var(--overlay-strong); border: 1px solid var(--line); }
.det-conf.high { color: #fff; background: var(--red); border-color: var(--red); } .det-conf.mid { color: var(--amber); } .det-conf.low { color: var(--muted); }
.det-hi { position: absolute; top: 9px; left: 9px; font-family: var(--mono); font-size: 10px; background: var(--red); color: #fff; padding: 2px 7px; border-radius: 6px; box-shadow: var(--glow-red); }
.det-body { padding: 14px; }
.det-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.det-type { font-family: var(--mono); font-size: 11px; padding: 2px 9px; border-radius: 6px; background: var(--raise); border: 1px solid var(--line-2); }
.det-type.type-weapon { color: var(--red); border-color: rgba(240, 86, 79, 0.5); }
.det-type.type-face { color: var(--sky); border-color: rgba(74, 163, 224, 0.5); }
.det-status { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.det-label { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.det-meta { color: var(--muted); font-size: 12px; }
.det-ts { margin-top: 2px; }
.det-actions { display: flex; gap: 8px; margin-top: 14px; }
.det-actions .cbtn { flex: 1; }

/* ============================================================================ Incidents */
.inc-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 18px; }
.inc-list-col { display: flex; flex-direction: column; }
.inc-list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 700; }
.inc-new { display: flex; flex-direction: column; gap: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.inc-new.hidden { display: none; }
.inc-new select, .inc-new input, .inc-new textarea { background: var(--input-bg); border: 1px solid var(--line-2); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; }
.inc-new .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.inc-list { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; }
.inc-row { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; transition: background var(--ease), border-color var(--ease); }
.inc-row:hover { background: var(--panel-2); text-decoration: none; }
.inc-row.on { border-color: var(--emerald-2); }
.inc-row-top { display: flex; justify-content: space-between; align-items: center; }
.inc-ref { font-size: 12px; color: var(--ink); font-family: var(--mono); }
.inc-row-mid { font-size: 14px; text-transform: capitalize; margin: 4px 0; }
.sev { font-family: var(--mono); font-size: 10px; text-transform: uppercase; padding: 1px 8px; border-radius: 6px; }
.sev.cr { background: var(--red); color: #fff; box-shadow: var(--glow-red); } .sev.hi { color: var(--red); border: 1px solid var(--red); }
.sev.md { color: var(--amber); border: 1px solid var(--line-2); } .sev.lo { color: var(--muted); border: 1px solid var(--line-2); }
.inc-status { font-family: var(--mono); font-size: 11px; padding: 1px 9px; border-radius: 6px; background: var(--raise); border: 1px solid var(--line-2); text-transform: capitalize; }
.inc-status.s-assigned, .inc-status.s-enroute { color: var(--amber); }
.inc-status.s-onscene { color: var(--sky); }
.inc-status.s-resolved, .inc-status.s-closed { color: var(--emerald-2); }
.inc-detail-head { display: flex; justify-content: space-between; align-items: flex-start; }
.inc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 9px 0 9px 22px; border-left: 2px solid var(--line-2); margin-left: 4px; }
.tl-dot { position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--emerald-bright); box-shadow: var(--glow-emerald); }
.tl-type { font-weight: 600; font-size: 13px; text-transform: capitalize; margin-right: 8px; }
.tl-ts { display: block; color: var(--muted); font-size: 12px; }
.sos-card { width: min(440px, 94vw); }
.sos-loc { margin: -4px 0 2px; }

/* ============================================================================ Video wall */
.vw-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.video-wall { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.vtile { position: relative; aspect-ratio: 16/9; background: var(--video-bg); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; }
.vtile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.vtile-off { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: #8fae9f; }
.vtile.is-live .vtile-off { display: none; }
.vtile-hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(var(--video-scrim), transparent); padding: 5px 9px; border-radius: 8px; font-size: 13px; color: #eef5f1; }
.vt-dot { width: 8px; height: 8px; border-radius: 50%; background: #8fae9f; }
.vt-dot.on { background: var(--emerald-bright); box-shadow: var(--glow-emerald); }
.vtile-ctl { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transition: 0.2s; }
.vtile:hover .vtile-ctl { opacity: 1; }
.vtile-ctl .cbtn { padding: 6px 10px; }
.vt-flash { position: absolute; bottom: 10px; left: 10px; background: var(--overlay-stronger); border: 1px solid var(--emerald); color: var(--ink);
  padding: 6px 11px; border-radius: 8px; font-size: 12px; opacity: 0; transition: 0.2s; }
.vt-flash.show { opacity: 1; }

/* ============================================================================ Federation / coverage */
.state-grid { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.state-chip { font-size: 12px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); transition: all var(--ease); }
.state-chip.on { border-color: var(--emerald-2); color: var(--emerald-2); background: rgba(47, 157, 104, 0.12); }

/* ============================================================================ Auth fallback + public SOS card (real login uses auth.css) */
.auth-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.auth-card, .sos-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-sm); backdrop-filter: blur(12px); }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h1 { font-size: 20px; margin: 12px 0 4px; }
.auth-head .crest { margin-bottom: 6px; }
.auth-foot { text-align: center; margin: 16px 0 0; font-size: 12px; color: var(--muted); }
/* SOS emergency crest must read RED (the .crest default is emerald) */
.sos-card .crest { background: linear-gradient(150deg, var(--red) 0%, #7f1d1d 100%); border-color: rgba(240, 86, 79, 0.5); color: #fff; box-shadow: 0 6px 16px rgba(220, 38, 38, 0.28); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }
.auth-form input, .auth-form select, .auth-form textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--line-2); color: var(--ink); border-radius: 9px; padding: 12px 13px; font-size: 16px; font-family: inherit; transition: border-color var(--ease), box-shadow var(--ease); }
.auth-form textarea { min-height: 96px; line-height: 1.5; resize: vertical; }
.auth-form select { -webkit-appearance: none; appearance: none; padding-right: 38px; background-repeat: no-repeat; background-position: right 14px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2333475f' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); }
.auth-form input:focus, .auth-form select:focus, .auth-form textarea:focus { outline: none; border-color: var(--emerald-2); box-shadow: 0 0 0 3px rgba(47, 157, 104, 0.16); }
.auth-form input.otp { letter-spacing: 8px; text-align: center; font-family: var(--mono); font-size: 22px; }
.sos-card .btn.wide { padding: 15px 18px; font-size: 16px; min-height: 52px; border-radius: 12px;
  background: linear-gradient(130deg, var(--red) 0%, #a5322d 100%); border-color: transparent; box-shadow: 0 8px 20px rgba(165, 50, 45, 0.28); color: #fff !important; }
.alert.error { background: rgba(240, 86, 79, 0.12); border: 1px solid var(--red); color: var(--red-ink); padding: 10px 13px; border-radius: 9px; font-size: 13px; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 13px; }
.inline { display: inline; }
.inline-center { display: block; text-align: center; margin-top: 12px; }

/* ============================================================================ Responsive */
@media (max-width: 1200px) {
  .grid-cards.six { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  body.console { grid-template-columns: 72px 1fr; }
  .brand-txt, .brand-sub, .scope-copy, .nav-group-title, .posture-rail, .nav-label { display: none; }
  .sidebar { padding: 18px 8px; align-items: center; }
  .scope-pill { justify-content: center; padding: 8px; }
  .nav-item { justify-content: center; padding: 11px 8px; }
  .nav-item.on::before { top: 6px; bottom: 6px; }
  .sidebar-logout button { font-size: 0; height: 40px; }
  .grid-cards, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .hero-panel { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-cards.six { grid-template-columns: repeat(2, 1fr); }
  .map-wrap { grid-template-columns: 1fr; height: auto; }
  .map-stage { height: 56vh; } .track-panel { border-left: none; border-top: 1px solid var(--line); }
  .inc-wrap { grid-template-columns: 1fr; }
  .video-wall { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
}
/* Mobile nav chrome — hidden on desktop, shown as drawer + bottom tabs on phones. */
.menu-toggle, .tabbar { display: none; }
.nav-scrim, .nav-scrim[hidden] { display: none; }

@media (max-width: 640px) {
  body.console { grid-template-columns: 1fr; }
  body.console.nav-open { overflow: hidden; }                       /* scroll-lock behind the drawer */
  .menu-toggle { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; margin-right: 2px;
    border: 1px solid var(--line-2); background: var(--raise); color: var(--ink-dim); cursor: pointer; padding: 0; }
  .menu-toggle svg { width: 20px; height: 20px; fill: currentColor; }
  .theme-toggle { width: 42px; height: 42px; }

  /* Topbar: hamburger + truncating title + toggle + a bare live dot */
  .page-heading { min-width: 0; flex: 1 1 auto; }
  .page-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
  .page-sub { display: none; }
  .topbar { padding: env(safe-area-inset-top) 14px 0; }
  .topbar-right { gap: 8px; flex: 0 0 auto; }
  .clock, .who { display: none; }
  .live-indicator { padding: 0; width: 14px; height: 14px; border: 0; background: transparent; font-size: 0; gap: 0; overflow: hidden; border-radius: 50%; }
  .live-indicator::before { margin: 0; width: 11px; height: 11px; }

  /* Off-canvas drawer sidebar (identity + logout restored) */
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 320px; height: 100vh; height: 100dvh; z-index: 60;
    flex-direction: column; align-items: stretch; overflow-y: auto;
    padding: calc(20px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
    transform: translateX(-100%); transition: transform 0.24s ease; box-shadow: 0 0 44px rgba(6, 20, 35, 0.4); }
  body.console.nav-open .sidebar { transform: translateX(0); }
  body.console.nav-open .brand-txt { display: flex; }
  body.console.nav-open .brand-sub { display: block; }
  body.console.nav-open .scope-copy { display: flex; }
  body.console.nav-open .nav-label { display: block; }
  body.console.nav-open .nav-group-title { display: block; }
  body.console.nav-open .posture-rail { display: block; }
  body.console.nav-open .nav-item { justify-content: flex-start; padding: 12px 12px; }
  body.console.nav-open .sidebar-logout button { font-size: 13px; }
  .drawer-id { display: flex; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(6, 20, 35, 0.5); backdrop-filter: blur(2px); }
  .nav-scrim[hidden] { display: none; }

  /* Bottom tab bar — equal-width columns */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--topbar-bg); backdrop-filter: blur(var(--glass-blur)); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { display: grid; place-items: center; gap: 3px; padding: 8px 0; min-height: 48px; font-size: 10.5px;
    color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: none; font-family: var(--sans); min-width: 0; }
  .tabbar a svg, .tabbar button svg { width: 21px; height: 21px; fill: currentColor; }
  .tabbar a.on { color: var(--emerald-2); }
  .tabbar span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* Content density + safe-area */
  .content { padding: 16px calc(16px + env(safe-area-inset-right)) calc(76px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .card { padding: 16px; }
  .hero-panel { padding: 18px; gap: 14px; margin-bottom: 16px; }
  .hero-panel h1, .hero-panel h2 { font-size: 1.35rem; }
  .hero-chipset { grid-template-columns: 1fr 1fr; }
  .grid-cards, .grid-cards.six { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .bar-row { grid-template-columns: 92px 1fr auto; }

  /* 16px inputs (kill iOS zoom) + touch targets */
  .field input, .field select, .field textarea, .inc-new input, .inc-new select, .inc-new textarea { font-size: 16px; }
  .field input, .field select, .field textarea { padding: 12px 13px; }
  .btn.sm { padding: 11px 16px; min-height: 44px; }
  label.check { min-height: 44px; }

  /* Detection filter tabs → horizontal scroll strip */
  .det-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .det-tabs::-webkit-scrollbar { display: none; }
  .det-tab { white-space: nowrap; flex: 0 0 auto; }

  /* Report filters + form actions full-width; headline 2-up */
  .report-filters { gap: 12px; }
  .report-filters .field { flex: 1 1 100%; }
  .report-filters .form-actions { flex: 1 1 100%; }
  .report-headline { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
  .rh-item b { font-size: 1.3rem; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .form-actions label.check { justify-content: flex-start; }

  /* Responsive tables: (.stack) label/value cards, (.pin) sticky first column */
  .table-wrap.stack table.data, .table-wrap.stack tbody, .table-wrap.stack tr, .table-wrap.stack td { display: block; width: 100%; }
  .table-wrap.stack thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .table-wrap.stack tr { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: 4px 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
  .table-wrap.stack td { display: flex; gap: 16px; justify-content: space-between; align-items: baseline; text-align: right; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
  .table-wrap.stack tr td:last-child { border-bottom: 0; }
  .table-wrap.stack td::before { content: attr(data-label); flex: 0 0 40%; text-align: left; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
  .table-wrap.stack td.cell-action { justify-content: stretch; }
  .table-wrap.stack td.cell-action::before { content: none; }
  .table-wrap.stack td.cell-action .btn { width: 100%; }
  .table-wrap.pin { position: relative; -webkit-overflow-scrolling: touch; }
  .table-wrap.pin table.data th:first-child, .table-wrap.pin table.data td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel-solid); box-shadow: 1px 0 0 var(--line-2); }
  .table-wrap.pin table.data th:first-child { z-index: 3; }
  .table-wrap.pin::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 26px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--panel)); }
}
@media (max-width: 400px) {
  .grid-cards, .grid-cards.six { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr auto; grid-template-areas: "l l" "bar val"; align-items: center; }
  .bar-row .bl { grid-area: l; white-space: normal; }
  .bar-row .bar-track { grid-area: bar; }
  .bar-row .bv { grid-area: val; }
}
@media (max-width: 380px) {
  .tiles { grid-template-columns: 1fr; }
}

/* ============================================================================ Global form controls — premium styling for EVERY input/select/textarea, not
   only those inside .field (filter bars, report date/status pickers, inline
   forms). Element/:where() specificity stays low so .field / .auth-form /
   .inc-new / .input-icon can still override. Checkbox/radio/button excluded. */
input:where(:not([type]), [type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]),
select, textarea {
  background: var(--input-bg); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.4; max-width: 100%;
  box-shadow: inset 0 1px 1.5px rgba(9, 30, 22, 0.035);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
textarea { line-height: 1.55; resize: vertical; }
select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 38px;
  background-repeat: no-repeat; background-position: right 13px center; background-size: 11px 7px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}
input:where(:not([type]), [type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]):hover:not(:focus):not(:disabled):not([readonly]),
select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: var(--line-strong, var(--muted)); }
input:where(:not([type]), [type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]):focus,
select:focus, textarea:focus { outline: none; border-color: var(--emerald-2); box-shadow: 0 0 0 3px rgba(47, 157, 104, 0.16); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.72; }
input:where(:not([type]), [type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]):disabled,
select:disabled, textarea:disabled, input[readonly], textarea[readonly] { background: var(--panel-2); color: var(--ink-dim); cursor: not-allowed; opacity: 0.9; }

/* ============================================================================ Management forms (users / features / reports) */
.admin-form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label:not(.switch):not(.check) { font-size: 11.5px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.field label .req { color: var(--red-2); font-weight: 800; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--input-bg); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: 10px; padding: 11px 13px; font: inherit; font-size: 14px; line-height: 1.4;
  box-shadow: inset 0 1px 1.5px rgba(9, 30, 22, 0.035);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.field input:hover:not(:focus):not(:disabled):not([readonly]),
.field select:hover:not(:focus):not(:disabled),
.field textarea:hover:not(:focus):not(:disabled) { border-color: var(--line-strong, var(--muted)); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--emerald-2); box-shadow: 0 0 0 3px rgba(47, 157, 104, 0.16); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: 0.72; }
.field input:disabled, .field select:disabled, .field textarea:disabled, .field input[readonly], .field textarea[readonly] {
  background: var(--panel-2); color: var(--ink-dim); cursor: not-allowed; box-shadow: none; opacity: 0.9;
}
.field textarea { min-height: 108px; line-height: 1.55; resize: vertical; }
.field select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 40px;
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}
/* Validation + helper text (works in console admin forms and public forms alike) */
.field.error input, .field.error select, .field.error textarea, .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red-2); }
.field.error input:focus, .field.has-error input:focus { box-shadow: 0 0 0 3px rgba(240, 86, 79, 0.16); }
.field-err { color: var(--red-2); font-size: 12.5px; font-weight: 600; margin: 2px 0 0; display: flex; align-items: center; gap: 6px; }
.field-hint, .field .hint { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 2px 0 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-dim); cursor: pointer; line-height: 1.4; }
label.check input { width: 17px; height: 17px; accent-color: var(--emerald); flex-shrink: 0; cursor: pointer; }
label.check:hover { color: var(--ink); }

/* ----------------------------------------------------------------------------
   Form compatibility + polish. Brings the pre-`.field` forms up to the `.field`
   visual system WITHOUT touching their markup: (a) bare `.stacked` forms whose
   <label> and control are flat siblings, and (b) implicit `<label>Text <control>`
   label-wrap forms. Element/low specificity so `.field`/`.auth-form`/`.inc-new`
   still win where they are present. */

/* (a) `.stacked` forms: sibling <label> + control -> stacked field rhythm. */
.stacked > label:not(.check):not(.switch),
.stacked > fieldset > legend {
  display: block; font-size: 11.5px; color: var(--ink-dim); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700; margin: 15px 0 6px; padding: 0;
}
.stacked > label:not(.check):not(.switch):first-of-type { margin-top: 0; }
.stacked > input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.stacked > select, .stacked > textarea, .stacked > fieldset { display: block; width: 100%; }
.stacked > fieldset { margin: 6px 0 0; }
.stacked > .form-actions, .stacked > .filter-actions,
.stacked > div:not([class]):last-child { margin-top: 18px; }
.stacked > button, .stacked > .btn { margin-top: 16px; }

/* (b) implicit label-wrap `<label>Text <control></label>` inside a card form ->
   stacked field. `.field` labels are siblings (no child control) so they never
   match this; checkbox/radio wrappers are excluded so they keep flowing inline. */
.card form label:not(.check):not(.switch):has(> input:not([type="checkbox"]):not([type="radio"])),
.card form label:not(.check):not(.switch):has(> select),
.card form label:not(.check):not(.switch):has(> textarea) {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  font-size: 11.5px; color: var(--ink-dim); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700;
}
/* controls carrying the (previously dead) `.input` class fill their column */
input.input, select.input, textarea.input { width: 100%; }

/* (c) dead-class alias: templates using `.field-error` get the real error look. */
.field-error { color: var(--red-2); font-size: 12.5px; font-weight: 600; margin: 4px 0 0; display: block; }

/* (d) legacy inline fieldset groups: soften the corners now that `--border` is a
   real token (see :root); give legends the same uppercase field-label treatment
   so checkbox groups read consistently — all without markup changes. */
form fieldset { border-radius: 10px; }
form fieldset > legend {
  font-size: 11.5px; color: var(--ink-dim); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700; padding: 0 6px; margin-bottom: 4px;
}

.nav-extlink { opacity: 0.5; margin-left: 5px; vertical-align: -1px; flex-shrink: 0; }

.flash-banner { border: 1px solid var(--emerald); background: rgba(47, 157, 104, 0.1); border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.flash-banner h4 { margin: 0 0 8px; font-size: 14px; color: var(--ink); }
.flash-banner code { display: block; font-family: var(--mono); font-size: 13px; padding: 3px 0; word-break: break-all; color: var(--emerald-2); }
.ok-note { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 10px; padding: 9px 14px; margin-bottom: 16px; font-size: 13px; color: var(--ink-dim); }

.feature-list { display: grid; gap: 4px; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.feature-row:last-child { border-bottom: 0; }
.feature-copy { min-width: 0; }
.feature-title { font-size: 14px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.feature-copy p { margin: 4px 0 0; max-width: 60ch; }

/* Reports catalogue */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.report-card { display: flex; flex-direction: column; }
.report-card .report-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 12px; background: rgba(47, 157, 104, 0.12); border: 1px solid rgba(56, 208, 138, 0.28); }
.report-card .report-ico svg { width: 20px; height: 20px; fill: var(--emerald-2); }
.report-card h3 { font-size: 1.02rem; margin: 0; }
.report-card p { color: var(--ink-dim); margin: 8px 0 14px; font-size: 0.9rem; line-height: 1.55; flex: 1; }
.report-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.report-headline { display: flex; gap: 22px; flex-wrap: wrap; margin: 4px 0 18px; }
.rh-item { display: flex; flex-direction: column; }
.rh-item b { font-family: var(--mono); font-size: 1.5rem; color: var(--ink); }
.rh-item span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

/* ============================================================================ Generic status pill (console + public share this) */
.badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--emerald) 12%, transparent); color: var(--emerald-2);
  border: 1px solid color-mix(in srgb, var(--emerald) 34%, transparent); }
.badge.is-system { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--ink-dim); border-color: var(--line-2); }
.badge.role-org { background: var(--panel-2); color: var(--muted); border-color: var(--line-2); }

/* ============================================================================ RBAC / persona &amp; permission management */
.rbac-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.rbac-stat { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel-2); }
.rbac-stat b { display: block; font-family: var(--display, var(--sans)); font-size: 1.6rem; font-weight: 800; color: var(--ink); line-height: 1; }
.rbac-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 5px; display: block; }
.rbac-toolbar { display: flex; gap: 14px 22px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.rbac-search { flex: 1 1 260px; max-width: 380px; }

.role-list { display: flex; flex-direction: column; gap: 10px; }
.role-card { border: 1px solid var(--line); border-radius: 13px; background: var(--panel); overflow: hidden; transition: border-color var(--ease), box-shadow var(--ease); }
.role-card[open] { border-color: color-mix(in srgb, var(--emerald) 40%, var(--line)); box-shadow: 0 8px 22px rgba(9, 30, 22, 0.06); }
.role-card__sum { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; }
.role-card__sum::-webkit-details-marker { display: none; }
.role-card__id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.role-card__name { font-weight: 700; color: var(--ink); font-size: 15px; }
.role-card__code { font-size: 11.5px; color: var(--muted); }
.role-card__meta { display: flex; align-items: center; gap: 9px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.perm-count { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.role-card__chev { color: var(--muted); transition: transform var(--ease); }
.role-card[open] .role-card__chev { transform: rotate(180deg); }
.role-card__body { padding: 2px 16px 18px; border-top: 1px solid var(--line-soft, var(--line)); }

.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 14px; }
.perm-group { border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); padding: 12px; }
.perm-group__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.perm-group__title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); }
.perm-group__count { font-size: 11px; color: var(--muted); font-family: var(--mono); background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 7px; }
.perm-all { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); cursor: pointer; text-transform: uppercase; letter-spacing: 0.04em; }
.perm-all input { width: 15px; height: 15px; accent-color: var(--emerald); cursor: pointer; }
.perm-group__items { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-item { flex: 1 1 100%; display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.perm-item input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--emerald); flex-shrink: 0; cursor: pointer; }
.perm-item__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.perm-item__label { font-size: 13px; color: var(--ink); line-height: 1.3; }
.perm-item__code { font-size: 10.5px; color: var(--muted); }
.perm-chip { font-size: 12px; color: var(--ink-dim); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 4px 9px; }
.perm-live { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* ============================================================================ Toggle switch (settings + forms) */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; }
.switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; transition: background var(--ease); flex-shrink: 0; }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28); transition: transform var(--ease); }
.switch__input:checked + .switch__track { background: var(--emerald); }
.switch__input:checked + .switch__track .switch__thumb { transform: translateX(18px); }
.switch__input:focus-visible + .switch__track { box-shadow: 0 0 0 3px rgba(47, 157, 104, 0.25); }
.switch__input:disabled + .switch__track { opacity: 0.5; cursor: not-allowed; }
.switch__text { font-size: 13.5px; color: var(--ink-dim); }

/* ============================================================================ Settings — tabbed console */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.settings-tabs { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 12px; }
.settings-tab { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--ink-dim);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background var(--ease), color var(--ease), border-color var(--ease); }
.settings-tab:hover { background: var(--raise-hover); color: var(--ink); }
.settings-tab.is-active { background: color-mix(in srgb, var(--emerald) 12%, transparent); color: var(--emerald-2); border-color: color-mix(in srgb, var(--emerald) 30%, transparent); }
.settings-tab__count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.settings-tab.is-active .settings-tab__count { color: var(--emerald-2); }
.settings-panel { display: none; }
.settings-panel.is-active { display: block; animation: settings-fade var(--ease) both; }
@keyframes settings-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.settings-panel__head { margin-bottom: 18px; }
.settings-panel__head h2 { font-size: 1.2rem; margin: 0; font-family: var(--display, var(--sans)); }
.settings-panel__head p { color: var(--muted); font-size: 13px; margin: 5px 0 0; }
.settings-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.settings-fields .field--wide { grid-column: 1 / -1; }
.setting-key { text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.settings-savebar { position: sticky; bottom: 12px; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 18px; background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 30px rgba(9, 30, 22, 0.12); flex-wrap: wrap; }
.settings-savebar__note { color: var(--muted); font-size: 12.5px; flex: 1 1 auto; }

@media (max-width: 820px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-tabs { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 6px; margin: 0 -4px; }
  .settings-tab { flex-shrink: 0; width: auto; }
}
