/* เอาอยู่ — "Disaster Response Command" design system (see screen design/disaster_response_command/DESIGN.md) */

:root {
  color-scheme: dark;
  /* surfaces */
  --bg: #0b1326;
  --lowest: #060e20;
  --low: #131b2e;
  --c: #171f33;
  --high: #222a3d;
  --highest: #2d3449;
  --bright: #31394d;
  --on: #dae2fd;
  --on-var: #bcc9c6;
  --outline: #879391;
  --outline-var: #3d4947;
  /* roles */
  --primary: #6bd8cb;
  --on-primary: #003732;
  --primary-cont: #29a195;
  --secondary: #b4c5ff;
  --secondary-cont: #0053db;
  --tertiary: #ffb3ad;
  --tertiary-cont: #ff5451;
  --on-tertiary: #68000a;
  --error-cont: #93000a;
  --orange: #f97316;
  --amber: #fbbf24;
  /* status + priority */
  --pending: var(--tertiary-cont);
  --accepted: var(--secondary);
  --resolved: var(--primary);
  --p-critical: #ff5451;
  --p-high: #f97316;
  --p-medium: #fbbf24;
  --p-low: #879391;
  --w1: #6bd8cb;
  --w2: #fbbf24;
  --w3: #f97316;
  --w4: #ff5451;
  /* type */
  --sans: 'IBM Plex Sans Thai', 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: 'JetBrains Mono', 'IBM Plex Sans Thai', ui-monospace, Consolas, monospace;
  /* shape + layout */
  --r-sm: 0.25rem;
  --r: 0.375rem;
  --r-lg: 0.5rem;
  --r-xl: 0.75rem;
  --top-h: 64px;
  --nav-h: 76px;
  --gutter: 1rem;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--on);
  font: 400 14px/20px var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  flex: none;
}
.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--on-var); }
.small { font-size: 12px; }
.center { text-align: center; }
.c-primary { color: var(--primary); }
.c-secondary { color: var(--secondary); }
.c-tertiary { color: var(--tertiary-cont); }
.c-amber { color: var(--amber); }
.c-danger { color: var(--p-critical); }
.c-warn { color: var(--p-high); }
.c-info { color: var(--secondary); }
.water-text-ankle { color: var(--w1); }
.water-text-knee { color: var(--w2); }
.water-text-chest { color: var(--w3); }
.water-text-roof { color: var(--w4); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.d-pending { background: var(--pending); }
.d-accepted { background: var(--accepted); }
.d-resolved { background: var(--resolved); }

.ping-dot, .live-dot { position: relative; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--tertiary-cont); flex: none; }
.ping-dot::after, .live-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit;
  animation: ping 1.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.live-dot { width: 8px; height: 8px; background: var(--primary); }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.45; } }
@keyframes strobe { 50% { box-shadow: 0 0 0 3px rgba(255, 84, 81, 0.25), 0 6px 22px rgba(255, 84, 81, 0.6); } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1100;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  display: flex; align-items: center; gap: 12px;
  background: rgba(6, 14, 32, 0.88);
  backdrop-filter: blur(16px);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-row { display: flex; align-items: center; gap: 6px; }
.brand-row b { font-size: 20px; line-height: 26px; font-weight: 700; }
.brand-chip {
  font: 600 10px/14px var(--mono); letter-spacing: 0.08em; color: var(--primary);
  background: rgba(41, 161, 149, 0.2); padding: 2px 6px; border-radius: var(--r-sm);
}
.live { display: flex; align-items: center; gap: 6px; font: 500 10px/14px var(--mono); color: var(--on-var); }
.live .live-dot { background: var(--outline); }
.live .live-dot::after { animation: none; }
.live.on .live-dot { background: var(--primary); }
.live.on .live-dot::after { animation: ping 1.4s cubic-bezier(0, 0, 0.2, 1) infinite; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--r);
  color: var(--on-var); font-weight: 500;
}
.topnav a:hover { color: var(--on); background: var(--c); }
.topnav a.active { color: var(--primary); background: rgba(34, 42, 61, 0.7); }
.topnav a.nav-sos { color: var(--tertiary); background: rgba(147, 0, 10, 0.25); }
.btn-rescuer {
  margin-left: auto; height: 44px; min-width: 44px; padding: 0 12px; border: 0; border-radius: var(--r);
  display: flex; align-items: center; gap: 6px; background: var(--primary); color: var(--on-primary);
  font: 600 12px/16px var(--mono); max-width: 45vw;
}
.btn-rescuer span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-rescuer:active { transform: scale(0.97); }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1100;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 4px env(safe-area-inset-bottom, 0px);
  display: flex; gap: 4px;
  background: rgba(6, 14, 32, 0.9); backdrop-filter: blur(16px);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: var(--r); color: var(--on-var); font: 500 10px/14px var(--mono); text-align: center;
}
.bottomnav a .ms { font-size: 24px; }
.bottomnav a.active { color: var(--primary); background: rgba(34, 42, 61, 0.6); }
.bottomnav a.nav-sos { color: var(--tertiary); background: rgba(147, 0, 10, 0.2); font-weight: 700; }
.bottomnav a.nav-sos .ms { color: var(--tertiary-cont); animation: pulse 1.5s infinite; }

#view { display: block; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); outline: none; }

