/* ════════════════════════════════════════════════════════════════════════
   KADYS · Emergency Response System
   Industrial control system aesthetic.
   IBM Plex typography. Deep graphite base. Sharp accents.
   ════════════════════════════════════════════════════════════════════════ */

/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html {
  /* Honour the user's browser/OS base font size so the UI scales when they
     bump up text size, while clamping so it never gets absurd on tiny or huge
     screens. 1rem ≈ 14px at the default 16px browser setting. */
  font-size: clamp(13px, 0.78rem + 0.18vw, 17px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--brand-primary); color: #fff; }

/* ─── Design Tokens — DARK (default) ─────────────────────────────────── */
:root,
[data-theme="dark"] {
  /* Warm graphite surfaces — a deliberately neutral, slightly warm charcoal
     (not the cool navy + cyan that reads as a generic dark dashboard). Gives
     OD VAULT its own "control-room" identity. */
  --bg-deep:   #0c0b0e;
  --bg:        #131217;
  --bg-elev:   #1b1a21;
  --bg-elev2:  #24222c;
  --bg-hover:  #2c2a3540;

  --fg:        #ece9f1;
  --fg-mute:   #9d96a8;
  --fg-faint:  #645d72;

  --border:        #2a2733;
  --border-strong: #3a3647;
  --border-faint:  #201e28;

  /* ── Single accent (Phase 1 design system) ────────────────────────
     One indigo accent drives every interactive surface: brand mark,
     primary buttons, active nav, focus rings, links. Same hue in both
     themes (lightness tuned per mode for contrast). Red is reserved for
     danger/critical only — never the primary accent. Legacy --brand-*
     names are kept as aliases so existing rules follow along. */
  --accent:        #5b8def;
  --accent-2:      #7ba3f5;
  --accent-strong: #3f6fd6;
  --accent-soft:   rgba(91, 141, 239, 0.16);

  --brand-deep:      #15203a;
  --brand-primary:   var(--accent);
  --brand-primary-2: var(--accent-2);
  --brand-glow:      var(--accent-soft);

  --accent-amber:    #f59e0b;
  --accent-cyan:     #22d3ee;
  --accent-red:      #ef4444;
  --accent-green:    #10b981;
  --accent-purple:   #a78bfa;
  --accent-blue:     #3b82f6;

  /* ── Legacy/alias tokens ──────────────────────────────────────────
     A number of older rules reference --muted, --bg-2 and --danger,
     which were never defined — so they silently fell back to hard-coded
     DARK values and became invisible in light mode. Alias them to the
     real theme tokens here. Because var() substitution is lazy, these
     follow the active theme automatically (no need to redefine per
     theme). */
  --muted:  var(--fg-mute);
  --bg-2:   var(--bg-elev);
  --danger: var(--accent-red);

  /* Radius scale — one rounded system across cards, buttons, inputs. */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Spacing scale. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --sev-low:      #10b981;
  --sev-medium:   #f59e0b;
  --sev-high:     #fb923c;
  --sev-critical: #ef4444;

  --status-available: #10b981;
  --status-on-task:   #f59e0b;
  --status-checking:  #22d3ee;
  --status-offline:   #6b7280;

  /* Map (Leaflet reads these via getComputedStyle, not var()). */
  --map-marker:      #5b8def;
  --map-marker-2:    #7ba3f5;
  --map-fence-main:  #5b8def;
  --map-fence-other: #48516b;
  --map-popup-mute:  #9d96a8;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 16px 48px rgba(0,0,0,0.6);
  --grid-line:  rgba(255,255,255,0.03);

  --font-sans:    'Inter', 'Manrope', system-ui, -apple-system, sans-serif;
  /* --font-cond is retained as a name but now resolves to the single sans
     family — no more condensed/spaced display face for chrome. */
  --font-cond:    var(--font-sans);
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
}

/* ─── Design Tokens — LIGHT ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg-deep:   #ffffff;
  --bg:        #f7f8fc;
  --bg-elev:   #ffffff;
  --bg-elev2:  #eef0f7;
  --bg-hover:  #e6e9f180;

  --fg:        #161821;
  --fg-mute:   #5c6273;
  --fg-faint:  #8c91a0;

  --border:        #d2d8e6;
  --border-strong: #b3bbcc;
  --border-faint:  #e6eaf3;

  --accent:        #3f6fd6;
  --accent-2:      #2f5fc8;
  --accent-strong: #2a55b8;
  --accent-soft:   rgba(63, 111, 214, 0.12);

  --brand-deep:      #16264d;
  --brand-primary:   var(--accent);
  --brand-primary-2: var(--accent-2);
  --brand-glow:      var(--accent-soft);

  --accent-amber:  #d97706;
  --accent-cyan:   #0e7490;
  --accent-red:    #dc2626;
  --accent-green:  #059669;
  --accent-purple: #7c3aed;
  --accent-blue:   #2563eb;

  --sev-low:      #059669;
  --sev-medium:   #d97706;
  --sev-high:     #ea580c;
  --sev-critical: #dc2626;

  --status-available: #059669;
  --status-on-task:   #d97706;
  --status-checking:  #0e7490;
  --status-offline:   #94a3b8;

  --map-marker:      #3f6fd6;
  --map-marker-2:    #2f5fc8;
  --map-fence-main:  #3f6fd6;
  --map-fence-other: #475569;
  --map-popup-mute:  #64748b;

  --shadow-sm:  0 1px 3px rgba(20,30,50,0.08);
  --shadow-md:  0 4px 16px rgba(20,30,50,0.08);
  --shadow-lg:  0 16px 48px rgba(20,30,50,0.18);
  --grid-line:  rgba(0,0,0,0.04);
}

/* ════════════════════════════════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════════════════════════════════ */

.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 100;
  padding: 24px;
  overflow: auto;
}

/* Split layout: branded panel + form card. No graph-paper, no glow. */
.login-split {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%; max-width: 920px;
  min-height: 540px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* ── Branded panel (solid accent) ── */
.login-panel {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  gap: 32px;
  padding: 44px 40px;
  background: linear-gradient(155deg, var(--accent-strong), var(--accent));
  color: #fff;
}
.login-panel-brand { display: flex; align-items: center; gap: 14px; }
.login-panel .brand-mark.lg { width: 52px; height: 52px; color: #fff; background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.25); }
.login-panel-wordmark { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.login-panel-copy h2 { font-size: 30px; line-height: 1.18; font-weight: 700; letter-spacing: -0.02em; }
.login-panel-copy p { margin-top: 14px; font-size: 15px; line-height: 1.6; color: rgba(255,255,255,0.86); max-width: 30ch; }
.login-panel-foot { font-size: 12px; color: rgba(255,255,255,0.72); }

/* ── Form card ── */
.login-card { padding: 44px 40px; display: flex; flex-direction: column; }
.login-card-head { margin-bottom: 26px; }
.login-card-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.login-card-sub { margin-top: 6px; font-size: 14px; color: var(--fg-mute); }

.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--accent);
  border-radius: var(--radius-sm);
}
.brand-mark.sm { width: 34px; height: 34px; }
.brand-mark svg { width: 100%; height: 100%; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .form-row label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 600;
  color: var(--fg-mute);
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-sans);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.login-error {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--accent-red);
  min-height: 16px;
  display: none;
}
.login-error.visible { display: block; }

.login-creds {
  margin-top: 24px;
  padding: 14px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}
.cred-row { display: flex; justify-content: space-between; padding: 3px 0; }
.cred-key { color: var(--fg-mute); font-weight: 600; }
.cred-val { color: var(--fg); }

@media (max-width: 720px) {
  .login-split { grid-template-columns: 1fr; max-width: 440px; min-height: 0; }
  .login-panel { padding: 32px 28px; gap: 20px; }
  .login-panel-copy h2 { font-size: 22px; }
  .login-card { padding: 32px 28px; }
}

