:root {
  --bg: #04132F; --navy: #071E40; --navy2: #0B2A5E; --panel: #0E2F66; --panel2: #123876;
  --line: rgba(135,185,245,.24); --line2: rgba(135,185,245,.38);
  --mint: #4FCB6E; --green: #70D390; --orange: #F59D22; --red: #F0494F; --grey: #7E99BC;
  --text: #F3F8FF; --soft: #B7CAE7; --muted: #7E99BC;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Tahoma, Arial, sans-serif;
  background: linear-gradient(165deg, #030B1D, #071E40 55%, #0B2A5E); color: var(--text);
  line-height: 1.42; -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

/* Phone-sized app column; full-screen on phones */
.screen {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  width: 100%; max-width: 440px; height: 100vh; height: 100dvh; margin: 0 auto; background: var(--navy);
}
@media (min-width: 760px) {
  body { padding: 24px 0; }
  .screen { height: min(880px, calc(100dvh - 48px)); border-radius: 30px; border: 1px solid var(--line2);
    box-shadow: 0 32px 80px -30px rgba(0,0,0,.9); }
}

.app-header {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--panel2); border-bottom: 1px solid var(--line);
}
.brand { font-family: Georgia, serif; font-size: 22px; font-weight: 800; }
.brand span { color: var(--mint); }
.header-actions { display: flex; gap: 6px; }
.chip-btn { font-size: 11px; font-weight: 700; border-radius: 20px; padding: 5px 11px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line2); }
.chip-btn.danger { color: #FFB8BA; background: rgba(240,73,79,.16); border-color: rgba(240,73,79,.4); }
.demo-strip { flex: none; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: #B9F1C7; background: rgba(79,203,110,.1); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(79,203,110,.18); }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 12px; display: block; }

/* Map */
.map-wrap { position: relative; flex: 0 0 210px; border-bottom: 1px solid var(--line); background: #0a1f3d; }
.map { position: absolute; inset: 0; }
.map .leaflet-tile-pane { filter: brightness(.72) saturate(.95) hue-rotate(8deg) contrast(1.04); }
.leaflet-control-attribution { font-size: 8px !important; background: rgba(4,19,47,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--soft) !important; }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }
.map-btn { position: absolute; z-index: 600; inset-inline-end: 8px; top: 8px; width: 34px; height: 34px; border-radius: 10px;
  background: rgba(14,47,102,.92); border: 1px solid var(--line2); color: var(--mint); font-size: 18px; }
.route-info { position: absolute; z-index: 600; inset-inline: 8px; bottom: 8px; padding: 7px 11px; border-radius: 12px;
  background: rgba(7,30,64,.94); border: 1px solid var(--line2); box-shadow: 0 8px 22px rgba(0,0,0,.5); }
.ri-time { font-size: 17px; font-weight: 900; color: var(--mint); line-height: 1.1; }
.ri-time small { font-size: 11px; color: var(--soft); font-weight: 700; }
.ri-sub { font-size: 10.5px; color: var(--muted); }
.lmark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  font-weight: 900; font-size: 13px; color: #04132F; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 4px 10px rgba(0,0,0,.5); background: var(--grey); }
.lmark span { transform: rotate(45deg); }
.lmark.clear { background: var(--green); }
.lmark.busy { background: var(--orange); }
.lmark.critical { background: var(--red); color: #fff; }
.lmark.selected { outline: 3px solid rgba(255,255,255,.7); outline-offset: 2px; }
.lmark.muted { color: #04132F; } /* the general .muted text colour would hide the pin label */
.lyou { width: 18px; height: 18px; border-radius: 50%; background: #3C8DFF; border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(60,141,255,.25); }

/* Filters */
.offline-note { margin: 8px 10px 0; padding: 7px 10px; border-radius: 10px; font-size: 11px; color: #FFD9A6; background: rgba(245,157,34,.13); border: 1px solid rgba(245,157,34,.45); }
.filters { padding: 10px 10px 4px; display: grid; gap: 8px; }
.select-wrap { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.select-wrap.block { display: grid; gap: 5px; margin-bottom: 10px; }
select { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; text-transform: none; letter-spacing: 0; }
.seg { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--soft); padding: 7px 2px; border-radius: 9px; font-size: 12px; font-weight: 600; }
.seg button.active { background: var(--mint); color: #04132F; }

/* Cards */
.list { padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.card { background: rgba(18,56,118,.6); border: 1px solid var(--line); border-radius: 15px; padding: 12px; margin-bottom: 10px; }
.card h2 { font-size: 18px; margin-bottom: 6px; }
.card h3 { font-size: 14px; margin-bottom: 6px; }
.card p { font-size: 12.5px; color: var(--soft); margin-bottom: 6px; }
.warn { color: #FFC9CB !important; }
.rec { margin: 6px 10px 0; padding: 11px 12px; border-radius: 15px; background: rgba(79,203,110,.1); border: 1px solid rgba(79,203,110,.45); }
.rec b { display: block; font-size: 13.5px; }
.rec p { font-size: 11px; color: var(--soft); margin-top: 3px; }
.rec.none { background: rgba(255,255,255,.04); border-color: var(--line); }
.fcard { width: 100%; text-align: start; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start;
  background: rgba(18,56,118,.86); border: 1px solid var(--line); border-radius: 15px; padding: 11px; }
.fcard.selected { border-color: rgba(79,203,110,.8); box-shadow: 0 0 0 1px rgba(79,203,110,.3) inset; }
.fcard.dim { opacity: .62; }
.fcard h3 { font-family: Georgia, serif; font-size: 15px; }
.fcard .sub { font-size: 11.5px; color: var(--soft); margin-top: 2px; }
.fcard .why { font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 10px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; color: var(--soft); }
.tag.fresh { color: #B9F1C7; border-color: rgba(79,203,110,.35); }
.tag.aud { color: #FFD9A6; border-color: rgba(245,157,34,.45); }
.tag.stale { color: #FFB8BA; border-color: rgba(240,73,79,.4); }
.pill { min-width: 76px; text-align: center; border-radius: 12px; padding: 6px 6px; font-size: 11.5px; font-weight: 800; }
.pill b { display: block; color: #fff; font-size: 12px; margin-top: 2px; }
.pill.clear { background: rgba(79,203,110,.18); color: var(--green); }
.pill.busy { background: rgba(245,157,34,.2); color: #FFC56F; }
.pill.critical { background: rgba(240,73,79,.25); color: #FF969B; }
.pill.unknown, .pill.closed, .pill.diversion { background: rgba(255,255,255,.07); color: var(--soft); }
.empty { padding: 16px; text-align: center; color: var(--soft); font-size: 13px; }
.lockout { margin: 10px; padding: 14px; border-radius: 15px; background: rgba(240,73,79,.16); border: 1px solid rgba(240,73,79,.6); }
.lockout b { display: block; color: #FFB8BA; }
.lockout p { font-size: 12px; color: #F3C6C8; margin: 4px 0 10px; }
.loc-note { font-size: 10.5px; color: var(--muted); text-align: center; padding: 0 10px 12px; }

/* Bottom sheet */
.sheet-backdrop { position: absolute; inset: 0; z-index: 900; background: rgba(1,7,18,.5); }
.sheet { position: absolute; z-index: 1000; inset-inline: 0; bottom: 0; max-height: 78%; overflow-y: auto; padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(165deg, var(--navy), var(--navy2)); border-top: 1px solid var(--line2); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 50px rgba(0,0,0,.5); animation: up .22s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet h3 { font-family: Georgia, serif; font-size: 18px; }
.sheet .sub { font-size: 12px; color: var(--soft); }
.x { border: 0; background: rgba(255,255,255,.08); border-radius: 50%; width: 30px; height: 30px; flex: none; }
.notice { margin-top: 10px; padding: 9px 10px; border-radius: 11px; font-size: 11.5px; background: rgba(245,157,34,.13); border: 1px solid rgba(245,157,34,.45); color: #FFD9A6; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.grid3 div { background: rgba(4,19,47,.4); border: 1px solid rgba(135,185,245,.18); border-radius: 10px; padding: 6px 7px; }
.grid3 span { display: block; color: var(--muted); font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em; }
.grid3 b { font-size: 12.5px; }
.nav-link { display: block; margin-top: 12px; text-align: center; text-decoration: none; font-weight: 800; color: #fff; padding: 13px; border-radius: 13px;
  background: linear-gradient(145deg, #3C8DFF, #2D6FE0); box-shadow: 0 6px 16px rgba(60,141,255,.35); }
.nav-link.off { opacity: .4; pointer-events: none; }
.call-link { display: block; margin-top: 12px; text-align: center; text-decoration: none; font-weight: 700; color: var(--text); padding: 12px; border-radius: 13px; border: 1px solid var(--line2, rgba(135,185,245,.38)); }

/* Buttons */
.btn { border: 1px solid var(--line2); background: var(--panel); border-radius: 12px; padding: 10px 13px; font-weight: 700; font-size: 13px; }
.btn.primary { background: var(--mint); color: #04132F; border-color: var(--mint); }
.btn.block { width: 100%; margin-top: 12px; padding: 13px; }
.btn.locked { opacity: .4; pointer-events: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 11px; margin: 8px 2px; }

/* Emergency banner + nav */
.emergency-banner { flex: none; display: flex; align-items: center; gap: 9px; padding: 9px 14px; text-decoration: none;
  border-top: 1px solid rgba(240,73,79,.48); background: linear-gradient(90deg, rgba(240,73,79,.22), rgba(91,45,86,.5)); color: #FF969B; font-weight: 800; font-size: 12px; }
.call-circle { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #FF7379; display: grid; place-items: center; flex: none; }
.navbar { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); background: #0A2E65; }
.navtab { border: 0; background: transparent; color: #94ADD2; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; padding: 4px; }
.navtab .ico { font-size: 17px; }
.navtab.active { color: var(--mint); }

/* Safety gate */
.gate { position: absolute; inset: 0; z-index: 2000; overflow-y: auto; background: linear-gradient(170deg, #061a3c, #04122c 70%); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.gate-lang { position: absolute; top: calc(12px + env(safe-area-inset-top)); inset-inline-end: 14px; }
.gate-inner { padding: calc(32px + env(safe-area-inset-top)) 16px 24px; }
.gate-icon { width: 46px; height: 46px; border-radius: 14px; margin: 0 auto 10px; display: grid; place-items: center; font-size: 26px; font-weight: 900;
  color: #04132F; background: linear-gradient(145deg, var(--mint), #2D9951); }
.gate h2 { text-align: center; font-size: 20px; }
.gate-sub { text-align: center; color: var(--soft); font-size: 12.5px; margin: 6px auto 14px; max-width: 320px; }
.symptoms { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.symptom { display: flex; gap: 8px; align-items: center; padding: 10px 9px; border-radius: 11px; font-size: 12px; line-height: 1.25; color: var(--soft);
  background: rgba(4,19,47,.4); border: 1px solid rgba(135,185,245,.2); cursor: pointer; }
.symptom:has(input:checked) { border-color: rgba(240,73,79,.7); background: rgba(240,73,79,.14); color: #fff; }
.symptom input { width: 17px; height: 17px; flex: none; accent-color: var(--red); }
.danger { margin-top: 14px; padding: 15px; border-radius: 16px; text-align: center; background: rgba(240,73,79,.14); border: 1px solid rgba(240,73,79,.55); }
.danger b { display: block; color: #FFB8BA; font-size: 14px; margin-bottom: 4px; }
.danger > span { display: block; color: #F3C6C8; font-size: 12px; margin-bottom: 12px; }
.call998 { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: #fff; font-weight: 800; font-size: 17px; padding: 15px;
  border-radius: 14px; background: linear-gradient(145deg, #FF3B41, #D11418); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(240,73,79,.18); } }
.gate-note { text-align: center; color: var(--muted); font-size: 10.5px; margin-top: 10px; }

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