/* ---------- Buttons / inputs / chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--r-sm);
  font: 600 13px/18px var(--mono); letter-spacing: 0.02em; text-align: center;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.grow { flex: 1; }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 52px; font-size: 14px; }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow); }
.btn-primary:hover { background: #89f5e7; }
.btn-ghost { background: var(--high); color: var(--on); }
.btn-ghost:hover { background: var(--bright); }
.btn-danger { background: var(--tertiary-cont); color: var(--on-tertiary); font-weight: 700; }
.btn-danger:hover { filter: brightness(1.08); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--on-var);
}
.icon-btn:hover { background: var(--high); color: var(--on); }
.icon-btn.lg { width: 48px; height: 48px; background: var(--high); color: var(--on); }
.icon-btn.lg .ms { font-size: 24px; }
.icon-btn.on { color: var(--primary); }
.linkish { background: none; border: 0; padding: 0; color: var(--primary); text-decoration: underline; }

.input, .field input, .field textarea, .field select, .select select {
  width: 100%; padding: 10px 12px; border: 1px solid #475569; border-radius: var(--r-sm);
  background: var(--lowest); color: var(--on);
}
.input:focus, .field input:focus, .field textarea:focus, .field select:focus, .select select:focus { outline: none; border-color: var(--primary-cont); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: var(--tertiary); font-size: 13px; min-height: 1em; }
.form-error:empty { display: none; }
.hint { color: var(--on-var); font-size: 12px; line-height: 16px; display: flex; align-items: center; gap: 4px; }
.hint .ms { font-size: 16px; }
.req { font: 700 10px/14px var(--mono); color: var(--tertiary); margin-left: auto; }

.chips { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips-lbl { display: flex; align-items: center; gap: 2px; flex: none; font: 500 10px/14px var(--mono); color: var(--on-var); }
.chips-lbl .ms { font-size: 14px; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: var(--c); color: var(--on);
  font-size: 12px; white-space: nowrap;
}
.chip .ms { font-size: 16px; }
.chip:hover { background: var(--high); }
.chip.on { border-color: var(--primary); background: rgba(107, 216, 203, 0.12); color: var(--primary); }
.chip-danger { background: rgba(147, 0, 10, 0.3); color: var(--tertiary); }
.chip-danger.on { border-color: var(--p-critical); background: rgba(255, 84, 81, 0.2); color: var(--tertiary); }
.chip-warn { color: #fdba74; }
.chip-warn.on { border-color: var(--p-high); background: rgba(249, 115, 22, 0.15); color: #fdba74; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm);
  font: 700 10px/14px var(--mono); letter-spacing: 0.06em; white-space: nowrap;
}
.badge .ms { font-size: 14px; }
.badge .dot { width: 6px; height: 6px; }
.badge.p-critical { background: var(--p-critical); color: var(--on-tertiary); }
.badge.p-high { background: rgba(249, 115, 22, 0.2); color: #fdba74; border: 1px solid rgba(249, 115, 22, 0.5); }
.badge.p-medium { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
.badge.p-low { background: var(--highest); color: var(--on-var); }
.badge.s-accepted { background: var(--secondary-cont); color: #dbe1ff; }
.badge.s-resolved { background: rgba(107, 216, 203, 0.15); color: var(--primary); border: 1px solid rgba(107, 216, 203, 0.4); }
.badge.soft-danger { background: rgba(255, 84, 81, 0.15); color: var(--tertiary); }
.badge.soft-info { background: rgba(0, 83, 219, 0.2); color: var(--secondary); }
.badge.water-ankle { background: rgba(107, 216, 203, 0.18); color: var(--w1); }
.badge.water-knee { background: rgba(251, 191, 36, 0.18); color: var(--w2); }
.badge.water-chest { background: var(--w3); color: #3b1300; }
.badge.water-roof { background: var(--w4); color: var(--on-tertiary); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm);
  background: var(--highest); font-size: 12px; line-height: 18px; white-space: nowrap;
}
.tag .ms { font-size: 16px; }
.tag-need { background: var(--low); border: 1px solid var(--outline-var); color: var(--primary); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 12px; color: var(--on-var); text-align: center; }
.empty .ms { font-size: 36px; color: var(--outline); }
.notice {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; margin: 0 var(--gutter);
  border-radius: var(--r-sm); background: rgba(0, 83, 219, 0.15); color: var(--secondary); font-size: 13px;
}

/* ---------- Panels & cards ---------- */
.panel {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-lg);
  background: var(--c); border: 1px solid rgba(61, 73, 71, 0.5);
}
.panel-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head h3 { font-size: 18px; line-height: 24px; font-weight: 600; }
.panel-head > :last-child:not(h3):not(.ms) { margin-left: auto; }
.card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 12px;
  padding: 16px 16px 16px 22px; border-radius: var(--r-lg); background: var(--c); box-shadow: var(--shadow);
  transition: background 0.3s;
}
.card.is-active { background: var(--bright); }
.card-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.card.p-critical .card-accent { background: var(--p-critical); box-shadow: 0 0 8px var(--p-critical); }
.card.p-high .card-accent { background: var(--p-high); box-shadow: 0 0 6px var(--p-high); }
.card.p-medium .card-accent { background: var(--p-medium); }
.card.p-low .card-accent { background: var(--p-low); }
.card.s-accepted .card-accent { background: var(--secondary); box-shadow: 0 0 6px var(--secondary-cont); }
.card.s-resolved .card-accent { background: var(--primary); }
.card.s-resolved { opacity: 0.85; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.elapsed { display: inline-flex; align-items: center; gap: 4px; flex: none; font: 500 10px/14px var(--mono); color: var(--on-var); }
.elapsed .ms { font-size: 14px; }
.elapsed.boxed { padding: 4px 8px; border-radius: var(--r-sm); background: var(--low); }
.card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-title h3 { font-size: 20px; line-height: 26px; font-weight: 700; }
a.card-title:hover h3 { color: var(--primary); }
.metric { font: 700 12px/16px var(--mono); color: var(--tertiary); white-space: nowrap; }
.card.s-accepted .metric { color: var(--secondary); }
.card.s-resolved .metric { color: var(--primary); }
.addr { display: flex; align-items: flex-start; gap: 4px; color: var(--on-var); }
.addr .ms { color: var(--tertiary-cont); font-size: 18px; margin-top: 1px; }
.desc { color: var(--on-var); }
.telemetry { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--r-sm); background: var(--low); min-width: 0; }
.tile .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.lbl { font: 500 10px/14px var(--mono); letter-spacing: 0.04em; color: var(--on-var); }
.gauge { display: flex; gap: 4px; height: 6px; }
.gauge i { flex: 1; border-radius: 999px; background: var(--highest); }
.gauge i.on.s1 { background: var(--w1); }
.gauge i.on.s2 { background: var(--w2); }
.gauge i.on.s3 { background: var(--w3); }
.gauge i.on.s4 { background: var(--w4); }
.gauge i.pulse { animation: pulse 1.2s infinite; }
.gauge.lg { height: 10px; gap: 6px; }
.assignee {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  background: rgba(0, 83, 219, 0.2); color: var(--secondary);
}
.assignee > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.assignee b { font: 700 12px/16px var(--mono); color: var(--on); }
.assignee span:not(.ms) { font-size: 12px; color: var(--on-var); }
.assignee .ms { font-size: 22px; }
.assignee.big { padding: 12px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-actions .btn { min-height: 44px; }
.more { width: 100%; margin-top: 4px; }

/* ---------- Map screen ---------- */
.kpis {
  display: flex; gap: 8px; padding: 8px var(--gutter); overflow-x: auto; scrollbar-width: none;
  background: rgba(6, 14, 32, 0.9);
}
.kpis::-webkit-scrollbar { display: none; }
.kpi {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 0;
  border-radius: var(--r-sm); background: var(--c); text-align: left;
}
button.kpi:active { transform: scale(0.97); }
.kpi > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.kpi small { font: 500 10px/14px var(--mono); letter-spacing: 0.06em; }
.kpi b { font-size: 16px; line-height: 20px; }
.kpi em { font: 400 12px/16px var(--sans); color: var(--on-var); font-style: normal; }
.kpi-pending { background: rgba(147, 0, 10, 0.22); color: var(--tertiary); }
.kpi-accepted { background: rgba(0, 83, 219, 0.2); color: var(--secondary); }
.kpi-accepted .dot { background: var(--secondary); }
.kpi-resolved { background: rgba(41, 161, 149, 0.2); color: var(--primary); }
.kpi-resolved .dot { background: var(--primary); }
.kpi-people small { color: var(--on-var); }

.map-stage { position: relative; height: 52vh; min-height: 300px; background: var(--lowest); }
#map, .mini-map, .hotspot-map { background: var(--lowest); }
#map { position: absolute; inset: 0; z-index: 0; }
.map-chip {
  position: absolute; top: 12px; left: 12px; z-index: 500; display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-sm); background: rgba(45, 52, 73, 0.85); backdrop-filter: blur(8px);
  font: 600 10px/14px var(--mono); max-width: calc(100% - 150px);
}
.map-chip .ms { font-size: 15px; }
.map-chip .mono { padding: 0 4px; border-radius: 2px; background: rgba(107, 216, 203, 0.1); white-space: nowrap; }
.map-ctrl { position: absolute; top: 12px; right: 12px; z-index: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.map-ctrl.bottom { top: auto; bottom: 12px; flex-direction: row; }
.ctrl-btn, .ctrl-icon, .ctrl-stack {
  border: 0; border-radius: var(--r-sm); background: rgba(45, 52, 73, 0.92); backdrop-filter: blur(8px);
  box-shadow: var(--shadow); color: var(--on);
}
.ctrl-btn { height: 36px; padding: 0 10px; display: flex; align-items: center; gap: 6px; font: 500 11px/14px var(--mono); }
.ctrl-btn .ms { font-size: 16px; }
.ctrl-btn .state-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--outline); }
.ctrl-btn.on .state-dot { background: var(--primary); }
.map-ctrl.bottom .ctrl-btn.on { color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary-cont); }
.ctrl-icon { width: 36px; height: 36px; display: grid; place-items: center; }
.ctrl-stack { display: flex; flex-direction: column; overflow: hidden; }
.ctrl-stack button { width: 36px; height: 32px; border: 0; background: none; display: grid; place-items: center; }
.ctrl-stack button:hover { color: var(--primary); background: var(--bright); }
.map-legend {
  position: absolute; left: 12px; bottom: 26px; z-index: 500; display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: var(--r-sm); background: rgba(6, 14, 32, 0.85); backdrop-filter: blur(8px);
  font: 500 10px/14px var(--mono); color: var(--on-var);
}
.map-legend span { display: flex; align-items: center; gap: 4px; }
.map-legend b { color: var(--bright); font-weight: 400; }