/* ════════════════════════════════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elev), transparent);
}
.sidebar-brand .brand-mark { color: var(--accent-amber); }
.brand-name {
  display: block;
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.18em;
  line-height: 1;
}
.sidebar-brand .brand-tag { font-size: 9px; }

.sidebar-close {
  margin-left: auto;
  width: 32px; height: 32px;
  display: none;
  align-items: center; justify-content: center;
  color: var(--fg-mute);
  border: 1px solid transparent;
}
.sidebar-close:hover {
  border-color: var(--border);
  color: var(--fg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); }

.nav-group { margin-bottom: 16px; }
.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-faint);
  padding: 6px 20px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px;
  font-size: 13px;
  color: var(--fg-mute);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 80ms ease;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; }
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.nav-item.active {
  background: var(--bg-elev);
  color: var(--fg);
  border-left-color: var(--accent-amber);
}
.nav-item.active svg { color: var(--accent-amber); }

.nav-badge {
  margin-left: auto;
  min-width: 20px; height: 18px;
  padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-red);
  color: white;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  border-radius: 9px;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--accent-amber);
  position: relative;
}
.user-avatar .status-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-elev);
  background: var(--status-offline);
}
.user-meta { flex: 1; min-width: 0; }
.user-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ─── Backdrop ───────────────────────────────────────────────────────── */
.backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  backdrop-filter: blur(2px);
}
.backdrop.visible { display: block; }

/* ─── Main ───────────────────────────────────────────────────────────── */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--bg);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  flex-shrink: 0;
  height: 60px;
}

.menu-toggle { display: none; }

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-family: var(--font-cond);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.1;
}
.topbar-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.status-control { position: relative; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: border-color 120ms;
}
.status-pill:hover { border-color: var(--border-strong); }

.status-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 50;
  display: none;
}
.status-menu.visible { display: block; }
.status-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.status-option:hover { background: var(--bg-hover); }

.btn-icon {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg-mute);
  transition: all 120ms ease;
}
.btn-icon:hover { color: var(--fg); border-color: var(--border-strong); }

.content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page-view {
  position: absolute; inset: 0;
  overflow-y: auto;
  display: none;
  padding: 24px;
}
.page-view.active { display: block; }
.page-view::-webkit-scrollbar { width: 8px; }
.page-view::-webkit-scrollbar-thumb { background: var(--border); }
.page-view::-webkit-scrollbar-track { background: transparent; }

/* ─── Mobile nav ─────────────────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 80;
  grid-template-columns: repeat(5, 1fr);
}
.mob-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px;
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.mob-item svg { width: 18px; height: 18px; }
.mob-item.active { color: var(--accent-amber); }

/* ════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ════════════════════════════════════════════════════════════════════════ */

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); border-color: var(--brand-primary-2); }
.btn-danger { background: var(--accent-red); border-color: var(--accent-red); color: white; }
.btn-success { background: var(--accent-green); border-color: var(--accent-green); color: white; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 6px 10px; font-size: 10px; }
.btn-full { width: 100%; }

/* ─── Forms ──────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
/* ─── Generic .field / .input style — covers every modal form ──────────
   The legacy CSS only styled `.form-row input` (a different layout class),
   so any form built with field()/inp()/ta()/sel() rendered with browser
   defaults (white bg). This block restores the dark-theme look. */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.field-hint {
  font-size: 11px;
  color: var(--fg-faint);
}
input.input,
textarea.input,
select.input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  border-radius: 3px;
  transition: border-color 120ms;
  width: 100%;
  box-sizing: border-box;
}
input.input::placeholder,
textarea.input::placeholder {
  color: var(--fg-faint);
}
input.input:focus,
textarea.input:focus,
select.input:focus {
  outline: none;
  border-color: var(--accent-amber);
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-mute) 50%),
                    linear-gradient(135deg, var(--fg-mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
input.input[type="number"] {
  font-variant-numeric: tabular-nums;
}
input.input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent-amber);
}
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.full { grid-column: 1 / -1; }
.form-row label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.form-row input,
.form-row textarea,
.form-row select {
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color 120ms;
}
.form-row textarea { font-family: var(--font-sans); resize: vertical; min-height: 80px; }
.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--accent-amber);
}
.form-help {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-faint);
  letter-spacing: 0.05em;
}

.form-row .check-row { display: flex; align-items: center; gap: 8px; }
.form-row input[type="checkbox"] { width: auto; }

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 18px;
  position: relative;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border-faint);
}
.card-title {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg);
}
.card-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ─── Stat Card ──────────────────────────────────────────────────────── */
.stat {
  position: relative;
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-cyan);
}
.stat.amber::before { background: var(--accent-amber); }
.stat.red::before { background: var(--accent-red); }
.stat.green::before { background: var(--accent-green); }
.stat.purple::before { background: var(--accent-purple); }

.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--font-cond);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-foot {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
}
.stat-foot.warn { color: var(--accent-amber); }
.stat-foot.danger { color: var(--accent-red); }

/* ─── Dots & Badges ──────────────────────────────────────────────────── */
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-mute);
  flex-shrink: 0;
  display: inline-block;
}
.dot-online,
.dot-available { background: var(--status-available); box-shadow: 0 0 6px var(--status-available); }
.dot-on-task { background: var(--status-on-task); }
.dot-checking { background: var(--status-checking); animation: pulse 1.5s infinite; }
.dot-offline { background: var(--status-offline); }

.dot-low      { background: var(--sev-low); }
.dot-medium   { background: var(--sev-medium); }
.dot-high     { background: var(--sev-high); }
.dot-critical { background: var(--sev-critical); animation: pulse-fast 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes pulse-fast {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.badge-amber { color: var(--accent-amber); border-color: var(--accent-amber); }
.badge-cyan { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.badge-red { color: var(--accent-red); border-color: var(--accent-red); }
.badge-green { color: var(--accent-green); border-color: var(--accent-green); }

.severity {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid;
}
.severity-low { color: var(--sev-low); border-color: var(--sev-low); }
.severity-medium { color: var(--sev-medium); border-color: var(--sev-medium); }
.severity-high { color: var(--sev-high); border-color: var(--sev-high); }
.severity-critical { color: var(--sev-critical); border-color: var(--sev-critical); background: var(--sev-critical); color: white; }

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev2);
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-faint);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table .mono { font-family: var(--font-mono); font-size: 12px; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-empty {
  padding: 40px;
  text-align: center;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── Lists ──────────────────────────────────────────────────────────── */
.list {
  display: flex;
  flex-direction: column;
}
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-faint);
  transition: background 80ms;
  cursor: pointer;
}
.list-item:hover { background: var(--bg-hover); }
.list-item:last-child { border-bottom: none; }
.list-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  color: var(--fg-mute);
}
.list-icon svg { width: 16px; height: 16px; }
.list-body { flex: 1; min-width: 0; }
.list-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 9000;  /* above Leaflet panes (700) and controls (1000) */
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-overlay.visible { display: flex; }

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent-amber);
}
.modal.wide { max-width: 800px; }
.modal.full { max-width: 1100px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ─── Toasts ─────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 70px; right: 20px;
  z-index: 9500;  /* above modal-overlay (9000) so toasts always visible */
  display: flex; flex-direction: column;
  gap: 8px;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-cyan);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  pointer-events: auto;
  animation: slideIn 200ms ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.removing { animation: slideOut 200ms ease forwards; }
@keyframes slideOut {
  to { opacity: 0; transform: translateX(20px); }
}
.toast-success { border-left-color: var(--accent-green); }
.toast-error { border-left-color: var(--accent-red); }
.toast-warn { border-left-color: var(--accent-amber); }

/* ════════════════════════════════════════════════════════════════════════
   PAGE HEADERS
   ════════════════════════════════════════════════════════════════════════ */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-head h2 {
  font-family: var(--font-cond);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.page-head .sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.1em;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ════════════════════════════════════════════════════════════════════════
   DASHBOARD
   ════════════════════════════════════════════════════════════════════════ */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .dash-row { grid-template-columns: 1fr; }
}

.sparkline-wrap {
  position: relative;
  height: 110px;
  margin: 8px 0;
}
.sparkline svg { width: 100%; height: 100%; }
.spark-bar {
  fill: var(--accent-cyan);
  opacity: 0.7;
  transition: opacity 120ms;
}
.spark-bar:hover { opacity: 1; }

.run-types {
  display: flex; flex-direction: column;
  gap: 8px;
}
.run-type-bar {
  display: flex; align-items: center; gap: 10px;
}
.run-type-label {
  width: 120px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.run-type-track {
  flex: 1;
  height: 6px;
  background: var(--bg-elev2);
  position: relative;
}
.run-type-fill {
  height: 100%;
  background: var(--accent-cyan);
}
.run-type-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  width: 32px;
  text-align: right;
}

/* ════════════════════════════════════════════════════════════════════════
   MAP
   ════════════════════════════════════════════════════════════════════════ */

#page-map { padding: 0; }

.map-shell {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
}
.map-toolbar {
  display: flex; flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 500;
}
.map-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.map-canvas .leaflet-container {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
}

