/* ═══════════════════════════════════════════════════════════
   SEXTON SAFETY SOLUTIONS — CAD DISPATCH
   dispatch.css v1.0
   Dark theme. No framework. No build step.
═══════════════════════════════════════════════════════════ */

/* ── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* backgrounds */
  --bg-base:        #0f1117;
  --bg-surface:     #1a1f2e;
  --bg-raised:      #212736;
  --bg-hover:       #252b3b;
  --bg-input:       #13161f;

  /* borders */
  --border:         #2d3748;
  --border-light:   #1e2433;
  --border-focus:   #3b82f6;

  /* text */
  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #4b5563;
  --text-dim:       #2d3748;

  /* brand / action */
  --blue:           #2563eb;
  --blue-light:     #3b82f6;
  --blue-bg:        #1e3a5f;
  --blue-text:      #60a5fa;

  /* priority */
  --p1:             #ef4444;
  --p1-bg:          #450a0a;
  --p1-text:        #fca5a5;
  --p2:             #f97316;
  --p2-bg:          #431407;
  --p2-text:        #fdba74;
  --p3:             #eab308;
  --p3-bg:          #3f2a00;
  --p3-text:        #fde047;
  --p4:             #3b82f6;
  --p4-bg:          #172554;
  --p4-text:        #93c5fd;

  /* status */
  --green:          #22c55e;
  --green-bg:       #14342a;
  --green-text:     #34d399;
  --green-light:    #86efac;
  --red:            #ef4444;
  --red-bg:         #2d1f1f;
  --red-text:       #f87171;
  --amber:          #eab308;

  /* discipline */
  --fire-bg:        #431407;
  --fire-border:    #f97316;
  --fire-text:      #fdba74;
  --ems-bg:         #14342a;
  --ems-border:     #22c55e;
  --ems-text:       #34d399;
  --law-bg:         #1e2060;
  --law-border:     #818cf8;
  --law-text:       #a5b4fc;

  /* layout */
  --topbar-h:       44px;
  --filter-strip-h: 0px;
  --right-col-w:    310px;
  --radius-sm:      4px;
  --radius-md:      6px;
  --radius-lg:      8px;

  /* type */
  --font: 'SF Pro Display', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ──────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ── LOGIN ────────────────────────────────────────────── */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-product {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.login-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.login-footer {
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.login-reset-link {
  text-align: center;
  margin-top: 14px;
}

.login-reset-link a {
  font-size: 12px;
  color: var(--blue-text);
  text-decoration: none;
}

.login-reset-link a:hover { text-decoration: underline; }

.mfa-prompt {
  text-align: center;
  margin-bottom: 20px;
}

.mfa-icon { font-size: 32px; margin-bottom: 10px; }
.mfa-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.mfa-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* ── FORMS ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  padding: 9px 11px;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--border-focus); }
.form-input::placeholder { color: var(--text-muted); }

.form-input--code {
  text-align: center;
  font-size: 22px;
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  padding: 12px;
}

.form-input--sm { padding: 6px 9px; font-size: 12px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  padding: 9px 11px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%234b5563' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-select:focus { border-color: var(--border-focus); }

.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
  padding: 8px 10px;
  resize: vertical;
  outline: none;
  min-height: 60px;
  line-height: 1.5;
}

.form-textarea:focus { border-color: var(--border-focus); }
.form-textarea::placeholder { color: var(--text-muted); }

.form-error {
  background: var(--p1-bg);
  border: 1px solid var(--p1);
  border-radius: var(--radius-md);
  color: var(--p1-text);
  font-size: 12px;
  padding: 9px 12px;
  margin-bottom: 14px;
  line-height: 1.4;
}

.form-section-title {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
  margin-top: 4px;
}