.sheet { position: relative; z-index: 2; margin-top: -12px; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--low); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45); }
.sheet-head { padding: 10px var(--gutter) 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sheet-handle { width: 48px; height: 4px; border-radius: 999px; background: var(--highest); }
.sheet-title { width: 100%; display: flex; align-items: center; gap: 8px; }
.sheet-title h2 { font-size: 20px; line-height: 26px; font-weight: 700; }
.count-chip { padding: 2px 8px; border-radius: 999px; background: rgba(255, 84, 81, 0.2); color: var(--tertiary); font: 600 10px/14px var(--mono); white-space: nowrap; }
.sheet-filters { padding: 0 var(--gutter) 8px; display: flex; flex-direction: column; gap: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search .ms { position: absolute; left: 12px; color: var(--on-var); pointer-events: none; }
.search input { width: 100%; height: 44px; padding: 0 12px 0 40px; border: 1px solid transparent; border-radius: var(--r-sm); background: var(--lowest); }
.search input:focus { outline: none; border-color: var(--primary-cont); background: var(--c); }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 0; border-radius: var(--r-sm);
  background: var(--highest); color: var(--on-var); font: 600 12px/16px var(--mono); white-space: nowrap;
}
.tab.on { color: var(--on); }
.tab.on.tab-pending { background: var(--tertiary-cont); color: var(--on-tertiary); box-shadow: 0 0 8px rgba(255, 84, 81, 0.4); }
.tab.on.tab-accepted { background: var(--secondary-cont); color: #dbe1ff; }
.tab.on.tab-resolved { background: var(--primary-cont); color: var(--on-primary); }
.tab.on.tab-all { background: var(--bright); }
.tab .blink { width: 6px; height: 6px; border-radius: 50%; background: var(--lowest); animation: pulse 1s infinite; }
.feed { display: flex; flex-direction: column; gap: 12px; padding: 4px var(--gutter) 96px; }
/* Cards must keep their natural height inside scrollable flex columns. */
.feed > *, .col-list > *, .zone-list > * { flex-shrink: 0; }

.sos-fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 1000;
  display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 999px;
  background: var(--tertiary-cont); color: var(--on-tertiary); font: 700 14px/18px var(--mono);
  box-shadow: 0 4px 16px rgba(255, 84, 81, 0.6);
}
.sos-fab .ms { font-size: 24px; animation: pulse 1.2s infinite; }
.sos-fab .halo { position: absolute; inset: 0; border-radius: inherit; background: var(--tertiary-cont); opacity: 0.4; animation: ping 1.8s infinite; z-index: -1; }

/* Map pins */
.pin-wrap { background: none; border: 0; }
.pin { position: relative; width: 28px; height: 28px; }
.pin-dot {
  position: absolute; inset: 2px; display: grid; place-items: center; border-radius: 50%;
  color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); z-index: 1;
}
.pin-dot .ms { font-size: 15px; font-weight: 700; }
.pin.p-critical .pin-dot { inset: 0; background: var(--p-critical); color: var(--on-tertiary); box-shadow: 0 0 12px rgba(255, 84, 81, 0.7); }
.pin.p-high .pin-dot { background: var(--p-high); color: #3b1300; }
.pin.p-medium .pin-dot { background: var(--p-medium); color: #3b2a00; }
.pin.p-low .pin-dot { background: #c7a3a0; color: #2b0b0a; }
.pin.s-accepted .pin-dot { background: var(--secondary-cont); color: #dbe1ff; }
.pin.s-resolved .pin-dot { inset: 5px; background: var(--primary); color: var(--on-primary); opacity: 0.8; }
.pin.s-resolved .pin-dot .ms { font-size: 12px; }
.pin .ping { position: absolute; inset: -2px; border-radius: 50%; background: var(--p-critical); opacity: 0.55; animation: ping 1.6s infinite; }
.pin.s-accepted .ping { background: var(--secondary-cont); opacity: 0.4; }
.pin-label {
  display: none; position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm); white-space: nowrap;
  background: rgba(6, 14, 32, 0.9); box-shadow: var(--shadow); font: 600 10px/14px var(--mono); color: var(--tertiary);
}
.pin-label i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pin.s-accepted .pin-label { color: var(--secondary); }
.pin.s-resolved .pin-label { color: var(--primary); }
.show-labels .pin-label { display: flex; }

/* Leaflet dark overrides */
.leaflet-container { font-family: var(--sans); background: var(--lowest); }
/* Turn light OSM tiles into a navy "night ops" basemap. */
.tiles-dark { filter: invert(1) hue-rotate(185deg) brightness(0.72) contrast(1.15) saturate(0.55); }
.leaflet-control-attribution { background: rgba(6, 14, 32, 0.7) !important; color: var(--outline) !important; font-size: 9px; }
.leaflet-control-attribution a { color: var(--on-var) !important; }
.leaflet-bar a { background: var(--highest); color: var(--on); border-color: var(--outline-var); }
.leaflet-bar a:hover { background: var(--bright); color: var(--primary); }
.leaflet-tooltip { background: var(--highest); color: var(--on); border: 0; box-shadow: var(--shadow); font-family: var(--mono); font-size: 11px; }
.leaflet-tooltip-top::before { border-top-color: var(--highest); }

/* ---------- Page heads (dispatch / analytics) ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px var(--gutter) 12px; }
.page-head h1 { display: flex; align-items: center; gap: 8px; font-size: 24px; line-height: 30px; font-weight: 700; }
.page-head h1 .ms { font-size: 28px; }
.eyebrow { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; letter-spacing: 0.12em; color: var(--on-var); }
.sub { color: var(--on-var); font-size: 13px; margin-top: 2px; }
.head-btns { display: flex; gap: 8px; }
.section-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 20px; line-height: 26px; font-weight: 700; margin-bottom: 12px; }
.section-title .mono { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; margin-left: auto; }

/* ---------- Dispatch board ---------- */
.col-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 var(--gutter); padding: 4px; border-radius: var(--r-lg); background: var(--low); }
.col-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--on-var); font: 600 13px/18px var(--sans);
}
.col-tab span { display: flex; align-items: center; gap: 6px; }
.col-tab b { font-size: 12px; font-weight: 500; }
.col-tab.on { background: var(--high); color: var(--on); }
.col-tab.t-pending.on span { color: var(--tertiary); }
.col-tab.t-accepted.on span { color: var(--secondary); }
.col-tab.t-resolved.on span { color: var(--primary); }
.filter-row { display: flex; align-items: center; gap: 8px; padding: 12px var(--gutter); overflow: hidden; }
.select { position: relative; display: flex; align-items: center; min-width: 0; flex: 0 1 280px; }
.select .ms { position: absolute; left: 10px; font-size: 18px; color: var(--primary); pointer-events: none; }
.select select { padding-left: 34px; height: 40px; appearance: none; background: var(--low); border-color: var(--outline-var); text-overflow: ellipsis; }
.filter-row .chips { flex: 1; }
.board { display: block; padding: 0 var(--gutter) 24px; }
.board .col { display: none; flex-direction: column; gap: 12px; }
.board .col.show { display: flex; }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--low); font: 600 12px/16px var(--mono); letter-spacing: 0.04em;
}
.col-head > .mono { margin-left: auto; padding: 2px 8px; border-radius: var(--r-sm); background: var(--highest); white-space: nowrap; }
.col-pending .col-head { background: rgba(147, 0, 10, 0.3); color: var(--tertiary); }
.col-pending .col-head > .mono { background: rgba(147, 0, 10, 0.6); }
.col-accepted .col-head { color: var(--secondary); }
.col-resolved .col-head { color: var(--primary); }
.col-list { display: flex; flex-direction: column; gap: 12px; }
.dispatch-card { padding: 20px 16px 16px; }
.card-topbar { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.dispatch-card.p-critical .card-topbar { background: linear-gradient(90deg, var(--p-critical), #ff8a80); }
.dispatch-card.p-high .card-topbar { background: var(--p-high); }
.dispatch-card.p-medium .card-topbar { background: var(--p-medium); }
.dispatch-card.p-low .card-topbar { background: var(--p-low); }
.dispatch-card.s-accepted .card-topbar { background: var(--secondary-cont); }
.dispatch-card.s-resolved .card-topbar { background: var(--primary); }
.loc-box { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--r-sm); background: var(--lowest); }
.loc-box p { display: flex; gap: 6px; align-items: flex-start; }
.loc-box .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.loc-box .mono { font-size: 18px; font-weight: 700; }
.need-block { display: flex; flex-direction: column; gap: 6px; }

/* ---------- SOS ---------- */
.sos-screen { display: flex; flex-direction: column; gap: 12px; padding: 12px 0 24px; max-width: 720px; margin: 0 auto; }
.sos-banner { display: flex; align-items: center; gap: 10px; margin: 0 var(--gutter); color: var(--tertiary); font-size: 16px; }
.sos-banner .btn { margin-left: auto; }
.sos-progress { display: flex; flex-direction: column; gap: 8px; margin: 0 var(--gutter); }
.sos-progress .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-weight: 600; }
.gps-badge { padding: 2px 8px; border-radius: var(--r-sm); background: rgba(107, 216, 203, 0.1); color: var(--primary); font-size: 10px; line-height: 14px; text-align: right; }
.gps-badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--amber); }
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bars i { height: 5px; border-radius: 999px; background: var(--highest); }
.bars i.on { background: var(--primary); }
#sosForm { display: flex; flex-direction: column; gap: 12px; }
.sos-step { display: flex; flex-direction: column; gap: 16px; padding: 0 var(--gutter); }
.acc-chip { display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm); background: rgba(107, 216, 203, 0.12); color: var(--primary); font: 600 10px/14px var(--mono); }
.acc-chip:empty { display: none; }
.acc-chip .ms { font-size: 14px; }
.loc-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.loc-line .mono { color: var(--on-var); font-size: 12px; }
.mini-map { height: 200px; border-radius: var(--r-sm); overflow: hidden; }
.group { display: flex; flex-direction: column; gap: 8px; }
.group h3 { display: flex; align-items: center; gap: 6px; font-size: 18px; line-height: 24px; font-weight: 600; }
.group h3.split { justify-content: space-between; }
.water-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.water-opt {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--r-sm);
  background: var(--c); border: 2px solid transparent; cursor: pointer;
}
.water-opt input { position: absolute; opacity: 0; pointer-events: none; }
.water-opt .w-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.water-opt b { font-size: 16px; line-height: 20px; }
.water-opt .mono { font-size: 10px; color: var(--secondary); white-space: nowrap; }
.water-opt small { color: var(--on-var); font-size: 12px; line-height: 16px; }
.water-opt.w-chest b, .water-opt.w-roof b { color: var(--tertiary); }
.water-opt:has(input:checked) { border-color: var(--primary); background: rgba(107, 216, 203, 0.08); }
.water-opt.w-chest:has(input:checked), .water-opt.w-roof:has(input:checked) { border-color: var(--tertiary-cont); background: rgba(255, 84, 81, 0.12); }
.water-opt:has(input:focus-visible) { outline: 2px solid var(--primary); }
.power-row { flex-direction: row; align-items: center; }
.power-row > div { flex: 1; display: flex; flex-direction: column; }
.power-row small { color: var(--tertiary); font-size: 12px; }
.power-toggle { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: var(--error-cont); color: #ffdad6; font-weight: 700; }
.power-toggle.safe { background: rgba(41, 161, 149, 0.3); color: var(--primary); }
.big-stepper .stepper { justify-content: space-between; padding: 8px; background: var(--lowest); }
.big-stepper .step-btn { width: 52px; height: 52px; font-size: 24px; }
.big-stepper .step-val b { font-size: 32px; line-height: 36px; color: var(--primary); }
.stepper { display: flex; align-items: center; gap: 8px; border-radius: var(--r-sm); }
.step-btn { width: 40px; height: 40px; border: 0; border-radius: var(--r-sm); background: var(--high); font-size: 20px; font-weight: 700; }
.step-btn.plus { background: var(--primary); color: var(--on-primary); }
.step-val { min-width: 56px; text-align: center; white-space: nowrap; }
.step-val b { font-size: 18px; }
.vuln-list { display: flex; flex-direction: column; gap: 8px; }
.vuln-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--low); border: 1px solid transparent; }
.vuln-row > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.vuln-row small { font-size: 12px; color: var(--on-var); }
.vuln-row.on { border-color: rgba(107, 216, 203, 0.5); background: rgba(107, 216, 203, 0.06); }
.need-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.need-opt {
  min-height: 52px; padding: 0 8px; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: var(--low); font: 600 12px/16px var(--mono);
}
.need-opt.on { background: var(--high); color: var(--primary); border-color: var(--primary-cont); box-shadow: var(--shadow); }
.step-nav { display: flex; gap: 8px; }
.phone-input { position: relative; display: flex; align-items: center; }
.phone-input .ms { position: absolute; left: 12px; font-size: 22px; }
.phone-input input { width: 100%; height: 56px; padding: 0 12px 0 44px; border: 1px solid #475569; border-radius: var(--r-sm); background: var(--lowest); font: 700 24px/28px var(--mono); }
.phone-input input:focus { outline: none; border-color: var(--primary-cont); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--high); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; background: rgba(6, 14, 32, 0.8); color: var(--on); }
.photo-add { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px dashed var(--outline-var); border-radius: var(--r-sm); background: var(--low); font: 600 10px/14px var(--mono); }
.photo-add .ms { font-size: 26px; }
.fallback { flex-direction: row; align-items: flex-start; background: var(--low); }
.fallback p { color: var(--on-var); font-size: 12px; line-height: 18px; margin-top: 2px; }
.fallback a { color: var(--tertiary); font-weight: 700; }
.sos-sticky {
  position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: flex; flex-direction: column; gap: 8px; padding: 8px var(--gutter) 0;
  background: linear-gradient(to bottom, transparent, var(--bg) 24%);
}
.sos-sticky .form-error { padding: 8px 10px; border-radius: var(--r-sm); background: rgba(147, 0, 10, 0.35); color: #ffdad6; }
.sos-submit {
  min-height: 60px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px;
  border: 0; border-radius: var(--r-sm); background: var(--tertiary-cont); color: var(--on-tertiary);
  font-size: 18px; line-height: 24px; font-weight: 700; animation: strobe 1.5s infinite;
}
.sos-submit .ms { font-size: 28px; font-variation-settings: 'FILL' 1; }
.sos-submit:disabled { animation: none; opacity: 0.7; }
.done-card { margin: 0 var(--gutter); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 16px; border-radius: var(--r-lg); background: var(--c); text-align: center; box-shadow: var(--shadow); }
.done-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: rgba(107, 216, 203, 0.2); color: var(--primary); }
.done-icon .ms { font-size: 40px; }
.done-card h2 { font-size: 22px; line-height: 28px; }
.case-no { font-size: 14px; font-weight: 700; }
.done-card p { color: var(--on-var); }
.done-status { width: 100%; display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: var(--r-sm); background: var(--lowest); text-align: left; }