.map-side {
  background: var(--bg-deep);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.map-side-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.map-side-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.map-tab {
  flex: 1;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  border-bottom: 2px solid transparent;
  background: var(--bg-elev);
}
.map-tab.active {
  color: var(--accent-amber);
  border-bottom-color: var(--accent-amber);
  background: var(--bg-deep);
}
.map-side-body {
  flex: 1;
  overflow-y: auto;
}

.map-fab {
  position: absolute;
  right: 16px; bottom: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent-amber);
  color: var(--bg-deep);
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  cursor: pointer;
  transition: transform 120ms;
}
.map-fab:hover { transform: scale(1.05); }
.map-fab svg { width: 24px; height: 24px; stroke-width: 2.5; }

.map-legend {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 400;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 260px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.map-legend-row { display: flex; align-items: center; gap: 6px; }

/* Leaflet overrides */
.leaflet-control-zoom a {
  background: var(--bg-elev) !important;
  color: var(--fg) !important;
  border: 1px solid var(--border) !important;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-elev) !important;
  color: var(--fg) !important;
  border: 1px solid var(--border);
}
.leaflet-popup-content { font-family: var(--font-sans); }
[data-theme="dark"] .leaflet-tile-container { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9); }
[data-theme="dark"] .leaflet-marker-icon { filter: none; }

.map-marker {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  display: grid;
  place-items: center;
  color: white;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.map-marker.low { background: var(--sev-low); }
.map-marker.medium { background: var(--sev-medium); }
.map-marker.high { background: var(--sev-high); }
.map-marker.critical { background: var(--sev-critical); animation: pulse-fast 1s infinite; }

.responder-marker {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid white;
  background: var(--accent-cyan);
  display: grid; place-items: center;
  color: white;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 9px;
  box-shadow: 0 0 0 2px var(--accent-cyan)40, 0 2px 8px rgba(0,0,0,0.4);
}
.responder-marker.on_task { background: var(--accent-amber); }
.responder-marker.checking { background: var(--accent-cyan); animation: pulse 1.5s infinite; }

/* ════════════════════════════════════════════════════════════════════════
   DISPATCH / RESPONDER
   ════════════════════════════════════════════════════════════════════════ */

.dispatch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) {
  .dispatch-grid { grid-template-columns: 1fr; }
}

.run-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 14px;
  border-left: 3px solid var(--sev-medium);
  transition: all 120ms ease;
  cursor: pointer;
}
.run-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.run-card.severity-low { border-left-color: var(--sev-low); }
.run-card.severity-medium { border-left-color: var(--sev-medium); }
.run-card.severity-high { border-left-color: var(--sev-high); }
.run-card.severity-critical { border-left-color: var(--sev-critical); }

.run-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.run-number {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--fg-mute);
}
.run-title {
  font-size: 14px;
  font-weight: 600;
  margin: 4px 0 6px;
  line-height: 1.3;
}
.run-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ════════════════════════════════════════════════════════════════════════
   CHAT / MESSAGING
   ════════════════════════════════════════════════════════════════════════ */

.messages-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  margin: -24px;
}
@media (max-width: 800px) {
  .messages-shell { grid-template-columns: 1fr; }
  .messages-list-pane.has-active { display: none; }
  .messages-thread-pane:not(.has-active) { display: none; }
}

.messages-list-pane {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
}
.messages-list-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.messages-list-tab {
  flex: 1;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  border-bottom: 2px solid transparent;
}
.messages-list-tab.active {
  color: var(--accent-amber);
  border-bottom-color: var(--accent-amber);
}
.messages-list-body { flex: 1; overflow-y: auto; }

.conv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-faint);
  cursor: pointer;
}
.conv-item.active { background: var(--bg-elev); border-left: 2px solid var(--accent-amber); }
.conv-item:hover { background: var(--bg-hover); }
.conv-avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  color: var(--accent-amber);
  flex-shrink: 0;
}
.conv-meta { flex: 1; min-width: 0; }
.conv-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-snippet {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--accent-red);
  color: white;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.messages-thread-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.thread-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  display: flex; align-items: center; gap: 10px;
}
.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 70%;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
  align-self: flex-start;
}
.msg.mine {
  align-self: flex-end;
  background: var(--accent-amber);
  color: var(--bg-deep);
  border-color: var(--accent-amber);
}
.msg-head {
  display: flex; gap: 10px; align-items: baseline;
  margin-bottom: 4px;
}
.msg-author {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.msg-time {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
}
.msg-body { font-size: 13px; line-height: 1.45; word-wrap: break-word; }

.thread-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--bg-deep);
  display: flex;
  gap: 8px;
}
.thread-foot input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 13px;
}
.thread-foot input:focus { outline: none; border-color: var(--accent-amber); }

.thread-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════════════
   CHECKLIST RUN
   ════════════════════════════════════════════════════════════════════════ */

.cl-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.cl-item-label { flex: 1; font-size: 13px; }
.cl-buttons { display: flex; gap: 6px; }
.cl-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cl-btn.pass.active { background: var(--accent-green); color: white; border-color: var(--accent-green); }
.cl-btn.fail.active { background: var(--accent-red); color: white; border-color: var(--accent-red); }
.cl-btn.na.active { background: var(--fg-mute); color: white; border-color: var(--fg-mute); }

/* ════════════════════════════════════════════════════════════════════════
   COMPLIANCE
   ════════════════════════════════════════════════════════════════════════ */

.compliance-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-faint);
}
.compliance-name {
  font-weight: 600;
  font-size: 13px;
}
.compliance-cells {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.compliance-cell {
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid;
  letter-spacing: 0.05em;
}
.compliance-cell.valid { color: var(--accent-green); border-color: var(--accent-green); }
.compliance-cell.expiring { color: var(--accent-amber); border-color: var(--accent-amber); }
.compliance-cell.expired { color: var(--accent-red); border-color: var(--accent-red); background: var(--accent-red); color: white; }
.compliance-cell.missing { color: var(--fg-faint); border-color: var(--border); border-style: dashed; }

/* ════════════════════════════════════════════════════════════════════════
   SOPs
   ════════════════════════════════════════════════════════════════════════ */

.sop-content {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.7;
}
.sop-content h2 {
  font-family: var(--font-cond);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-faint);
}
.sop-content p { margin-bottom: 12px; }
.sop-content ul, .sop-content ol { margin: 12px 0 12px 20px; }
.sop-content li { margin-bottom: 4px; }
.sop-content strong { color: var(--accent-amber); font-weight: 600; }

/* ════════════════════════════════════════════════════════════════════════
   ACTIVITY / TIMELINE
   ════════════════════════════════════════════════════════════════════════ */

.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}
.tl-event {
  position: relative;
  padding: 10px 0 14px;
}
.tl-event::before {
  content: '';
  position: absolute;
  left: -22px; top: 14px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--bg);
}
.tl-event.critical::before { background: var(--sev-critical); }
.tl-event.high::before { background: var(--sev-high); }
.tl-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tl-title {
  font-weight: 600;
  font-size: 13px;
  margin: 2px 0;
}
.tl-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.visible { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .menu-toggle { display: inline-flex; }
  .mobile-nav { display: grid; }
  .main { padding-bottom: 60px; }
  .map-shell { grid-template-columns: 1fr; }
  .map-side { display: none; }
}

/* Wide data tables must never force horizontal page scroll — wrap them in
   their own scroll context on narrower screens so the rest of the layout
   stays put. Applies to every .data-table (run archive, etc.). */
@media (max-width: 768px) {
  .data-table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table thead, .data-table tbody, .data-table tr { display: table; width: 100%; table-layout: fixed; }
  .page-view { padding: 20px 16px; }
  .grid-cards { grid-template-columns: 1fr; }
  .activity-filter-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 540px) {
  .topbar { padding: 10px 14px; }
  .topbar-title h1 { font-size: 16px; }
  .topbar-sub { display: none; }
  .status-pill { padding: 5px 8px; }
  .status-pill span:last-child { display: none; }
  .page-view { padding: 16px; }
  .page-head h2 { font-size: 18px; }
  .page-head { gap: 10px; }
  .page-actions { width: 100%; }
  .stat-value { font-size: 28px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-height: 92dvh; max-width: 100%; }
  .modal-foot { justify-content: stretch; }
  .modal-foot .btn { flex: 1 1 auto; }
  .activity-filter-grid { grid-template-columns: 1fr; }
  .toast-container { top: 16px; right: 16px; left: 16px; max-width: none; }
  .messages-shell { margin: -16px; }
}