.form-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── BUTTONS ──────────────────────────────────────────── */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-primary:hover { background: #1d4ed8; }
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary.btn-full { width: 100%; }
.btn-primary.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: var(--font);
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover { border-color: var(--text-muted); color: var(--text-primary); }

.btn-danger {
  background: transparent;
  color: var(--red-text);
  border: 1px solid var(--red-bg);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: var(--font);
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover { background: var(--red-bg); }

/* ── TOPBAR ───────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; flex: 1; min-width: 0; }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-org {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-center {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

.topbar-user {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font);
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.topbar-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }
.topbar-btn.active { border-color: var(--blue-light); color: var(--blue-text); background: rgba(59,130,246,0.08); }
.topbar-btn--danger:hover { border-color: var(--red); color: var(--red-text); }

/* WS status */
.ws-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.ws-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.3s;
}

.ws-dot--connected { background: var(--green); }
.ws-dot--error     { background: var(--red); }
.ws-dot--connecting {
  background: var(--amber);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Filter badge on topbar button */
.filter-badge {
  display: none;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.filter-badge.show { display: flex; }

/* ── FILTER STRIP ─────────────────────────────────────── */
.filter-strip {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #0c1220;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 32px;
}

.filter-strip.show { display: flex; }

.strip-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--blue-text);
  background: var(--blue-bg);
  cursor: default;
}

.strip-tag--fire { background: var(--fire-bg); color: var(--fire-text); border-color: rgba(249,115,22,0.3); }
.strip-tag--ems  { background: var(--ems-bg);  color: var(--ems-text);  border-color: rgba(34,197,94,0.3);  }
.strip-tag--law  { background: var(--law-bg);  color: var(--law-text);  border-color: rgba(129,140,248,0.3); }
.strip-tag--p1   { background: var(--p1-bg);   color: var(--p1-text);   border-color: rgba(239,68,68,0.3);  }
.strip-tag--p2   { background: var(--p2-bg);   color: var(--p2-text);   border-color: rgba(249,115,22,0.3); }
.strip-tag--p3   { background: var(--p3-bg);   color: var(--p3-text);   border-color: rgba(234,179,8,0.3);  }
.strip-tag--p4   { background: var(--p4-bg);   color: var(--p4-text);   border-color: rgba(59,130,246,0.3); }

.strip-x {
  cursor: pointer;
  opacity: 0.6;
  font-size: 12px;
  line-height: 1;
  margin-left: 2px;
}

.strip-x:hover { opacity: 1; }
.strip-clear { color: var(--red-text); background: none; border: none; cursor: pointer; font-size: 11px; font-family: var(--font); margin-left: 4px; }
.strip-clear:hover { text-decoration: underline; }

/* ── BOARD LAYOUT ─────────────────────────────────────── */
.board {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr var(--right-col-w);
  overflow: hidden;
  min-height: 0;
}

/* ── INCIDENTS COLUMN ─────────────────────────────────── */
.incidents-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.col-header-left { display: flex; align-items: center; gap: 8px; }

.col-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.col-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 22px;
  text-align: center;
}

.incidents-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.incidents-list::-webkit-scrollbar { width: 4px; }
.incidents-list::-webkit-scrollbar-track { background: transparent; }
.incidents-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.col-footer {
  padding: 5px 12px;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
}

.col-footer b { color: var(--text-secondary); font-weight: 500; margin-left: 3px; }

/* ── INCIDENT CARD ────────────────────────────────────── */
.inc-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--text-muted);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.1s;
  user-select: none;
}

.inc-card:hover { background: var(--bg-hover); }
.inc-card:focus { outline: 2px solid var(--border-focus); outline-offset: 1px; }

.inc-card[data-priority="1"] { border-left-color: var(--p1); }
.inc-card[data-priority="2"] { border-left-color: var(--p2); }
.inc-card[data-priority="3"] { border-left-color: var(--p3); }
.inc-card[data-priority="4"] { border-left-color: var(--p4); }

.inc-card.is-hidden { display: none; }
.inc-card.is-open .inc-accordion { display: block; }

.inc-main { padding: 9px 11px; }

.inc-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.inc-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.inc-meta { display: flex; align-items: center; gap: 6px; }

.inc-time { font-size: 10px; color: var(--text-muted); }

.priority-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.priority-badge--1 { background: var(--p1-bg); color: var(--p1-text); }
.priority-badge--2 { background: var(--p2-bg); color: var(--p2-text); }
.priority-badge--3 { background: var(--p3-bg); color: var(--p3-text); }
.priority-badge--4 { background: var(--p4-bg); color: var(--p4-text); }