/* ---------- Case detail ---------- */
.case-screen { display: flex; flex-direction: column; gap: 12px; padding: 12px var(--gutter) 24px; max-width: 1200px; margin: 0 auto; }
.case-top { display: flex; align-items: center; gap: 10px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--on-var); font-weight: 600; }
.back:hover { color: var(--primary); }
.status-banner { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r-lg); }
.status-banner .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-banner .elapsed { margin-left: auto; }
.sb-pending { background: rgba(147, 0, 10, 0.3); border: 1px solid rgba(255, 84, 81, 0.35); color: var(--tertiary); }
.sb-accepted { background: rgba(0, 83, 219, 0.2); border: 1px solid rgba(180, 197, 255, 0.3); color: var(--secondary); }
.sb-resolved { background: rgba(41, 161, 149, 0.15); border: 1px solid rgba(107, 216, 203, 0.3); color: var(--primary); }
.case-grid { display: grid; gap: 12px; }
.case-grid .col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.case-chip { padding: 2px 8px; border-radius: var(--r-sm); background: var(--low); color: var(--primary); font-size: 11px; }
.team-line { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--lowest); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.contact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: var(--r-sm); background: var(--lowest); }
.contact-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contact-row .name { font-size: 18px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.stat-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: var(--r-sm); background: var(--high); text-align: center; }
.stat-tile .ms { font-size: 22px; color: var(--on-var); }
.stat-tile b { font-size: 30px; line-height: 34px; }
.stat-tile span:last-child { font-size: 12px; color: var(--on-var); }
.stat-tile.hot { background: rgba(147, 0, 10, 0.3); }
.stat-tile.hot .ms, .stat-tile.hot b { color: var(--tertiary); }
.water-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.water-head b { margin-left: auto; font-size: 22px; }
.gauge-caption { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.power-line { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; }
.power-line.danger { background: rgba(147, 0, 10, 0.3); color: var(--tertiary); }
.power-line.safe { background: rgba(41, 161, 149, 0.15); color: var(--primary); }
.case-map { height: 220px; }
.checklist { display: flex; flex-direction: column; gap: 6px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-sm); background: var(--low); cursor: pointer; }
.check-row span:not(.ms) { flex: 1; }
.check-row .ms { color: var(--primary); }
.check-row input { width: 22px; height: 22px; accent-color: var(--primary-cont); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.timeline li:not(:last-child)::before { content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--highest); }
.timeline li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.timeline .row { display: flex; justify-content: space-between; gap: 8px; }
.tl-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--high); color: var(--on-var); }
.tl-icon .ms { font-size: 18px; }
.tl-created .tl-icon { background: rgba(255, 84, 81, 0.2); color: var(--tertiary); }
.tl-accepted .tl-icon, .tl-note .tl-icon { background: rgba(0, 83, 219, 0.25); color: var(--secondary); }
.tl-resolved .tl-icon { background: rgba(41, 161, 149, 0.25); color: var(--primary); }
.live-mini { display: flex; align-items: center; gap: 6px; font: 500 10px/14px var(--mono); color: var(--primary); }
.live-mini i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: pulse 1.2s infinite; }

