/* ══ EDIT COLORS HERE — theme tokens ════════════════════════════════ */
:root {
  --bg:       #cfe3ef;
  --surface:  #daeaf4;
  --surface2: #ecf5fb;
  --border:   #b8d4e3;
  --accent:   #00475f;
  --accent2:  #d08d3d;
  --accent3:  #3b8771;
  --accent4:  #c0533a;
  --txt:      #2f424d;
  --txt2:     #4a7a8a;
  --txt3:     #7aacba;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{font-family:'DM Sans',sans-serif;background:var(--bg);color:var(--txt);
     font-size:13px;line-height:1.5;display:flex;flex-direction:column}
#topbar{background:#00475f;border-bottom:1px solid #003d52;
  height:68px;padding:0 1.2rem;display:flex;align-items:center;gap:1rem;flex-shrink:0;z-index:200}
.logos{display:flex;align-items:center;gap:.8rem;flex-shrink:0}
.logo-img{height:34px;width:auto;object-fit:contain}
.logo-placeholder{height:34px;min-width:80px;border:1px dashed var(--border);border-radius:4px;
  display:flex;align-items:center;justify-content:center;padding:0 8px;
  font-size:9px;font-weight:600;letter-spacing:.08em;color:var(--txt3)}
.logo-divider{width:1px;height:28px;background:var(--border);flex-shrink:0}
.brand-text{flex:1;min-width:0}
.brand-title{font-family:'DM Sans',sans-serif;font-size:13px;font-weight:700;color:#ecf5fb;letter-spacing:.02em;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-sub{font-size:10px;color:#99d1e3;white-space:nowrap}
.topbar-right{display:flex;align-items:center;gap:.8rem;margin-left:auto;flex-shrink:0}
.ctrl-label{font-size:10px;font-weight:600;color:#99d1e3;letter-spacing:.08em;
  text-transform:uppercase;white-space:nowrap}
.sc-pills{display:flex;gap:3px}
.sc-pill{padding:3px 9px;border-radius:20px;border:1px solid rgba(153,209,227,.4);background:transparent;
  color:#99d1e3;font-family:'DM Sans',sans-serif;font-size:11px;font-weight:500;
  cursor:pointer;transition:all .15s;white-space:nowrap}
.sc-pill:hover{border-color:#ecf5fb;color:#ecf5fb}
.sc-pill.active{background:#99d1e3;border-color:#99d1e3;color:#00475f;font-weight:700}
/* Stacked Hazard + Reach dropdowns; right-aligned so the selects line up on their right edge */
.dropdown-stack{display:flex;flex-direction:column;gap:5px}
.ctrl-row{display:flex;align-items:center;justify-content:flex-end;gap:.5rem}
select#reachSel,select#hazardSel{background:#003d52;border:1px solid rgba(153,209,227,.4);color:#ecf5fb;
  font-family:'DM Sans',sans-serif;font-size:12px;padding:4px 8px;border-radius:6px;
  cursor:pointer;width:200px}
#body{display:flex;flex:1;overflow:hidden;min-height:0}
#leftPanel{width:360px;flex-shrink:0;background:var(--surface);
  border-right:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden}
#leftScroll{flex:1;overflow-y:auto;padding:.9rem 1rem 1.4rem;min-height:0}
#leftScroll::-webkit-scrollbar{width:4px}
#leftScroll::-webkit-scrollbar-track{background:transparent}
#leftScroll::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}
#rightCol{display:flex;flex-direction:column;flex:1;overflow:hidden;min-width:0}
#mapWrap{position:relative;flex:1;min-height:0;overflow:hidden}
#map{width:100%;height:100%;background:#1a2e3a}
#bottomStrip{height:220px;flex-shrink:0;background:var(--surface);
  border-top:1px solid var(--border);display:flex;overflow:hidden}
#stripLeft{width:380px;flex-shrink:0;border-right:1px solid var(--border);
  display:flex;flex-direction:column;padding:.7rem .85rem;overflow:hidden}
#stripRight{flex:1;min-width:0;display:flex;flex-direction:column;
  padding:.7rem .85rem;overflow:hidden}
