/* Layout: map fills the window; a 380px control rail on the left (desktop) becomes a bottom sheet on phones.
   Palette borrows from FAA sectional charts: navy ink, chart blue, airspace magenta. */
:root {
  --bg: #e9edf1;
  --panel: #ffffff;
  --panel-2: #f5f7f9;
  --ink: #13213a;
  --muted: #5a687b;
  --line: #d9e0e7;
  --blue: #1f5fa8;
  --magenta: #a8195c;
  --green: #2b6e49;
  --amber: #b86e00;
  --red: #b3261e;
  --focus: #1f5fa8;
  --display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --rail: 384px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#app { position: fixed; inset: 0; display: flex; }

/* ---------- rail ---------- */
#panel { width: var(--rail); flex: 0 0 var(--rail); height: 100%; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); z-index: 3; position: relative; }
.sheet-handle { display: none; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font: 700 30px/1 var(--display); letter-spacing: .02em; margin: 0; text-transform: uppercase; }
h1::after { content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 7px; border-radius: 50%; background: var(--magenta); vertical-align: 5px; }
.tagline { margin: 6px 0 12px; color: var(--muted); font-size: 13.5px; }
.search { display: flex; gap: 6px; margin-bottom: 12px; }
.search input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.search button { padding: 8px 12px; border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: 6px; font-weight: 600; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 -18px 14px; padding: 0 12px; position: sticky; top: -14px; background: var(--panel); z-index: 2; }
.tab { flex: 1; background: none; border: 0; padding: 10px 4px 9px; font: 600 14px var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.on { color: var(--ink); border-bottom-color: var(--magenta); }
.tabpane { display: none; }
.tabpane.on { display: block; }

.ctl { margin-bottom: 14px; }
.ctl-label { display: block; font: 600 12px var(--display); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.seggroup, .view-toggle { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--panel-2); }
.seg { flex: 1 1 auto; border: 0; background: transparent; padding: 7px 8px; font-size: 13.5px; font-weight: 500; color: var(--muted); border-right: 1px solid var(--line); white-space: nowrap; }
.seg:last-child { border-right: 0; }
.seg.on { background: var(--ink); color: #fff; }
.view-toggle .seg { padding: 5px 12px; font: 600 13px var(--display); letter-spacing: .06em; }
select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* ---------- inspector ---------- */
.inspector { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.insp-empty { color: var(--muted); font-size: 14px; }
.insp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.insp-title { font: 700 19px/1.15 var(--display); margin: 0; }
.insp-sub { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.verdict { display: inline-block; padding: 2px 9px; border-radius: 999px; font: 600 12.5px var(--display); letter-spacing: .05em; text-transform: uppercase; color: #fff; white-space: nowrap; }
.v0 { background: var(--green); } .v1 { background: #5f8d3a; } .v2 { background: var(--amber); } .v3 { background: #c2410c; } .v4 { background: var(--red); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.kpi .k { font: 600 11.5px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi .v { font: 500 22px/1.15 var(--mono); font-variant-numeric: tabular-nums; }
.kpi .u { font-size: 12px; color: var(--muted); }
.kpi.plane .k::before, .kpi.heli .k::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.kpi.plane .k::before { background: var(--blue); } .kpi.heli .k::before { background: var(--magenta); }
.facts { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13.5px; }
.facts li { padding: 6px 0; border-top: 1px dashed var(--line); }
.facts b { font-weight: 600; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 10px; font-size: 13px; font-weight: 600; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }

.pins { margin-top: 14px; }
.pins h3, .layer-group h3 { font: 600 12px var(--display); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.pin { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.pin .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.pin .x { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 0 4px; }

/* ---------- neighbourhood list ---------- */
.sortbar { display: grid; grid-template-columns: auto 1fr 110px; gap: 6px; align-items: center; margin: 10px 0; font-size: 13px; color: var(--muted); }
.hoodlist { display: flex; flex-direction: column; }
.hood { display: grid; grid-template-columns: 1fr 64px; gap: 4px 10px; padding: 9px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.hood:hover { background: var(--panel-2); }
.hood .nm { font-weight: 600; min-width: 0; }
.hood .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.hood .num { text-align: right; font: 500 17px var(--mono); font-variant-numeric: tabular-nums; }
.hood .bar { grid-column: 1 / -1; height: 6px; display: flex; border-radius: 3px; overflow: hidden; background: var(--panel-2); }
.hood .bar i { display: block; height: 100%; }
.hood .bar .p { background: var(--blue); } .hood .bar .h { background: var(--magenta); }
.hood.sel { background: #eef3fa; }

/* ---------- layers ---------- */
.layer-group { margin-bottom: 16px; }
.chk { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.chk input { width: 16px; height: 16px; accent-color: var(--ink); }
.sw { margin-left: auto; width: 26px; height: 8px; border-radius: 4px; flex: 0 0 26px; }
.sw-heat { background: linear-gradient(90deg, #fde7a5, #f59e4b, #d9485f, #6b1f63); }
.sw-proc { background: repeating-linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 11px); height: 3px; }
.sw-tour { background: #cc1a73; } .sw-comm { background: #1a59cc; } .sw-oth { background: #33734d; }
.sw-plane { background: linear-gradient(90deg, #f0f921, #e16462, #6a00a8); } .sw-311 { background: #8c1a59; }
.range-row { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); padding-left: 24px; }
.range-row input { flex: 1; }

/* ---------- about ---------- */
.about { font-size: 14px; }
.about h3 { font: 700 16px var(--display); margin: 16px 0 6px; }
.about p { margin: 0 0 8px; }
.about table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.about td, .about th { border-top: 1px solid var(--line); padding: 4px 4px; text-align: left; vertical-align: top; }
.about th { font: 600 11.5px var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.monthbars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; align-items: end; height: 70px; margin: 8px 0 2px; }
.monthbars div { background: var(--magenta); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.monthlabels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; font: 500 10.5px var(--mono); color: var(--muted); text-align: center; }

/* ---------- map ---------- */
#mapWrap { position: relative; flex: 1; min-width: 0; height: 100%; }
#map, #map3dWrap, #map3d { position: absolute; inset: 0; }
#map3d gmp-map-3d, #map3d > * { width: 100%; height: 100%; }
.legend { position: absolute; left: 12px; bottom: 26px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; z-index: 2; max-width: calc(100% - 24px); box-shadow: 0 1px 4px rgba(19,33,58,.12); }
.legend .t { font: 600 11.5px var(--display); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.legend .ramp { display: flex; }
.legend .ramp span { flex: 1; text-align: center; font: 500 11px var(--mono); padding: 3px 4px 0; border-top: 10px solid; min-width: 30px; }
.presets { position: absolute; top: 12px; left: 12px; display: flex; flex-wrap: wrap; gap: 6px; z-index: 2; max-width: calc(100% - 24px); }
.presets button { background: rgba(19,33,58,.88); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; font: 600 13px var(--display); letter-spacing: .04em; }
.note3d { position: absolute; right: 12px; bottom: 26px; max-width: 320px; background: rgba(255,255,255,.95); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--muted); z-index: 2; }
.toast { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13.5px; z-index: 5; max-width: calc(100% - 32px); }
.keygate { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(233,237,241,.92); z-index: 6; padding: 16px; }
.keygate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 440px; width: 100%; }
.keygate-card h2 { font: 700 22px var(--display); margin: 0 0 8px; }
.keygate-card form { display: flex; gap: 8px; margin-top: 12px; }
.keygate-card input { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--mono); font-size: 13px; }
.keygate-card button { padding: 9px 14px; background: var(--ink); color: #fff; border: 0; border-radius: 6px; font-weight: 600; }

/* map labels drawn by OverlayView */
.maplabel { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; pointer-events: none; font: 600 11.5px/1.1 var(--display); letter-spacing: .03em; color: var(--ink);
  background: rgba(255,255,255,.88); border: 1px solid rgba(19,33,58,.25); border-radius: 4px; padding: 2px 5px; margin-top: -6px; }
.maplabel.proc { color: var(--blue); border-color: rgba(31,95,168,.4); }
.maplabel.heli { color: var(--magenta); border-color: rgba(168,25,92,.35); }
.mapdot { position: absolute; width: 12px; height: 12px; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(19,33,58,.35); pointer-events: none; }
.mapdot.heli { background: var(--magenta); } .mapdot.apt { background: var(--blue); } .mapdot.pin { background: #111; width: 14px; height: 14px; }

/* ---------- phones: bottom sheet ---------- */
@media (max-width: 880px) {
  #app { flex-direction: column; }
  #mapWrap { position: absolute; inset: 0; }
  #panel { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: auto; max-height: 34vh; border-right: 0; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0; box-shadow: 0 -4px 18px rgba(19,33,58,.18); padding-top: 6px; transition: max-height .2s ease; }
  #panel.open { max-height: 82vh; }
  .sheet-handle { display: block; width: 100%; border: 0; background: none; padding: 4px 0 8px; }
  .sheet-handle span { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
  h1 { font-size: 24px; }
  .tagline { display: none; }
  .legend { bottom: calc(34vh + 10px); }
  .tabs { top: -6px; }
  .note3d { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- additions for app.js ---------- */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.keygate-msg { color: var(--red); font-size: 13.5px; margin: 10px 0 0; }
.insp-line { font-size: 14px; margin: 4px 0 4px; }
.kpi-head { margin: 12px 0 -2px; }
.verdict.mini { font-size: 11px; padding: 1px 7px; vertical-align: 1px; }
.facts li.sub { border-top: 0; padding-top: 0; color: var(--muted); font-size: 13px; }
.vdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.hood .rng { grid-column: 1 / -1; height: 4px; position: relative; margin-top: -3px; }
.hood .rng i { position: absolute; top: 1px; height: 2px; background: var(--ink); opacity: .35; border-radius: 1px; }
.hood .det { grid-column: 1 / -1; cursor: default; }
.hood .det .facts { margin-top: 2px; }
.pin-n { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff; font: 600 11px var(--display); margin-right: 7px; vertical-align: 1px; }
.pin-v { font-size: 13px; }

/* info windows */
.iw { font: 13.5px/1.4 var(--body); color: var(--ink); max-width: 300px; }
.iw b:first-child { font: 700 15px/1.2 var(--display); display: block; margin-bottom: 4px; }
.iw p { margin: 4px 0; }
.iw table { border-collapse: collapse; margin-top: 4px; width: 100%; }
.iw td { padding: 2px 0; border-top: 1px solid var(--line); }
.iw td.mono { text-align: right; }

/* map labels and dots */
.maplabel.alt { font: 500 10.5px/1.2 var(--mono); color: var(--blue); background: rgba(255,255,255,.85); border-color: rgba(31,95,168,.3); padding: 0 3px; transform: translate(-50%, -50%); margin: 0; }
.maplabel.hood { background: transparent; border: 0; color: #2b3a52; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; transform: translate(-50%, -50%); margin: 0;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
.maplabel.at-dot { transform: translate(9px, -50%); margin: 0; }
.mapdot.clickable { pointer-events: auto; cursor: pointer; }
.mapdot.clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mapdot.pick { background: #111; width: 14px; height: 14px; box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(17,17,17,.3); border: 0; }
.mapdot.pin { width: 20px; height: 20px; background: var(--ink); color: #fff; font: 600 11px/16px var(--display); text-align: center; }

/* 3D view */
#map3dWrap { background: #10151d; }
.chips3d { position: absolute; left: 12px; bottom: 26px; display: flex; flex-wrap: wrap; gap: 6px; z-index: 2; max-width: calc(100% - 360px); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.94); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font: 600 13px var(--display); letter-spacing: .03em; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip:not(.on) { opacity: .55; }
.chip:not(.on) i { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--muted); }
@media (max-width: 880px) {
  .chips3d { bottom: calc(34vh + 10px); max-width: calc(100% - 24px); }
  .presets button { padding: 5px 10px; font-size: 12px; }
}
.days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 2px 0 8px; }
.dayk { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px 8px; min-width: 0; }
.dayk .k { font: 600 11.5px/1.2 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); min-height: 28px; }
.dayk .k small { display: block; font-weight: 500; letter-spacing: .02em; text-transform: none; font-size: 11.5px; }
.dayk .v { font: 500 24px/1.2 var(--mono); font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.dayk .verdict { font-size: 11px; padding: 1px 7px; }
.earth { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.earth .btn { display: inline-block; text-decoration: none; color: var(--ink); }