.inc-type {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inc-addr {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inc-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.unit-chip {
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
}

.unit-chip--enroute  { background: var(--blue-bg);   color: var(--blue-text);  }
.unit-chip--onscene  { background: var(--green-bg);  color: var(--green-text); }
.unit-chip--staged   { background: var(--p3-bg);     color: var(--p3-text);    }

.inc-no-units { font-size: 10px; color: var(--text-muted); margin-top: 5px; }

/* Accordion (single click) */
.inc-accordion {
  display: none;
  border-top: 1px solid var(--border-light);
  padding: 9px 11px 10px;
}

.acc-caller {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.acc-caller span { color: var(--text-secondary); }

.acc-note-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.acc-drop-zone {
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.acc-drop-zone.drag-over {
  border-color: var(--blue-light);
  color: var(--blue-text);
  background: rgba(30,58,95,0.4);
}

.acc-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

/* ── RIGHT COLUMN ─────────────────────────────────────── */
.right-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-input);
  overflow: hidden;
  min-height: 0;
}

/* ── MAP PANE ─────────────────────────────────────────── */
.map-pane {
  flex: 0 0 52%;
  position: relative;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #0a1420;
}

/* Override Leaflet for dark theme */
.leaflet-container { background: #0a1420; font-family: var(--font); }
.leaflet-control-zoom a {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { color: var(--text-primary) !important; }
.leaflet-control-attribution {
  background: rgba(15,17,23,0.7) !important;
  color: var(--text-muted) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* Custom map pin */
.map-pin {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #0a1420;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-pin--1 { background: var(--p1); box-shadow: 0 0 0 4px rgba(239,68,68,0.2); }
.map-pin--2 { background: var(--p2); }
.map-pin--3 { background: var(--p3); }
.map-pin--4 { background: var(--p4); }

.map-pin-inner {
  transform: rotate(45deg);
  font-size: 8px;
  font-weight: 700;
  color: #fff;
}

.map-legend {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: flex;
  gap: 8px;
  background: rgba(15,17,23,0.75);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  z-index: 400;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot--p1 { background: var(--p1); }
.legend-dot--p2 { background: var(--p2); }
.legend-dot--p3 { background: var(--p3); }
.legend-dot--p4 { background: var(--p4); }

/* ── UNITS PANE ───────────────────────────────────────── */
.units-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.units-header {
  padding: 6px 12px;
}

.units-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.units-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.units-list::-webkit-scrollbar { width: 3px; }
.units-list::-webkit-scrollbar-track { background: transparent; }
.units-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.agency-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  z-index: 5;
}

.agency-avail { font-weight: 400; text-transform: none; letter-spacing: 0; }
.agency-avail--ok     { color: var(--green-text); }
.agency-avail--warn   { color: var(--p3-text); }
.agency-avail--none   { color: var(--red-text); }

/* Unit row */
.unit-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: grab;
  transition: background 0.1s;
}

.unit-row:hover { background: var(--bg-surface); }
.unit-row:active { cursor: grabbing; }
.unit-row.is-dragging { opacity: 0.4; }
.unit-row.is-hidden { display: none; }

.unit-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
}

.unit-icon--fire { background: var(--fire-bg); }
.unit-icon--ems  { background: var(--ems-bg);  }
.unit-icon--law  { background: var(--law-bg);  }
.unit-icon--other { background: var(--bg-raised); }

.unit-info { flex: 1; min-width: 0; }

.unit-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-type-label {
  font-size: 10px;
  color: var(--text-muted);
}

.unit-status-badge {
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}

.unit-status-badge--available  { background: var(--green-bg); color: var(--green-text); }
.unit-status-badge--dispatched { background: var(--blue-bg);  color: var(--blue-text);  }
.unit-status-badge--enroute    { background: var(--blue-bg);  color: var(--blue-text);  }
.unit-status-badge--onscene    { background: var(--green-bg); color: var(--green-light); }
.unit-status-badge--staged     { background: var(--p3-bg);    color: var(--p3-text);    }
.unit-status-badge--unavailable{ background: var(--red-bg);   color: var(--red-text);   }
.unit-status-badge--oos        { background: var(--bg-raised); color: var(--text-muted); }

/* ── MODALS ───────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal--filter { max-width: 360px; margin: 0 12px; align-self: flex-start; }
.modal--detail { max-width: 640px; margin: 0 16px; }
.modal--unit   { max-width: 400px; margin: 0 16px; }

/* Filter modal: anchor top-right below filter button */
#modal-filter {
  align-items: flex-start;
  justify-content: flex-end;
  padding: 50px 12px 0 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-family: var(--font);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}

.modal-divider { height: 1px; background: var(--border); margin: 0 -16px; }

/* Filter groups */
.filter-group { display: flex; flex-direction: column; gap: 8px; }

.fg-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.fg-pills { display: flex; flex-wrap: wrap; gap: 5px; }

.pill {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.1s;
}

.pill:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.pill.on { border-color: var(--blue-light); background: var(--blue-bg); color: var(--blue-text); }
.pill.on.pill--fire { border-color: var(--fire-border); background: var(--fire-bg); color: var(--fire-text); }
.pill.on.pill--ems  { border-color: var(--ems-border);  background: var(--ems-bg);  color: var(--ems-text);  }
.pill.on.pill--law  { border-color: var(--law-border);  background: var(--law-bg);  color: var(--law-text);  }
.pill.on.pill--p1   { border-color: var(--p1); background: var(--p1-bg); color: var(--p1-text); }
.pill.on.pill--p2   { border-color: var(--p2); background: var(--p2-bg); color: var(--p2-text); }
.pill.on.pill--p3   { border-color: var(--p3); background: var(--p3-bg); color: var(--p3-text); }
.pill.on.pill--p4   { border-color: var(--p4); background: var(--p4-bg); color: var(--p4-text); }

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-label { font-size: 12px; color: var(--text-secondary); }

.toggle-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.toggle-switch.on { background: var(--blue); border-color: var(--blue); }

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 2px;
  left: 2px;
  transition: left 0.15s, background 0.15s;
}

.toggle-switch.on::after { left: 18px; background: #fff; }

/* ── DRAWER ───────────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  justify-content: flex-end;
}

.drawer-overlay.open { display: flex; }

.drawer--right {
  width: 100%;
  max-width: 440px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -12px 0 40px rgba(0,0,0,0.5);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.drawer-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: flex-end;
}

/* ── INCIDENT DETAIL MODAL ────────────────────────────── */
.detail-hero {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.detail-priority-bar {
  width: 4px;
  border-radius: 2px;
  align-self: stretch;
  flex-shrink: 0;
  min-height: 48px;
}

.detail-priority-bar--1 { background: var(--p1); }
.detail-priority-bar--2 { background: var(--p2); }
.detail-priority-bar--3 { background: var(--p3); }
.detail-priority-bar--4 { background: var(--p4); }

.detail-type { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.detail-id   { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.detail-addr { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-field-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.detail-field-value { font-size: 12px; color: var(--text-primary); }

.log-entry {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}

.log-time { color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; font-size: 11px; }
.log-text { color: var(--text-secondary); line-height: 1.4; }
.log-text b { color: var(--text-primary); font-weight: 500; }

/* Disposition codes */
.dispo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dispo-btn {
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: all 0.1s;
}
.dispo-btn:hover { border-color: var(--blue-light); color: var(--text-primary); background: rgba(30,58,95,0.3); }
.dispo-btn.selected { border-color: var(--blue); background: var(--blue-bg); color: var(--blue-text); }

/* ── UNIT DETAIL MODAL ────────────────────────────────── */
.unit-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.unit-status-btn {
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
  transition: all 0.1s;
  color: var(--text-secondary);
}

.unit-status-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }
.unit-status-btn.selected { border-color: var(--green); background: var(--green-bg); color: var(--green-text); }

/* ── TOAST ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-primary);
  max-width: 300px;
  pointer-events: all;
  animation: toast-in 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast--success { border-color: var(--green); }
.toast--error   { border-color: var(--red); }
.toast--info    { border-color: var(--blue-light); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.empty-state-icon { font-size: 28px; margin-bottom: 10px; }

/* ── LOADING SPINNER ──────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --right-col-w: 100%; }

  .board {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 380px;
  }

  .incidents-col { border-right: none; border-bottom: 1px solid var(--border); }

  .right-col { flex-direction: row; }
  .map-pane { flex: 1; border-bottom: none; border-right: 1px solid var(--border); }
  .units-pane { width: 200px; flex: 0 0 200px; }

  .topbar-org { display: none; }
  .topbar-center { display: none; }

  .modal--filter { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  #modal-filter { align-items: flex-end; justify-content: center; padding: 0; }

  .drawer--right { max-width: 100%; }
}

@media (max-width: 480px) {
  .right-col { flex-direction: column; }
  .map-pane  { flex: 0 0 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .units-pane { width: 100%; flex: 1; }
}