.strip-title{font-family:'DM Sans',sans-serif;font-size:9px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;
  color:#00475f;margin-bottom:.45rem;flex-shrink:0}
.strip-scroll{flex:1;overflow-y:auto;min-height:0}
.strip-scroll::-webkit-scrollbar{width:4px}
.strip-scroll::-webkit-scrollbar-track{background:transparent}
.strip-scroll::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}
.sec-title{font-family:'DM Sans',sans-serif;font-size:9px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;
  color:#00475f;margin-bottom:.5rem;margin-top:.1rem}
.panel-sep{border:none;border-top:1px solid var(--border);margin:.75rem 0}
.chart-wrap{position:relative;width:100%}
.card{background:var(--surface2);border:1px solid var(--border);border-radius:8px;
  padding:.6rem .7rem;margin-bottom:.5rem}
.card:last-child{margin-bottom:0}
.card-val{font-size:19px;font-weight:700;line-height:1;color:var(--accent)}
.card-val.warm{color:var(--accent2)}
.card-val.green{color:var(--accent3)}
.card-label{font-size:10px;color:var(--txt3);margin-top:3px;line-height:1.3}
.fc-list{margin-top:5px;display:flex;flex-direction:column;gap:2px}
.fc-row{display:flex;justify-content:space-between;font-size:10px;color:var(--txt2)}
.fc-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:155px}
.fc-miles{font-weight:600;color:var(--txt);white-space:nowrap;margin-left:.4rem}
.thresh-row{display:flex;gap:.5rem;margin-bottom:.5rem}
.thresh-card{flex:1;background:var(--surface2);border:1px solid var(--border);
  border-radius:8px;padding:.55rem .7rem}
.thresh-label{font-size:9px;color:var(--txt3);font-weight:600;text-transform:uppercase;
  letter-spacing:.07em;margin-bottom:2px}
.thresh-val{font-size:13px;font-weight:700;color:var(--accent);line-height:1.2}
.thresh-sub{font-size:10px;color:var(--txt2);margin-top:2px}
.vuln-bars{display:flex;flex-direction:column;gap:9px}
.vuln-bar-group{}
.vuln-bar-title{font-size:10px;font-weight:600;color:var(--txt2);margin-bottom:3px}
.vuln-bar-track{display:flex;height:22px;border-radius:3px;overflow:hidden;width:100%}
.vuln-seg{height:100%;transition:width .45s ease;display:flex;align-items:center;
  justify-content:center;font-size:9px;font-weight:700;color:rgba(255,255,255,.95);
  overflow:hidden;white-space:nowrap;min-width:0}
.vuln-legend{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}
.vuln-leg-item{display:flex;align-items:center;gap:3px;font-size:9px;color:var(--txt2)}
.vuln-leg-swatch{width:9px;height:9px;border-radius:2px;flex-shrink:0}
.lu-summary{font-size:10px;color:var(--txt2);margin-bottom:.3rem}
.lu-chart-wrap{position:relative;flex:1;min-height:0;width:100%}
.ds-cat-hdr{font-size:10px;font-weight:700;letter-spacing:.04em;padding:4px 0 3px 7px;
  border-top:1px solid var(--border);margin-top:4px;border-left:3px solid;line-height:1.3;background:transparent}
.ds-cat-hdr:first-of-type{border-top:none;margin-top:0}
.ds-bar-item{padding:3px 0 3px 9px;border-bottom:1px solid rgba(0,71,95,.15)}
.ds-bar-label{display:flex;justify-content:space-between;font-size:10px;color:var(--txt2);margin-bottom:2px}
.ds-bar-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px}
.ds-bar-nums{white-space:nowrap;color:var(--txt3);margin-left:.5rem;flex-shrink:0}
.ds-bar-track{position:relative;height:14px;background:rgba(0,71,95,.08);border-radius:2px;
  overflow:hidden;border:1px solid var(--border)}
.ds-bar-fill{position:absolute;left:0;top:0;height:100%;border-radius:2px;
  transition:width .45s ease;opacity:.75}