/* ---------- Analytics ---------- */
.analytics-screen { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; }
.analytics-screen > :not(.page-head) { margin: 0 var(--gutter); }
.live-chip { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 2px 8px; border-radius: var(--r-sm); background: rgba(147, 0, 10, 0.3); color: var(--tertiary); font: 700 10px/14px var(--mono); letter-spacing: 0.1em; }
.live-chip .ping-dot { width: 8px; height: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--r-lg); background: var(--c); min-width: 0; }
.kpi-tile .lbl { display: flex; justify-content: space-between; align-items: center; }
.kpi-tile .lbl .ms { font-size: 18px; }
.kpi-tile b { font-size: 30px; line-height: 36px; }
.kpi-tile em { font: 400 13px/16px var(--sans); font-style: normal; color: var(--on-var); margin-left: 2px; }
.kpi-tile small { font-size: 11px; line-height: 15px; color: var(--on-var); }
.kpi-tile.t-danger b, .kpi-tile.t-danger .lbl .ms { color: var(--tertiary-cont); }
.kpi-tile.t-primary b, .kpi-tile.t-primary .lbl .ms { color: var(--primary); }
.map-panel { position: relative; padding: 0; overflow: hidden; gap: 0; }
.hotspot-map { height: 380px; }
.risk-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; font: 500 10px/14px var(--mono); color: var(--on-var); }
.risk-legend .grad { width: 80px; height: 6px; border-radius: 999px; background: linear-gradient(90deg, #29a195, #fbbf24, #f97316, #ff5451); }
.analytics-cols { display: grid; gap: 16px; }
.zone-list { display: flex; flex-direction: column; gap: 12px; }
.zone-card { padding: 16px; }
.zone-card h3 { font-size: 20px; line-height: 26px; font-weight: 700; }
.zone-card .card-top { align-items: center; flex-wrap: wrap; }
.zone-card .card-top .muted { margin-left: auto; }
.zone-badge.z-danger { background: var(--error-cont); color: #ffdad6; }
.zone-badge.z-warn { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
.zone-badge.z-info { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
.zone-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; border-radius: var(--r-sm); background: var(--lowest); }
.zone-stats > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.zone-stats b { font-size: 22px; line-height: 28px; }
.zone-stats b em { font: 400 12px/16px var(--sans); font-style: normal; color: var(--on-var); }
.zone-stats small { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--on-var); }
.zone-stats small .ms { font-size: 14px; color: var(--amber); }
.bottleneck { display: flex; gap: 10px; padding: 12px; border-radius: var(--r-sm); background: rgba(147, 0, 10, 0.25); color: var(--tertiary); }
.bottleneck b { display: block; font: 700 11px/16px var(--mono); letter-spacing: 0.05em; }
.bottleneck p { color: var(--on); font-size: 13px; }
.zone-pin { position: relative; width: 28px; height: 28px; }
.zone-num { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; font: 700 13px/1 var(--mono); color: #fff; border: 2px solid rgba(255, 255, 255, 0.7); }
.zone-pin.z-danger .zone-num { background: var(--p-critical); box-shadow: 0 0 0 8px rgba(255, 84, 81, 0.25), 0 0 24px rgba(255, 84, 81, 0.6); }
.zone-pin.z-warn .zone-num { background: var(--p-high); box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.2); }
.zone-pin.z-info .zone-num { background: #b58900; }
.zone-label {
  position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-sm); background: rgba(6, 14, 32, 0.9); white-space: nowrap; font: 600 11px/15px var(--mono);
}
.zone-label i { width: 6px; height: 6px; border-radius: 50%; background: var(--tertiary-cont); }
.z-warn .zone-label i { background: var(--p-high); }
.z-info .zone-label i { background: var(--amber); }
.reco { gap: 12px; }
.reco-text { font-size: 16px; line-height: 24px; }
.reco h4 { font: 600 12px/16px var(--mono); color: var(--on-var); letter-spacing: 0.04em; }
.equip-sum { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.equip-sum li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--low); }
.equip-sum li span:not(.ms) { flex: 1; }
.equip-sum li .ms { color: var(--primary); }
.equip-sum b { font-size: 16px; color: var(--primary); }

/* ---------- Auth / admin ---------- */
.btn-rescuer:not(.signed-in) { background: var(--high); color: var(--on); }
.auth-screen { display: grid; place-items: center; padding: 32px var(--gutter); min-height: 60vh; }
.auth-card { width: min(420px, 100%); gap: 14px; }
.auth-card h1 { font-size: 22px; line-height: 28px; }
.auth-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: rgba(107, 216, 203, 0.15); color: var(--primary); }
.auth-icon .ms { font-size: 30px; }
.admin-screen { padding-bottom: 24px; }
.admin-cols { display: grid; gap: 16px; padding: 0 var(--gutter); }
.user-card.inactive { opacity: 0.6; }
.user-card .card-title h3 { font-size: 18px; }
.row-inline { display: flex; gap: 8px; }
.row-inline input { flex: 1; }
.dlg-sub { font-size: 14px; color: var(--on-var); margin-top: 4px; }
.contact-row.locked { justify-content: flex-start; background: var(--low); color: var(--on-var); }
.contact-row.locked > .ms { color: var(--amber); font-size: 24px; }
.push-right { margin-left: auto; }
.reporter { border-color: rgba(180, 197, 255, 0.35); }
@media (min-width: 1024px) {
  .admin-cols { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
}

/* ---------- Dialog / toast ---------- */
#dlg {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--outline-var);
  border-radius: var(--r-xl); background: var(--c); color: var(--on); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
#dlg::backdrop { background: rgba(6, 14, 32, 0.75); backdrop-filter: blur(2px); }
.dlg-form { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.dlg-head { display: flex; align-items: center; gap: 8px; }
.dlg-head > .ms { color: var(--primary); font-size: 24px; }
.dlg-head h2 { font-size: 20px; line-height: 26px; flex: 1; }
.dlg-case { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--r-sm); background: var(--lowest); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.quick-notes { display: flex; flex-wrap: wrap; gap: 6px; }
.toast {
  /* Top of screen so it never covers the SOS button or the floating action button. */
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 3000;
  top: calc(var(--top-h) + 12px + env(safe-area-inset-top, 0px));
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--r); background: var(--highest);
  border-left: 4px solid var(--outline); box-shadow: var(--shadow); font-weight: 500;
}
.toast.ok { border-left-color: var(--primary); }
.toast.err { border-left-color: var(--tertiary-cont); }

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  .grid-2, .zone-stats { grid-template-columns: 1fr; }
  .telemetry { grid-template-columns: 1fr; }
}

@media (min-width: 760px) {
  :root { --gutter: 1.5rem; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .case-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .hotspot-map { height: 460px; }
}

@media (min-width: 1024px) {
  :root { --nav-h: 0px; }
  .topnav { display: flex; }
  .btn-rescuer { margin-left: 8px; }
  .bottomnav { display: none; }
  #view { padding-bottom: 0; }

  /* Map screen: map left, feed right, full height */
  .map-screen { display: flex; flex-direction: column; height: calc(100vh - var(--top-h)); }
  .map-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 460px; }
  .map-stage { height: auto; }
  .sheet { margin: 0; border-radius: 0; display: flex; flex-direction: column; min-height: 0; box-shadow: -8px 0 30px rgba(0, 0, 0, 0.35); }
  .sheet-handle { display: none; }
  .feed { flex: 1; overflow-y: auto; padding-bottom: 96px; }
  .sos-fab { bottom: 24px; right: 484px; }

  /* Dispatch: real kanban */
  .col-tabs { display: none; }
  .board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .board .col { display: flex; }

  .analytics-cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
  #recoPanel { position: sticky; top: calc(var(--top-h) + 16px); }
  .sos-sticky { bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