/* ─── Utilities ─────────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.muted { color: var(--fg-mute); }
.faint { color: var(--fg-faint); }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gap-sm { gap: 4px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 20px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--fg-faint);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto 12px;
  opacity: 0.4;
}
.empty-state h3 {
  font-family: var(--font-cond);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.empty-state p {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* Print */
@media print {
  .sidebar, .topbar, .mobile-nav, .toast-container, .modal-overlay { display: none !important; }
  .main { height: auto; }
  .page-view { position: static; padding: 0; }
}

/* ─── Real-time Indicator ────────────────────────────────────────────── */
.rt-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border, #2a2f3b);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px; letter-spacing: 0.1em;
  color: var(--muted, #8d96a8);
  transition: color 120ms, border-color 120ms;
}
.rt-indicator .rt-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6b7280;
  box-shadow: 0 0 0 0 transparent;
}
.rt-indicator[data-state="on"] {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}
.rt-indicator[data-state="on"] .rt-dot {
  background: #10b981;
  animation: rt-pulse 2s ease-in-out infinite;
}
.rt-indicator[data-state="reconnecting"] {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
}
.rt-indicator[data-state="reconnecting"] .rt-dot {
  background: #f59e0b;
  animation: rt-pulse 0.6s ease-in-out infinite;
}
@keyframes rt-pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50% { box-shadow: 0 0 0 6px transparent; opacity: 0.6; }
}

/* Mute toggle styling — when muted, dim and add slash overlay via icon swap */
#mute-toggle.muted { color: var(--muted, #8d96a8); }
#mute-toggle:not(.muted) { color: var(--accent-amber, #f59e0b); }