.ds-bar-pct{position:absolute;left:5px;top:50%;transform:translateY(-50%);font-size:9px;
  font-weight:700;color:#fff;white-space:nowrap;z-index:1;text-shadow:0 1px 2px rgba(0,0,0,.7)}
.leaflet-container{background:#071820!important}
.leaflet-control-attribution{background:rgba(11,30,43,.8)!important;color:var(--txt3)!important;font-size:9px!important}
.leaflet-control-attribution a{color:var(--txt3)!important}
.leaflet-bar{background:var(--surface2)!important;border-color:var(--border)!important}
.leaflet-bar a{background:var(--surface2)!important;color:var(--txt)!important;border-color:var(--border)!important}
.leaflet-bar a:hover{background:var(--surface)!important}
#mapControls{display:none}
.map-btn{padding:3px 10px;border-radius:16px;border:1px solid rgba(153,209,227,.35);background:transparent;
  color:#99d1e3;font-family:'DM Sans',sans-serif;font-size:10px;font-weight:500;
  cursor:pointer;transition:all .15s}
.map-btn.active{background:#99d1e3;border-color:#99d1e3;color:#00475f;font-weight:700}
.map-btn:hover:not(.active){color:#ecf5fb;border-color:#99d1e3}
#mapLegend{position:absolute;top:10px;right:10px;z-index:500;
  background:rgba(0,71,95,.94);border:1px solid rgba(153,209,227,.25);border-radius:8px;
  padding:.6rem .8rem;min-width:220px;max-width:260px;
  max-height:calc(100% - 20px);overflow-y:auto}
/* ── Accordion layer panel ──────────────────────────────────────────────── */
.acc-item{margin-bottom:3px}
.acc-header{display:flex;align-items:center;gap:5px;padding:4px 7px;border-radius:4px;
  cursor:pointer;border:1px solid rgba(153,209,227,.25);color:#99d1e3;
  font-size:10px;font-weight:500;font-family:'DM Sans',sans-serif;
  user-select:none;transition:all .15s}
.acc-header:hover{color:#ecf5fb;border-color:rgba(153,209,227,.6)}
.acc-header.active{background:rgba(153,209,227,.12);border-color:rgba(153,209,227,.45)}
.acc-arrow{font-size:8px;flex-shrink:0;transition:transform .15s;display:inline-block;color:#99d1e3}
.acc-name{flex:1;min-width:0;display:inline-block;color:#99d1e3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.acc-all-btn{font-size:8px;padding:1px 5px;border-radius:8px;
  border:1px solid rgba(153,209,227,.35);color:#99d1e3;
  background:transparent;cursor:pointer;flex-shrink:0;font-family:'DM Sans',sans-serif}
.acc-all-btn:hover{border-color:#99d1e3;color:#ecf5fb}
.acc-body{flex-direction:column;padding:3px 6px 2px 14px;gap:1px}
.layer-row{display:flex;align-items:center;gap:6px;padding:2px 0;
  font-size:10px;color:#c8dfe9;cursor:pointer;
  font-family:'DM Sans',sans-serif;line-height:1.3}
.layer-row input[type=checkbox]{accent-color:#99d1e3;cursor:pointer;flex-shrink:0}
.layer-row:hover{color:#ecf5fb}
.acc-subhdr{font-size:9px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;
  color:#99d1e3;margin:6px 0 2px;padding-bottom:2px;border-bottom:1px solid rgba(153,209,227,.3)}
.acc-subhdr:first-child{margin-top:1px}
.acc-parenthdr{font-size:10px;font-weight:700;color:#c8dfe9;margin:4px 0 1px}
.layer-row--nested{padding-left:12px}
.leg-title{font-size:9px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;
  color:#99d1e3;margin-bottom:5px}
.leg-row{display:flex;align-items:center;gap:6px;margin-bottom:4px;font-size:11px;color:#c8dfe9}
.leg-swatch{width:14px;height:4px;border-radius:2px;flex-shrink:0}
.leg-circle{width:9px;height:9px;border-radius:50%;flex-shrink:0}
.leg-square{width:10px;height:10px;border-radius:2px;flex-shrink:0}
.leg-sep{border:none;border-top:1px solid rgba(153,209,227,.2);margin:5px 0}
.leg-note{font-size:9px;color:var(--txt3);font-style:italic;margin-top:6px;line-height:1.4}
#loadingMap{position:absolute;inset:0;background:rgba(13,30,43,.7);z-index:400;
  display:none;align-items:center;justify-content:center;flex-direction:column;gap:8px}
#loadingMap.active{display:flex}
.load-map-txt{font-size:11px;color:var(--txt2)}
.map-tooltip{background:var(--surface2)!important;border:1px solid var(--border)!important;
  color:var(--txt)!important;font-family:'DM Sans',sans-serif!important;font-size:12px!important;
  border-radius:6px!important;box-shadow:0 4px 16px rgba(0,0,0,.5)!important;padding:6px 10px!important}
.map-tooltip::before{display:none!important}
#loadingOverlay{position:fixed;inset:0;background:var(--bg);z-index:9999;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem}
.load-title{font-family:'DM Sans',sans-serif;font-size:17px;font-weight:700;color:#00475f}
.load-bar-track{width:200px;height:3px;background:var(--surface2);border-radius:2px;overflow:hidden}
.load-bar-fill{height:100%;background:var(--accent);border-radius:2px;
  animation:lbar 1.4s ease-in-out infinite}
@keyframes lbar{0%{width:0%;margin-left:0}50%{width:60%;margin-left:20%}100%{width:0%;margin-left:100%}}


/* ── Landing disclaimer modal ─────────────────────────────────────────────── */
.disclaimer-modal{ display:none; position:fixed; inset:0; z-index:10000;
  background:rgba(0,0,0,.55); align-items:center; justify-content:center; padding:1.5rem; }
.disclaimer-box{ background:#fff; max-width:760px; width:100%; border-radius:10px;
  padding:1.75rem 1.75rem 1.5rem; box-shadow:0 12px 40px rgba(0,0,0,.3); font-family:'DM Sans',sans-serif; }
.disclaimer-title{ font-size:1.15rem; font-weight:700; color:#00475f; margin-bottom:.75rem; }
.disclaimer-text{ font-size:.9rem; line-height:1.5; color:#333; margin-bottom:1.25rem; }
.disclaimer-text p{ margin:0 0 .85rem; }
.disclaimer-text p:last-child{ margin-bottom:0; }
.disclaimer-text a{ color:#00475f; }
.disclaimer-btn{ background:#00475f; color:#fff; border:none; border-radius:6px;
  padding:.55rem 1.1rem; font-size:.9rem; font-weight:600; cursor:pointer; }
.disclaimer-btn:hover{ background:#016380; }

/* ── Map legend toggle (mobile only; hidden on desktop) ───────────────────── */
#legendToggle{display:none;position:absolute;top:10px;right:10px;z-index:600;
  background:rgba(0,71,95,.94);border:1px solid rgba(153,209,227,.35);color:#ecf5fb;
  font-family:'DM Sans',sans-serif;font-size:11px;font-weight:600;letter-spacing:.04em;
  padding:6px 10px;border-radius:8px;cursor:pointer}

/* ══ MOBILE / NARROW SCREENS ══════════════════════════════════════════════════
   Stack everything vertically: map band on top, then controls, then the panel
   with all charts scrolling beneath. Desktop layout above is untouched. */
@media (max-width:768px){
  html,body{overflow:auto}

  /* Topbar wraps: logos + brand on row 1, controls full-width on row 2 */
  #topbar{height:auto;flex-wrap:wrap;padding:.5rem .8rem;gap:.4rem .8rem;position:sticky;top:0}
  .brand-sub{display:none}
  .brand-title{white-space:normal}
  .logo-img{height:26px}
  .topbar-right{flex-basis:100%;flex-direction:column;align-items:stretch;gap:.5rem;margin-left:0}
  .sc-pills{flex-wrap:wrap}
  .dropdown-stack{width:100%;gap:.4rem}
  .ctrl-row{justify-content:space-between}
  select#reachSel,select#hazardSel{flex:1;width:auto;min-width:0}

  /* Body stacks; map first (order:-1) as a fixed band, panel full-width below */
  #body{flex-direction:column;overflow:visible;flex:none}
  #rightCol{order:-1;flex:none}
  #mapWrap{height:45vh;flex:none}
  #leftPanel{width:100%;flex:none;border-right:none;border-top:1px solid var(--border)}
  #leftScroll{overflow:visible;flex:none}

  /* Collapsible legend: tap "Layers" to reveal it below the button */
  #legendToggle{display:block}
  #mapLegend.collapsed{display:none}
  #mapLegend{top:48px;left:10px;right:10px;max-width:none;width:auto;max-height:calc(100% - 58px)}
}