/* ─── Real-time Toast Variants ───────────────────────────────────────── */
.toast-alert {
  border-left: 3px solid var(--accent-red, #ef4444);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.18), var(--bg-card, #1a1f2b));
  animation: rt-flash 0.6s ease-out;
}
.toast-dispatch {
  border-left: 3px solid var(--accent-amber, #f59e0b);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), var(--bg-card, #1a1f2b));
}
.toast-message {
  border-left: 3px solid var(--accent-cyan, #22d3ee);
}
.toast-breach {
  border-left: 3px solid #f97316;
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.15), var(--bg-card, #1a1f2b));
}
@keyframes rt-flash {
  0%   { transform: translateX(40px); opacity: 0; }
  50%  { transform: translateX(-4px); }
  100% { transform: translateX(0); opacity: 1; }
}

.toast-actions {
  display: flex; gap: 6px; margin-top: 8px;
}
.toast-actions .btn { font-size: 10px; padding: 4px 8px; }

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 4 — Frontend polish
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Command Palette (⌘K) ──────────────────────────────────────────────── */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(8, 10, 16, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.cmdk-overlay.visible { display: flex; }

.cmdk-modal {
  width: min(640px, 92vw);
  background: var(--bg-card, #1a1f2b);
  border: 1px solid var(--border, #2a2f3b);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  font-family: var(--font-sans, 'IBM Plex Sans', sans-serif);
  animation: cmdk-pop 140ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes cmdk-pop {
  from { transform: translateY(-8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.cmdk-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #2a2f3b);
}
.cmdk-icon { color: var(--muted, #8d96a8); flex-shrink: 0; }
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-size: 15px;
  color: var(--fg, #e2e8f0);
  font-family: inherit;
}
.cmdk-input::placeholder { color: var(--muted, #8d96a8); }

.cmdk-kbd, .cmdk-foot kbd {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border, #2a2f3b);
  border-radius: 3px;
  color: var(--muted, #8d96a8);
  background: var(--bg-deep, #0e1118);
}

.cmdk-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
}
.cmdk-list:empty + .cmdk-foot { display: none; }
.cmdk-list .cmdk-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted, #8d96a8);
  font-size: 13px;
}

.cmdk-section {
  padding: 8px 12px 4px;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--muted, #8d96a8);
  text-transform: uppercase;
}

.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 80ms;
}
.cmdk-item:hover, .cmdk-item.active {
  background: var(--bg-hover, rgba(245, 158, 11, 0.08));
}
.cmdk-item.active {
  background: rgba(245, 158, 11, 0.16);
  outline: 1px solid rgba(245, 158, 11, 0.4);
}
.cmdk-item-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--bg-deep, #0e1118);
  border: 1px solid var(--border, #2a2f3b);
  border-radius: 4px;
  color: var(--muted, #8d96a8);
  flex-shrink: 0;
}
.cmdk-item-body { flex: 1; min-width: 0; }
.cmdk-item-title {
  font-size: 13px;
  color: var(--fg, #e2e8f0);
  font-weight: 500;
}
.cmdk-item-sub {
  font-size: 11px;
  color: var(--muted, #8d96a8);
  margin-top: 2px;
}
.cmdk-item-badge {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-deep, #0e1118);
  color: var(--muted, #8d96a8);
  text-transform: uppercase;
}

.cmdk-foot {
  display: flex; gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border, #2a2f3b);
  font-size: 11px;
  color: var(--muted, #8d96a8);
  background: var(--bg-deep, #0e1118);
}
.cmdk-foot kbd { margin-right: 4px; }

/* ─── QR Code Modal ─────────────────────────────────────────────────────── */
.qr-display {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 16px;
}
.qr-canvas {
  background: #fff;
  padding: 16px;
  border-radius: 4px;
  border: 1px solid var(--border, #2a2f3b);
}
.qr-canvas svg, .qr-canvas img { display: block; }
.qr-label {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg, #e2e8f0);
  text-align: center;
}
.qr-sublabel {
  font-size: 11px;
  color: var(--muted, #8d96a8);
  text-align: center;
}
.qr-actions {
  display: flex; gap: 8px;
  margin-top: 8px;
}
@media print {
  body * { visibility: hidden; }
  .qr-display, .qr-display * { visibility: visible; }
  .qr-display { position: absolute; top: 0; left: 0; }
  .qr-actions { display: none; }
}

/* ─── Leaflet-Draw mode banner ───────────────────────────────────────────── */
.draw-mode-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000;
  background: rgba(245, 158, 11, 0.95);
  color: #0e1118;
  padding: 8px 16px;
  border-radius: 4px;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  pointer-events: auto;
}
.draw-mode-banner button {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(0,0,0,0.3);
  color: inherit;
  padding: 3px 8px; border-radius: 3px;
  font-family: inherit; font-size: 10px;
  cursor: pointer;
}
.draw-mode-banner button:hover { background: rgba(0,0,0,0.3); }

/* ─── Marker Cluster theming (override defaults to match dark UI) ────────── */
.marker-cluster-small {
  background-color: rgba(34, 211, 238, 0.3) !important;
}
.marker-cluster-small div {
  background-color: rgba(34, 211, 238, 0.85) !important;
  color: #0e1118 !important;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace) !important;
  font-weight: 700 !important;
}
.marker-cluster-medium {
  background-color: rgba(245, 158, 11, 0.3) !important;
}
.marker-cluster-medium div {
  background-color: rgba(245, 158, 11, 0.9) !important;
  color: #0e1118 !important;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace) !important;
  font-weight: 700 !important;
}
.marker-cluster-large {
  background-color: rgba(239, 68, 68, 0.3) !important;
}
.marker-cluster-large div {
  background-color: rgba(239, 68, 68, 0.95) !important;
  color: #fff !important;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace) !important;
  font-weight: 700 !important;
}

/* ─── Leaflet-Draw control retheming ─────────────────────────────────────── */
.leaflet-draw-toolbar a {
  background-color: var(--bg-card, #1a1f2b) !important;
  border-bottom-color: var(--border, #2a2f3b) !important;
}
.leaflet-draw-toolbar a:hover {
  background-color: var(--bg-deep, #0e1118) !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 5A — Property page styling
   ═══════════════════════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.stats-grid .stat {
  position: relative;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.stats-grid .stat::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent-amber);
}

.building-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
@media (max-width: 720px) {
  .building-body { grid-template-columns: 1fr; }
}

.building-col {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.building-col-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.building-col-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 600;
}

.mini-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.mini-row:hover { background: var(--bg-hover, rgba(245,158,11,0.05)); border-color: var(--border); }
.mini-row-body { flex: 1; min-width: 0; }
.mini-row-title { font-size: 13px; font-weight: 500; color: var(--fg); }
.mini-row-sub { font-size: 11px; color: var(--fg-mute); margin-top: 1px; }
.mini-row-actions { display: flex; gap: 4px; flex-shrink: 0; }

.loc-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 12px;
  background: var(--bg-deep, rgba(0,0,0,0.15));
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 4px 0;
}
.loc-selector .field { margin: 0; }
.loc-selector .field-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.loc-label {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
  background: var(--bg-deep, rgba(0,0,0,0.2));
  border-left: 2px solid var(--accent-amber);
  border-radius: 2px;
  margin-top: 4px;
  color: var(--fg);
}

.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 8px;
  grid-column: 1 / -1;  /* span all columns if inside grid */
}

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 5C — Spacing fixes (run-together text issues from Phase 1)
   ═══════════════════════════════════════════════════════════════════════ */

/* Responder Quick Status — inline status indicators were collapsing.
   Add gap to the container and padding to each option. */
.status-quick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.status-quick-grid label,
.status-quick-grid > * {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Data tables — th cells were running together because no padding. */
.data-table th,
.data-table td {
  padding: 8px 12px;
  text-align: left;
}
.data-table thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Card foot rows — multiple inline metrics were running together
   ("23m ago0 acked", "5 itemslast: —", "0 items EDIT") */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--fg-mute);
}
.card-foot > * {
  display: inline-flex; align-items: center; gap: 6px;
}
.card-foot .muted-stack {
  display: flex; flex-direction: column; gap: 2px;
}

/* Message tabs ("CHANNELSDIRECT" → "CHANNELS  DIRECT") */
.msg-tabs {
  display: flex;
  gap: 16px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.msg-tabs > * {
  cursor: pointer;
  padding: 6px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-mute);
  border-bottom: 2px solid transparent;
}
.msg-tabs > .active {
  color: var(--fg);
  border-bottom-color: var(--accent-amber);
}

/* Map page legend — uses the existing .map-legend definition above (vertical
   stack at bottom-left of canvas). Just ensure rows have spacing. */
.map-legend > * {
  display: inline-flex; align-items: center; gap: 4px;
}

/* Map page tabs ("PINS RUNS RESPONDERS GEOFENCES FLOOR PLANS" was running together) */
.map-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.map-tabs > * {
  cursor: pointer;
  padding: 4px 2px;
  color: var(--fg-mute);
  border-bottom: 2px solid transparent;
}
.map-tabs > .active {
  color: var(--fg);
  border-bottom-color: var(--accent-amber);
}

/* Map actions row — keep tabs and action buttons on separate logical rows */
.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
}

/* Generic flex-row spacing — used by inspections "5 items · last: —" pattern */
.flex-row { display: flex; align-items: center; gap: 8px; }
.dot-sep::before { content: ' · '; color: var(--fg-mute); margin: 0 4px; }

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 6a — Pin tab + lifecycle, Geofence detail
   ═══════════════════════════════════════════════════════════════════════ */

.pin-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.pin-filter-bar .input { flex: 1; min-width: 200px; }
.pin-filter-bar select { max-width: 180px; }

.pin-list {
  display: flex; flex-direction: column;
  gap: 6px;
}

.pin-row {
  display: flex; align-items: stretch;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 80ms, border-color 80ms;
  overflow: hidden;
  min-height: 64px;
}
.pin-row:hover { background: var(--bg-hover, rgba(245,158,11,0.05)); border-color: var(--accent-amber); }

.pin-row-stripe {
  width: 4px; flex-shrink: 0;
  background: var(--accent-cyan);
}
.pin-row-stripe.sev-low      { background: #22c55e; }
.pin-row-stripe.sev-medium   { background: #eab308; }
.pin-row-stripe.sev-high     { background: #f97316; }
.pin-row-stripe.sev-critical { background: #ef4444; }

.pin-row-body {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  display: flex; flex-direction: column;
  gap: 3px;
}
.pin-row-title-line {
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.pin-row-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}
.pin-row-sub {
  font-size: 12px;
  color: var(--fg-mute);
}
.pin-row-meta {
  font-size: 11px;
  color: var(--fg-mute);
  display: flex; align-items: center;
  gap: 4px; flex-wrap: wrap;
}
.pin-row-meta .sep { opacity: 0.5; }

.pin-row-thumb {
  width: 64px; height: 64px;
  object-fit: cover;
  flex-shrink: 0;
}

.pin-row-closed { opacity: 0.65; }
.pin-row-closed .pin-row-stripe { opacity: 0.4; }

/* Pin detail modal */
.pin-detail-strip {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.pin-detail-title {
  margin: 0 0 12px 0;
  font-size: 18px;
}
.pin-detail-photo {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  background: var(--bg-deep);
  object-fit: contain;
}
.pin-detail-notes {
  margin: 8px 0 12px;
  padding: 10px 12px;
  background: var(--bg-deep, rgba(0,0,0,0.15));
  border-left: 2px solid var(--accent-amber);
  border-radius: 2px;
  font-size: 14px;
  line-height: 1.5;
}

.audit-list {
  display: flex; flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
}
.audit-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.audit-row:last-child { border-bottom: none; }
.audit-label {
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
}
.audit-who { color: var(--fg); }
.audit-when { color: var(--fg-mute); }

/* Geofence detail */
.gf-detail .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px;
  background: var(--bg-deep, rgba(0,0,0,0.15));
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 8px;
}

/* Generic mono font helper used in pin location coords */
.mono { font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 6a.1 — Map location badge (on-site / off-site indicator)
   ═══════════════════════════════════════════════════════════════════════ */

.map-loc-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 500;
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,0.3));
  pointer-events: none;
}
.map-loc-badge.badge-on {
  border-color: #22c55e;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}
.map-loc-badge.badge-off {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.map-loc-badge[hidden] { display: none; }

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 7 — Dispatch pulse, responder profile, theme picker, run reports
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Pulse stat strip ────────────────────────────────────────────────── */
.pulse-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 700px) {
  .pulse-strip { grid-template-columns: repeat(2, 1fr); }
}
.pulse-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-amber);
  padding: 14px 16px;
}
.pulse-tile-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--fg-mute);
  margin-bottom: 4px;
}
.pulse-tile-value {
  font-family: var(--font-cond, var(--font-sans));
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--fg);
}
.pulse-tile-foot {
  font-size: 11px;
  color: var(--fg-mute);
  margin-top: 4px;
}

/* ─── Pulse columns: runs | roster ────────────────────────────────────── */
.pulse-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .pulse-cols { grid-template-columns: 1fr; }
}
.pulse-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px;
  min-height: 200px;
}
.pulse-col-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--fg-mute);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Run rows in dispatch pulse */
.run-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 80ms;
}
.run-row:hover { border-color: var(--accent-amber); }
.run-row-stripe {
  width: 3px;
  flex-shrink: 0;
  background: var(--severity-medium, #eab308);
}
.run-row.sev-critical .run-row-stripe { background: #ef4444; }
.run-row.sev-high     .run-row-stripe { background: #f97316; }
.run-row.sev-medium   .run-row-stripe { background: #eab308; }
.run-row.sev-low      .run-row-stripe { background: #22c55e; }
.run-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.run-row-line1 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.run-row-line1 .run-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
}
.run-row-title { font-weight: 600; font-size: 13px; }
.run-row-sub { font-size: 11px; color: var(--fg-mute); }
.run-row-sub .unassigned {
  color: #f59e0b;
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Roster rows in dispatch pulse */
.roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 80ms;
}
.roster-row:hover { background: rgba(245, 158, 11, 0.05); }
.roster-row:last-child { border-bottom: none; }
.roster-row .status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #6b7280;
}
.status-dot.status-available  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.status-dot.status-on_task    { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.6); }
.status-dot.status-checking   { background: #22d3ee; box-shadow: 0 0 6px rgba(34,211,238,0.6); }
.status-dot.status-off_duty   { background: #6b7280; }
.status-dot.status-unavailable{ background: #ef4444; }
.status-dot.status-offline    { background: #4b5563; }
.roster-body { flex: 1; min-width: 0; }
.roster-name {
  font-weight: 600;
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.roster-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.1);
  padding: 1px 5px;
  border-radius: 2px;
}
.roster-sub {
  font-size: 11px;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Theme picker ────────────────────────────────────────────────────── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.theme-card {
  border: 2px solid var(--border);
  background: var(--bg-card);
  padding: 14px;
  cursor: pointer;
  transition: all 120ms;
  text-align: center;
}
.theme-card:hover { border-color: var(--accent-amber); }
.theme-card.active {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
}
.theme-swatch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 60px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.theme-swatch-bg     { grid-row: 1 / 3; grid-column: 1; }
.theme-swatch-card   { grid-row: 1 / 3; grid-column: 2; opacity: 0.7; }
.theme-swatch-accent { grid-row: 1; grid-column: 1 / 3; height: 8px; align-self: end; }
.theme-swatch-accent2 { grid-row: 2; grid-column: 1 / 3; height: 8px; align-self: start; }
.theme-name {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg);
}

/* ─── Profile modal ───────────────────────────────────────────────────── */
.profile-modal { padding: 4px; }
.profile-photo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.profile-photo {
  width: 120px; height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-amber);
}
.profile-photo-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  font-family: var(--font-cond, var(--font-sans));
  font-size: 36px;
  font-weight: 700;
  color: var(--accent-amber);
}
.profile-name {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.profile-call-tag {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.1);
  padding: 3px 8px;
  border-radius: 3px;
}
.profile-status {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--fg-mute);
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.phone-link {
  color: var(--accent-cyan);
  text-decoration: none;
  font-family: var(--font-mono);
}
.phone-link:hover { text-decoration: underline; }

/* ─── Report detail modal ─────────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--border);
}
.addendum-list { display: flex; flex-direction: column; gap: 8px; }
.addendum-item {
  background: var(--bg-elev);
  border-left: 2px solid var(--accent-cyan);
  padding: 8px 10px;
  font-size: 13px;
}
.addendum-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}

/* ─── Severity color tokens (used by run rows) ─────────────────────────── */
:root {
  --severity-low: #22c55e;
  --severity-medium: #eab308;
  --severity-high: #f97316;
  --severity-critical: #ef4444;
}

/* ─── Better avatar mini ──────────────────────────────────────────────── */
.avatar-mini {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-amber);
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-cond, var(--font-sans));
  font-size: 10px;
  font-weight: 700;
  margin-right: -4px;
}

/* Checkbox label */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-mute);
  cursor: pointer;
  padding: 6px 10px;
}

/* ════════════════════════════════════════════════════════════════════════
   SCAN — Floating action button + modal styling
   ════════════════════════════════════════════════════════════════════════ */
.scan-fab {
  position: fixed;
  right: 18px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0));
  z-index: 850;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #22d3ee, #0ea5b7);
  color: #0a1416;
  font-family: var(--font-cond, var(--font-sans));
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(34, 211, 238, 0.35), 0 2px 6px rgba(0,0,0,0.2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.scan-fab:hover, .scan-fab:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(34, 211, 238, 0.45), 0 3px 8px rgba(0,0,0,0.25);
  outline: none;
}
.scan-fab:active { transform: translateY(0); }
@media (min-width: 900px) {
  .scan-fab { bottom: 24px; }
}
@media (max-width: 480px) {
  .scan-fab-label { display: none; }
  .scan-fab { padding: 14px; }
}

.scan-modal-body { display: flex; flex-direction: column; gap: 14px; }
.scan-help { color: var(--fg-mute); font-size: 13px; line-height: 1.5; margin: 0; }
.scan-status {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  color: var(--fg-mute);
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-manual { display: flex; gap: 8px; }
.scan-manual .form-input { flex: 1; }

/* Native shell tweaks: respect iOS safe-area for the FAB and topbar */
body.is-native .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
body.is-native .mobile-nav { padding-bottom: max(8px, env(safe-area-inset-bottom)); }

/* 3D building view */
.bld3d-shell { position: relative; height: 100%; min-height: 480px; }
.bld3d-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.bld3d-canvas:active { cursor: grabbing; }
.bld3d-toolbar {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
  /* Theme-aware floating panel. Previously a hard-coded dark panel which made
     its own text + ghost buttons (var(--fg)) invisible in light mode. */
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--fg);
  max-width: 220px;
}
/* In-canvas controls always carry a visible fill so they never read as blank
   boxes over the 3D scene, in either theme. */
.bld3d-toolbar { max-width: 240px; }
/* Long building names must wrap inside their buttons, not clip/overflow. */
.bld3d-toolbar .btn {
  background: var(--bg-elev); color: var(--fg); border-color: var(--border-strong);
  white-space: normal; word-break: break-word; text-align: left; line-height: 1.25;
}
.bld3d-toolbar .btn:hover { border-color: var(--accent); }
.bld3d-toolbar .btn.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.bld3d-toolbar .btn.btn-ghost { background: var(--bg); color: var(--fg); }
.bld3d-toolbar .bld3d-title { font-weight: 700; }
.bld3d-toolbar .bld3d-sub { color: var(--fg-mute); font-size: 11px; }
.bld3d-legend {
  position: absolute; bottom: 12px; left: 12px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 11px;
}
.bld3d-legend .chip {
  background: rgba(14,17,24,0.78); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; color: var(--fg-mute);
}
.bld3d-info {
  position: absolute; right: 12px; top: 12px; z-index: 5;
  background: rgba(14,17,24,0.85); backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; max-width: 280px;
  font-size: 12px; line-height: 1.5;
}
.bld3d-info h3 { margin: 0 0 4px 0; font-size: 13px; letter-spacing: .04em; }
.bld3d-info .row { display: flex; justify-content: space-between; gap: 12px; color: var(--fg-mute); }
.bld3d-info .actions { display: flex; gap: 6px; margin-top: 8px; }
.bld3d-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  color: var(--fg-mute); font-size: 13px; text-align: center; padding: 24px;
}

/* ════════════════════════════════════════════════════════════════════════
   LEGAL — login agreement gate + footer links
   ════════════════════════════════════════════════════════════════════════ */
.login-agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-mute);
  margin: 6px 0 14px;
  cursor: pointer;
  user-select: none;
}
.login-agree input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.login-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.login-staff { margin-top: 14px; text-align: center; font-size: 13px; }
.login-staff a { color: var(--accent); }
.login-staff a:hover { text-decoration: underline; }
.login-agree a {
  color: var(--accent, #22d3ee);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.login-agree a:hover { color: #fff; }
.login-legal {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
}
.login-legal a {
  color: var(--fg-mute);
  text-decoration: none;
  text-transform: uppercase;
}
.login-legal a:hover { color: var(--accent, #22d3ee); }

/* ════════════════════════════════════════════════════════════════════════
   USER EDITOR — roles + permissions
   ════════════════════════════════════════════════════════════════════════ */
.role-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px;
}
.role-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  background: rgba(255,255,255,0.02);
  transition: background .15s, border-color .15s;
}
.role-chip:has(input:checked) {
  background: rgba(34,211,238,0.15);
  border-color: #22d3ee;
  color: #22d3ee;
}
.role-chip input { accent-color: #22d3ee; cursor: pointer; }

.perm-wrap { margin-top: 6px; }
.perm-help {
  font-size: 11px; color: var(--fg-mute, #888);
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  line-height: 1.45;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 12px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0,0,0,0.12);
}
.perm-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.perm-row:hover { background: rgba(255,255,255,0.04); }
.perm-row code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--fg);
  background: transparent;
  padding: 0;
}
.perm-row input { accent-color: #22d3ee; cursor: pointer; }

.lockout-warn {
  border: 1px solid rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.08);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  color: #fca5a5;
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════════════════════
   ROLE TOGGLE — topbar pill (dispatcher / responder / admin / owner)
   ════════════════════════════════════════════════════════════════════════ */
.role-toggle {
  position: relative;
  display: inline-flex;
}
.role-toggle-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 12px;
  font-family: var(--font-cond, var(--font-sans));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 4px;
  transition: border-color .15s, background .15s;
}
.role-toggle-btn:hover { border-color: var(--brand-primary); background: var(--bg-elev); }
.role-toggle-label {
  color: var(--fg-mute);
  font-size: 9px;
  letter-spacing: 0.12em;
}
.role-toggle-current {
  color: var(--brand-primary-2);
  text-transform: uppercase;
}
.role-toggle-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: 160px;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 800;
}
.role-toggle-menu.visible { display: block; }
.role-toggle-option {
  padding: 8px 12px;
  font-family: var(--font-cond, var(--font-sans));
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  color: var(--fg);
}
.role-toggle-option:hover { background: var(--bg-hover); }
.role-toggle-option.active {
  color: var(--brand-primary-2);
  background: var(--brand-glow);
}

/* User avatar can show an uploaded photo */
.user-avatar { position: relative; overflow: hidden; }
.user-avatar-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Profile picture picker — used in the user editor */
.profile-pic-field {
  display: flex; align-items: center; gap: 16px;
  margin-top: 4px;
}
.profile-pic-preview {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-elev2);
  flex: 0 0 auto;
}
.profile-pic-controls {
  display: flex; flex-direction: column; gap: 6px;
}
.profile-pic-file {
  font-size: 12px;
}

/* ════════════════════════════════════════════════════════════════════════
   TEXTAREAS — generous defaults; Enter-to-submit hint
   ════════════════════════════════════════════════════════════════════════ */
textarea.input,
textarea.input-tall {
  min-height: 120px;          /* well above the 6-row visual default */
  resize: vertical;
  line-height: 1.55;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
}
textarea.input-tall {
  min-height: 200px;
}
.note-hint {
  font-size: 11px;
  color: var(--fg-mute, #888);
  letter-spacing: 0.02em;
}
.note-hint kbd {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
}
.msg-textarea {
  flex: 1;
  min-height: 38px !important;
  max-height: 200px;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  padding: 9px 12px;
}

/* Optimistic-send states for chat bubbles */
.msg-bubble.pending { opacity: 0.55; }
.msg-bubble.pending .msg-time { font-style: italic; }
.msg-bubble.failed {
  opacity: 0.85;
  border: 1px solid var(--danger, #f87171);
  cursor: pointer;
}
.msg-bubble.failed .msg-time { color: var(--danger, #f87171); font-weight: 600; }

/* Inline photos in chat bubbles + attachment strip in the composer */
.msg-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 4px;
  margin-top: 4px;
  max-width: 280px;
}
.msg-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  cursor: zoom-in;
  display: block;
}
.msg-attach-strip {
  display: flex;
  gap: 6px;
  padding: 4px 8px;
  flex-wrap: wrap;
  background: var(--bg-2, #131a2b);
  border-top: 1px solid var(--border, #2a3340);
}
.msg-attach-tile {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 4px;
  overflow: hidden;
}
.msg-attach-tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.msg-attach-x {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  padding: 0; border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff; font-size: 12px; font-weight: bold;
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* Photo gallery widget — used by run / SOP / equipment forms */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 4px;
}

/* ── Form folders (collapsible by type) ─────────────────────────────── */
.form-folder {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--bg-elev);
  color: var(--fg);
  overflow: hidden;
}
.form-folder > summary.form-folder-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--fg);
  user-select: none;
}
.form-folder > summary.form-folder-summary::-webkit-details-marker { display: none; }
.form-folder > summary.form-folder-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s ease;
  color: var(--fg-mute);
}
.form-folder[open] > summary.form-folder-summary::before { transform: rotate(90deg); }
.form-folder .form-folder-name { flex: 1; }
.form-folder > .grid-cards { padding: 0 12px 12px; }

/* ── Shift log day grouping ─────────────────────────────────────────── */
.shift-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.shift-day-head .shift-day-date {
  font-weight: 700;
  font-size: 15px;
  color: var(--fg);
}

/* ── File / document attachments ────────────────────────────────────── */
.file-gallery .file-list { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
}
.file-row .file-name {
  flex: 1;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.file-row .file-name:hover { text-decoration: underline; }
.file-row .file-icon { flex: none; }
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-2, #131a2b);
  border: 1px solid var(--border, #2a3340);
  border-radius: 4px;
  overflow: hidden;
}
.photo-tile img {
  width: 100%; height: 100%; object-fit: cover;
  cursor: zoom-in;
  display: block;
}
.photo-tile .photo-delete {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px; font-weight: bold;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
}
.photo-tile .photo-delete:hover { background: var(--danger, #f87171); }
.photo-add { position: relative; aspect-ratio: 1; }
.photo-add input.photo-add-input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.photo-add-tile {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  border: 1px dashed var(--border, #2a3340);
  border-radius: 4px;
  color: var(--muted, #94a3b8);
  font-size: 11px; font-weight: bold;
  cursor: pointer;
  background: transparent;
}
.photo-add-tile:hover {
  border-color: var(--accent, #22d3ee);
  color: var(--accent, #22d3ee);
}


/* ── Activity Log search/filter bar ───────────────────────────────────── */
.activity-filter-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.activity-filter-grid .field { margin: 0; }
.activity-filter-actions {
  display: flex;
  gap: 8px;
}
@media (max-width: 860px) {
  .activity-filter-grid { grid-template-columns: 1fr 1fr; }
  .activity-filter-actions { grid-column: 1 / -1; }
}

/* ── Login: product selector + actions ────────────────────────────────── */
.login-products {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 18px;
}
.login-product {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 8px; cursor: pointer; text-align: center;
  background: var(--surface-2, rgba(255,255,255,.03));
  border: 1px solid var(--border, rgba(255,255,255,.10));
  border-radius: 8px; color: var(--fg-mute, #9aa7b8);
  transition: border-color .15s, background .15s, color .15s;
}
.login-product:hover { border-color: var(--accent, #38e0ff); }
.login-product.active {
  border-color: var(--accent, #38e0ff);
  background: color-mix(in srgb, var(--accent, #38e0ff) 12%, transparent);
  color: var(--fg, #e8eef6);
}
.login-product .lp-name { font-weight: 700; letter-spacing: .06em; font-size: 14px; }
.login-product .lp-desc { font-size: 10px; letter-spacing: .04em; opacity: .8; }
.login-actions { display: flex; gap: 8px; margin-top: 12px; }
.login-actions .btn { flex: 1; }
.login-staff { text-align: center; margin-top: 14px; }
.login-staff a {
  color: var(--fg-mute, #8595a8); font-size: 12px; letter-spacing: .04em;
  text-decoration: none;
}
.login-staff a:hover { color: var(--accent, #38e0ff); }

/* ── Signup plan cards ────────────────────────────────────────────────── */
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 14px; }
.plan-card {
  border: 1px solid var(--border, rgba(255,255,255,.12)); border-radius: 10px;
  padding: 14px; cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--surface-2, rgba(255,255,255,.03));
}
.plan-card:hover { border-color: var(--accent, #38e0ff); }
.plan-card.active { border-color: var(--accent, #38e0ff); background: color-mix(in srgb, var(--accent,#38e0ff) 10%, transparent); }
.plan-card .plan-name { font-weight: 700; font-size: 15px; }
.plan-card .plan-price { font-size: 13px; color: var(--accent, #38e0ff); margin: 2px 0 8px; }
.plan-card ul { margin: 0; padding-left: 16px; font-size: 11px; color: var(--fg-mute,#9aa7b8); line-height: 1.5; }
@media (max-width: 620px) { .plan-grid, .login-products { grid-template-columns: 1fr; } }

/* ── Kadys company portal (full-screen overlay) ───────────────────────── */
.kadys-portal {
  position: fixed; inset: 0; z-index: 4000; display: none;
  flex-direction: column; background: var(--bg, #0e1118); color: var(--fg, #e8eef6);
  overflow: auto;
}
.kadys-portal.visible { display: flex; }
.kadys-portal .kp-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border, rgba(255,255,255,.10));
  position: sticky; top: 0; background: var(--bg, #0e1118); z-index: 2;
}
.kadys-portal .kp-top h1 { font-size: 18px; margin: 0; letter-spacing: .04em; }
.kadys-portal .kp-top .kp-sub { font-size: 11px; color: var(--fg-mute,#8595a8); }
.kp-body { padding: 22px; max-width: 1200px; width: 100%; margin: 0 auto; }
.kp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 20px; }
.kp-stat { border: 1px solid var(--border, rgba(255,255,255,.10)); border-radius: 10px; padding: 14px; background: var(--bg-elev); }
.kp-stat .kp-stat-val { font-size: 26px; font-weight: 700; }
.kp-stat .kp-stat-lbl { font-size: 11px; letter-spacing: .06em; color: var(--fg-mute,#8595a8); text-transform: uppercase; }
.kp-badge { font-size: 10px; padding: 2px 8px; border-radius: 999px; letter-spacing: .05em; }
.kp-badge.active { background: rgba(52,211,153,.16); color: #34d399; }
.kp-badge.restricted, .kp-badge.suspended { background: rgba(245,158,11,.16); color: #f59e0b; }

/* ── Login: org-subdomain product dropdown ────────────────────────────── */
.login-orgctx { margin: 4px 0 16px; }
.login-org-name {
  font-family: var(--font-cond);
  font-weight: 700; letter-spacing: .04em; font-size: 15px;
  color: var(--brand-primary-2); margin-bottom: 8px; text-transform: uppercase;
}
.login-product-field { display: block; }
.login-product-field .field-label {
  display: block; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--fg-mute); margin-bottom: 4px;
}
.login-product-field select.input { width: 100%; }

/* ── HazMat quick-reference guide ─────────────────────────────────────── */
.hazmat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.haz-card { cursor: pointer; transition: border-color .15s, transform .05s; }
.haz-card:hover { border-color: var(--brand-primary); }
.haz-card:active { transform: scale(.997); }
.haz-name { font-family: var(--font-cond); font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.haz-synonyms { font-size: 12px; color: var(--fg-mute); margin-top: 2px; }
.haz-also { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em;
  color: var(--brand-primary-2); margin-right: 4px; }
.haz-area-pill {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand-primary) 16%, transparent);
  color: var(--brand-primary-2); border: 1px solid color-mix(in srgb, var(--brand-primary) 35%, transparent);
}
.haz-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--fg-mute); align-items: center; }
.haz-meta b { color: var(--fg-faint); font-weight: 600; font-size: 10px; letter-spacing: .06em; }
.haz-placard { font-family: var(--font-mono); font-size: 11px; color: var(--accent-amber);
  border: 1px solid color-mix(in srgb, var(--accent-amber) 40%, transparent); border-radius: 4px; padding: 1px 6px; }
.haz-tap { margin-top: 8px; font-size: 11px; color: var(--fg-faint); letter-spacing: .04em; }
.haz-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 10px; margin: 10px 0 14px; }
.haz-detail-row .haz-detail-label { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--fg-faint); }
.haz-section { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.haz-section > summary { cursor: pointer; padding: 10px 14px; font-family: var(--font-cond);
  font-weight: 600; letter-spacing: .03em; background: var(--bg-elev2); list-style: none; }
.haz-section > summary::-webkit-details-marker { display: none; }
.haz-section > summary::before { content: '▸ '; color: var(--brand-primary-2); }
.haz-section[open] > summary::before { content: '▾ '; }
.haz-section-body { padding: 12px 14px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: var(--fg); }

/* ════════════════════════════════════════════════════════════════════════
   PHASE 1 — DESIGN-SYSTEM NORMALIZATION
   One sans family + sentence case for all UI chrome. Monospace and
   spaced-caps are reserved for genuine machine values (IDs, tag UIDs, NDC,
   JSON) via the .mono / [data-mono] helpers below. This block is appended
   last so it wins the cascade over the legacy uppercase/mono chrome rules
   without having to rewrite each of them in place. Revert = delete block.
   ════════════════════════════════════════════════════════════════════════ */

/* Chrome typography reset — labels, nav, buttons, headings, tabs, badges. */
.btn,
.nav-label, .nav-item, .user-role,
.status-pill, .status-option,
.mob-item,
.field-label, .form-row label, .form-help, .login-form .form-row label,
.card-title, .card-sub,
.stat-label,
.badge, .severity,
.table thead th, .data-table thead th,
.modal-head h2,
.topbar-title h1, .topbar-sub,
.run-type-label, .run-meta,
.map-tab, .map-tabs, .map-legend, .map-tabs > *,
.msg-tabs > *, .messages-list-tab,
.thread-empty, .cl-btn, .sop-content h2,
.tl-time, .empty-state h3,
.cmdk-section, .cmdk-item-badge,
.qr-label, .draw-mode-banner,
.building-col-title, .loc-selector .field-label,
.audit-label, .roster-sub,
.bld3d-toolbar .bld3d-title,
.kp-stat .kp-stat-lbl,
.login-org-name, .login-product-field .field-label,
.haz-detail-row .haz-detail-label,
.haz-meta b, .role-toggle-current,
.brand-name, .brand-tag, .login-legal a, .login-error {
  font-family: var(--font-sans);
  text-transform: none;
  letter-spacing: normal;
}

/* Headings keep a touch of weight but normal tracking. */
.topbar-title h1, .modal-head h2, .card-title, .empty-state h3, .sop-content h2 {
  letter-spacing: -0.01em;
  font-weight: 700;
}

/* Section/eyebrow labels: small + muted, but sentence/Title case, not caps. */
.nav-label, .stat-label, .field-label, .form-row label, .card-sub {
  font-weight: 600;
  font-size: 11px;
}

/* Single rounded system. */
.card, .stat, .btn, .status-pill, .btn-icon,
input.input, textarea.input, select.input,
.form-row input, .form-row textarea, .form-row select,
.login-form input, .login-shell { border-radius: var(--radius-sm); }
.card, .stat, .login-shell { border-radius: var(--radius); }
.modal { border-radius: var(--radius-lg); }

/* Single accent on interactive chrome (was amber). */
.nav-item.active { border-left-color: var(--accent); }
.nav-item.active svg { color: var(--accent); }
.mob-item.active { color: var(--accent); }
.user-avatar { color: var(--accent); }
input.input:focus, textarea.input:focus, select.input:focus,
.form-row input:focus, .form-row textarea:focus, .form-row select:focus,
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
input.input[type="checkbox"], input[type="checkbox"] { accent-color: var(--accent); }
a.link, .link { color: var(--accent); }

/* Genuine machine values keep monospace. Apply via class. */
.mono, code, .run-id, .tag-uid, .ndc, .json,
.cred-val, .cred-key { font-family: var(--font-mono); }

/* ════════════════════════════════════════════════════════════════════════
   PHASE 12 — MESSAGES (Messenger-style chat)
   List + thread + grouped bubbles + composer, all on Phase 1 tokens.
   ════════════════════════════════════════════════════════════════════════ */
/* Messages fills its page region exactly (no scroll spill past the composer). */
#page-messages.page-view { padding: 0; overflow: hidden; }
.msg-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
  background: var(--bg);
}
.msg-sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-deep);
  min-height: 0;
}
.msg-sidebar .msg-tabs {
  display: flex; gap: 4px; padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.msg-sidebar .msg-tabs .tab {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px; color: var(--fg-mute);
  background: transparent; border: 1px solid transparent;
}
.msg-sidebar .msg-tabs .tab.active {
  background: var(--bg-elev); color: var(--fg); border-color: var(--border);
}
.msg-list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.msg-list .btn { width: 100%; margin: 0 0 8px; }
.msg-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius);
  cursor: pointer; transition: background 120ms;
}
.msg-item:hover { background: var(--bg-hover); }
.msg-item.active { background: var(--accent-soft); }
.msg-item .flex-1 { min-width: 0; }
.channel-hash {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--bg-elev2); color: var(--accent); font-weight: 700; font-size: 18px;
}
.msg-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview { font-size: 12px; color: var(--fg-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-item-time { font-size: 11px; color: var(--fg-faint); margin-left: auto; flex: 0 0 auto; align-self: flex-start; }

/* Thread pane */
.msg-thread { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.msg-thread-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg-deep); flex: 0 0 auto;
}
.msg-thread-head h3 { font-size: 16px; font-weight: 700; }
.msg-thread-body {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 18px; display: flex; flex-direction: column; gap: 4px;
}
.msg-thread > .empty-state, .msg-thread .empty-state {
  margin: auto; text-align: center; color: var(--fg-mute);
}

/* Bubbles — left for others (with avatar), right for me */
.msg-bubble {
  display: flex; flex-direction: column; gap: 2px;
  max-width: 72%; align-self: flex-start;
  margin-top: 8px;
}
.msg-bubble .msg-body {
  background: var(--bg-elev); border: 1px solid var(--border);
  padding: 9px 13px; border-radius: 16px 16px 16px 4px;
  color: var(--fg);
}
.msg-bubble.mine { align-self: flex-end; align-items: flex-end; }
.msg-bubble.mine .msg-body {
  background: var(--accent); color: #fff; border-color: var(--accent);
  border-radius: 16px 16px 4px 16px;
}
.msg-bubble .msg-author { color: var(--fg-mute); font-weight: 600; padding: 0 6px; }
.msg-bubble.mine .msg-author { display: none; }
.msg-bubble .msg-time { padding: 0 8px; color: var(--fg-faint); }
.msg-bubble .msg-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.msg-bubble .msg-photo { width: 140px; height: 140px; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; }

/* Composer */
.msg-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  background: var(--bg-deep); flex: 0 0 auto;
}
.msg-composer .msg-textarea {
  flex: 1; resize: none; border-radius: var(--radius-lg);
  padding: 10px 14px; max-height: 160px;
}
.msg-composer .btn { flex: 0 0 auto; }
.msg-attach-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.msg-attach-tile { position: relative; }
.msg-attach-tile img { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); }
.msg-attach-x {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent-red); color: #fff; font-size: 12px; line-height: 1;
}

@media (max-width: 720px) {
  .msg-shell { grid-template-columns: 1fr; }
  .msg-sidebar { display: var(--msg-mobile-list, flex); }
}
