/* ══════════════════════════════════════════════
   FloodWatch — North Macedonia
   style.css
   ══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── DESIGN TOKENS ── */
:root {
  --primary:           #0A1628;
  --primary-mid:       #122040;
  --primary-light:     #EFF6FF;
  --accent:            #3B82F6;
  --accent-glow:       rgba(59,130,246,0.15);
  --emergency:         #EF4444;
  --emergency-bg:      #FEF2F2;
  --emergency-border:  #FECACA;
  --emergency-glow:    rgba(239,68,68,0.12);
  --warning:           #F97316;
  --warning-bg:        #FFF7ED;
  --warning-border:    #FED7AA;
  --warning-glow:      rgba(249,115,22,0.12);
  --watch:             #EAB308;
  --watch-bg:          #FEFCE8;
  --watch-border:      #FEF08A;
  --watch-glow:        rgba(234,179,8,0.12);
  --surface:           #FFFFFF;
  --surface-2:         #F8FAFC;
  --bg:                #EDF2F7;
  --border:            #E2E8F0;
  --border-strong:     #CBD5E1;
  --text:              #0F172A;
  --text-mid:          #475569;
  --text-light:        #94A3B8;
  --mono:              'JetBrains Mono', monospace;
  --sans:              'Space Grotesk', sans-serif;
  --radius:            10px;
  --radius-lg:         14px;
  --shadow:            0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:         0 4px 12px rgba(0,0,0,.08), 0 8px 32px rgba(0,0,0,.06);
  --header-height:     54px;
  --sidebar-width:     420px;
  --tab-bar-height:    56px;
}

html, body, #root {
  height: 100%;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}
#root { display: flex; flex-direction: column; }


/* ══════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════ */
.header {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  height: var(--header-height);
  flex-shrink: 0;
  position: relative;
  z-index: 1000;
  overflow: hidden;
}
.header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59,130,246,0.6), transparent);
}

.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-icon { width: 30px; height: 30px; }
.logo-text { font-size: 17px; font-weight: 700; letter-spacing: -.4px; }
.logo-sub { font-size: 10px; font-weight: 400; opacity: .5; letter-spacing: .3px; text-transform: uppercase; margin-top: 1px; }

.header-sep { width: 1px; height: 26px; background: rgba(255,255,255,.1); flex-shrink: 0; }

/* Live badge */
.live-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3);
  border-radius: 20px; padding: 3px 10px 3px 7px;
  font-size: 11px; font-weight: 600; color: #FCA5A5;
  flex-shrink: 0;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #EF4444;
  animation: livePulse 1.4s ease infinite;
}
@keyframes livePulse {
  0%,100% { opacity:1; transform:scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  50%      { opacity:.8; transform:scale(1.1); box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* Metrics strip */
.metrics-strip { display: flex; gap: 0; margin-left: 4px; }
.metric-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-right: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
}
.metric-pill:last-child { border-right: none; }
.metric-val   { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.metric-label { color: rgba(255,255,255,.45); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.metric-trend { font-size: 10px; font-weight: 700; }
.trend-up     { color: #EF4444; }
.trend-stable { color: #94A3B8; }
.trend-down   { color: #34D399; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lang-btn {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.8); border-radius: 6px; padding: 4px 11px;
  font-size: 11px; font-weight: 600; cursor: pointer; font-family: var(--sans);
  transition: all .15s; letter-spacing: .3px;
}
.lang-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* Mobile hamburger / panel toggle */
.mobile-panel-toggle {
  display: none;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  color: #fff; border-radius: 6px; padding: 5px 9px;
  font-size: 16px; cursor: pointer; line-height: 1;
  transition: background .15s;
}
.mobile-panel-toggle:hover { background: rgba(255,255,255,.2); }


/* ══════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════ */
.main { display: flex; flex: 1; overflow: hidden; position: relative; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { width: 100%; height: 100%; }


/* ══════════════════════════════════════════════
   MAP OVERLAYS
   ══════════════════════════════════════════════ */
.map-overlay {
  position: absolute; top: 14px; left: 14px; z-index: 800;
  display: flex; flex-direction: column; gap: 8px;
}
.overlay-card {
  background: rgba(255,255,255,0.95); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 13px; box-shadow: var(--shadow-md);
}
.overlay-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-light); margin-bottom: 7px; }
.legend-items { display: flex; flex-direction: column; gap: 5px; }
.legend-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-count { margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text-mid); }

.map-ctrl {
  position: absolute; bottom: 10px; left: 84px; z-index: 800;
  display: flex; align-items: center; gap: 6px;
}
.map-btn {
  background: rgba(255,255,255,0.95); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 12px; font-size: 11px; font-weight: 600; color: var(--primary);
  cursor: pointer; font-family: var(--sans);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 5px;
  transition: all .15s;
}
.map-btn:hover { background: var(--primary); color: #fff; }

/* Map ctrl group */
.map-ctrl-group {
  position: absolute; bottom: 10px; left: 84px; z-index: 800;
  display: flex; align-items: center; gap: 6px;
}


/* ══════════════════════════════════════════════
   MAP LAYER SWITCHER
   ══════════════════════════════════════════════ */
.layer-switcher {
  position: absolute; top: 14px; right: 14px; z-index: 800;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden;
  min-width: 148px;
}
.layer-switcher-title {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-light);
  padding: 8px 11px 5px; border-bottom: 1px solid var(--border);
}
.layer-list { display: flex; flex-direction: column; }
.layer-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px; background: none; border: none;
  cursor: pointer; font-family: var(--sans); text-align: left;
  transition: background .12s; border-bottom: 1px solid var(--border);
}
.layer-btn:last-child { border-bottom: none; }
.layer-btn:hover  { background: var(--surface-2); }
.layer-btn.active { background: var(--accent-glow); }
.layer-thumb {
  width: 32px; height: 22px; border-radius: 4px;
  flex-shrink: 0; border: 1px solid var(--border);
}
.layer-thumb-satellite { background: linear-gradient(135deg, #1a3a2a 0%, #2d5a3a 40%, #1e4a30 70%, #0f2a1a 100%); }
.layer-thumb-street    { background: linear-gradient(135deg, #e8e0d8 0%, #f5f0e8 50%, #ddd8cc 100%); }
.layer-thumb-terrain   { background: linear-gradient(135deg, #a8c898 0%, #78a868 40%, #b8a878 70%, #c8b888 100%); }
.layer-thumb-dark      { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.layer-thumb-topo      { background: linear-gradient(135deg, #d4e8c2 0%, #a8d4b0 40%, #78b888 70%, #90c4a0 100%); }
.layer-name  { font-size: 11.5px; font-weight: 600; color: var(--text); }
.layer-check { margin-left: auto; color: var(--accent); font-size: 13px; opacity: 0; transition: opacity .15s; }
.layer-btn.active .layer-check { opacity: 1; }


/* ══════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

/* ── TABS ── */
.tabs {
  display: flex; background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1; padding: 13px 6px; font-size: 12px; font-weight: 600;
  color: var(--text-mid); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  font-family: var(--sans); transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--accent); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; border-radius: 20px;
  background: var(--emergency); color: #fff;
  font-size: 9px; font-weight: 700; padding: 0 4px;
}

/* ── SIDEBAR BODY ── */
.sidebar-body {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mobile sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 899; backdrop-filter: blur(2px);
}


/* ══════════════════════════════════════════════
   SECTION HEADER
   ══════════════════════════════════════════════ */
.section-hd {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-light); padding: 4px 0 2px; display: flex; align-items: center; gap: 8px;
}
.section-hd::after { content:''; flex:1; height:1px; background:var(--border); }


/* ══════════════════════════════════════════════
   ALERT CARD
   ══════════════════════════════════════════════ */
.alert-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 13px 13px 13px 17px;
  cursor: pointer; transition: all .18s;
  position: relative; overflow: hidden;
  animation: fadeUp .3s ease both;
}
.alert-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  border-radius: 14px 0 0 14px;
}
.alert-card.emergency::before { background: var(--emergency); }
.alert-card.warning::before   { background: var(--warning); }
.alert-card.watch::before     { background: var(--watch); }
.alert-card.emergency { box-shadow: 0 0 0 0 transparent; }
.alert-card.emergency:hover { box-shadow: 0 4px 20px var(--emergency-glow); border-color: var(--emergency-border); transform: translateY(-1px); }
.alert-card.warning:hover   { box-shadow: 0 4px 20px var(--warning-glow);   border-color: var(--warning-border);   transform: translateY(-1px); }
.alert-card.watch:hover     { box-shadow: 0 4px 20px var(--watch-glow);     border-color: var(--watch-border);     transform: translateY(-1px); }
.alert-card.selected.emergency { border-color: var(--emergency); box-shadow: 0 0 0 2px var(--emergency-glow), 0 4px 20px var(--emergency-glow); }
.alert-card.selected.warning   { border-color: var(--warning);   box-shadow: 0 0 0 2px var(--warning-glow); }
.alert-card.selected.watch     { border-color: var(--watch);     box-shadow: 0 0 0 2px var(--watch-glow); }

@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.alert-card:nth-child(2){animation-delay:.04s} .alert-card:nth-child(3){animation-delay:.08s}
.alert-card:nth-child(4){animation-delay:.12s} .alert-card:nth-child(5){animation-delay:.16s}
.alert-card:nth-child(6){animation-delay:.20s}

.alert-top { display: flex; align-items: flex-start; gap: 8px; }
.sev-badge {
  padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; white-space: nowrap; flex-shrink: 0;
}
.sev-emergency { background: var(--emergency-bg); color: var(--emergency); border: 1px solid var(--emergency-border); }
.sev-warning   { background: var(--warning-bg);   color: var(--warning);   border: 1px solid var(--warning-border); }
.sev-watch     { background: var(--watch-bg);     color: var(--watch);     border: 1px solid var(--watch-border); }

.alert-loc  { font-size: 13.5px; font-weight: 700; color: var(--text); flex: 1; line-height: 1.2; }
.alert-time { font-size: 10px; color: var(--text-light); white-space: nowrap; font-family: var(--mono); }

.alert-meta-row { display: flex; align-items: center; gap: 10px; margin-top: 5px; }
.alert-river        { font-size: 11.5px; color: var(--text-mid); }
.alert-river strong { color: var(--accent); font-weight: 600; }

/* Impact icons */
.impact-icons { display: flex; gap: 4px; margin-left: auto; }
.impact-icon {
  display: flex; align-items: center; gap: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 6px;
  font-size: 10px; color: var(--text-mid); font-weight: 500;
}
.impact-icon.active { background: #FEF2F2; border-color: #FECACA; color: var(--emergency); }

.alert-desc { font-size: 12px; color: var(--text-mid); margin-top: 7px; line-height: 1.55; }


/* ══════════════════════════════════════════════
   GAUGE BAR
   ══════════════════════════════════════════════ */
.gauge-wrap   { margin-top: 10px; }
.gauge-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.gauge-label  { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-light); }
.gauge-val-row { display: flex; align-items: baseline; gap: 5px; }
.gauge-val    { font-family: var(--mono); font-size: 16px; font-weight: 700; }
.gauge-unit   { font-size: 10px; color: var(--text-light); }
.gauge-trend-label { font-size: 10px; font-weight: 700; display: flex; align-items: center; gap: 2px; }

.gauge-bar-bg   { height: 5px; background: var(--border); border-radius: 10px; overflow: hidden; position: relative; }
.gauge-bar-fill { height: 100%; border-radius: 10px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.gauge-bar-threshold { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-light); border-radius: 1px; }
.gauge-bar-labels      { display: flex; justify-content: space-between; margin-top: 3px; }
.gauge-bar-labels span { font-size: 9px; color: var(--text-light); font-family: var(--mono); }

/* Sparkline */
.sparkline-wrap  { margin-top: 8px; }
.sparkline-label { font-size: 9px; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }

/* Alert actions */
.alert-actions { display: flex; gap: 7px; margin-top: 10px; }
.btn-sm { padding: 5px 11px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: var(--sans); border: none; transition: all .15s; }
.btn-primary          { background: var(--primary); color: #fff; }
.btn-primary:hover    { background: #1e3a5f; }
.btn-ghost            { background: none; border: 1px solid var(--border); color: var(--text-mid); }
.btn-ghost:hover      { background: var(--bg); }
.btn-danger           { background: var(--emergency-bg); border: 1px solid var(--emergency-border); color: var(--emergency); }


/* ══════════════════════════════════════════════
   DASHBOARD TAB
   ══════════════════════════════════════════════ */
.dash-wrap { display: flex; flex-direction: column; gap: 10px; }
.dash-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-light); margin-bottom: 2px; display: flex; align-items: center; gap: 8px;
}
.dash-section-title::after { content:''; flex:1; height:1px; background:var(--border); }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 11px 13px;
}
.stat-card-label { font-size: 10px; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-card-val   { font-family: var(--mono); font-size: 22px; font-weight: 700; margin-top: 2px; line-height: 1; }
.stat-card-sub   { font-size: 10px; color: var(--text-mid); margin-top: 3px; }
.stat-card-trend { font-size: 11px; font-weight: 700; margin-top: 4px; }

/* Basin gauge */
.basin-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 12px 14px;
}
.basin-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.basin-row:last-child  { border-bottom: none; padding-bottom: 0; }
.basin-row:first-child { padding-top: 0; }
.basin-name     { font-size: 12px; font-weight: 600; min-width: 90px; }
.basin-bar-wrap { flex: 1; }
.basin-bar-bg   { height: 6px; background: var(--border); border-radius: 6px; overflow: hidden; }
.basin-bar-fill { height: 100%; border-radius: 6px; transition: width .6s; }
.basin-val   { font-family: var(--mono); font-size: 11px; font-weight: 700; min-width: 42px; text-align: right; }
.basin-trend { font-size: 11px; font-weight: 700; min-width: 16px; text-align: center; }

/* 24h chart */
.chart-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 12px 14px;
}
.chart-title     { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.chart-sub       { font-size: 10px; color: var(--text-light); margin-bottom: 10px; }
.chart-zone-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.chart-zone-tab {
  padding: 3px 9px; border-radius: 20px; font-size: 10px; font-weight: 600;
  border: 1px solid var(--border); background: none; cursor: pointer; font-family: var(--sans);
  color: var(--text-mid); transition: all .15s;
}
.chart-zone-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Impact summary */
.impact-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 12px 14px;
}
.impact-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.impact-row:last-child { border-bottom: none; }
.impact-label        { display: flex; align-items: center; gap: 7px; color: var(--text-mid); }
.impact-value        { font-weight: 700; font-family: var(--mono); font-size: 13px; }
.impact-value.red    { color: var(--emergency); }
.impact-value.orange { color: var(--warning); }
.impact-value.yellow { color: var(--watch); }


/* ══════════════════════════════════════════════
   REPORT FORM
   ══════════════════════════════════════════════ */
.report-wrap  { padding: 2px; }
.report-intro {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border-radius: var(--radius); padding: 11px 13px; margin-bottom: 12px; border: 1px solid #BFDBFE;
}
.report-intro p { font-size: 12px; color: #1E40AF; line-height: 1.5; }
label { font-size: 11.5px; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; }
.form-group { margin-bottom: 11px; }
input[type=text], input[type=tel], textarea, select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-size: 13px; font-family: var(--sans);
  color: var(--text); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=tel]:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
textarea { resize: vertical; min-height: 75px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
.sev-selector { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.sev-opt      { padding: 8px 6px; border-radius: 8px; border: 1.5px solid var(--border); text-align: center; cursor: pointer; transition: all .15s; }
.sev-opt input { display: none; }
.sev-opt.sel-emergency { border-color: var(--emergency); background: var(--emergency-bg); }
.sev-opt.sel-warning   { border-color: var(--warning);   background: var(--warning-bg); }
.sev-opt.sel-watch     { border-color: var(--watch);     background: var(--watch-bg); }
.sev-opt-label { font-size: 10.5px; font-weight: 700; margin-top: 2px; display: block; letter-spacing: .3px; }
.sev-opt.sel-emergency .sev-opt-label { color: var(--emergency); }
.sev-opt.sel-warning   .sev-opt-label { color: var(--warning); }
.sev-opt.sel-watch     .sev-opt-label { color: var(--watch); }
.btn-submit {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); font-size: 13px; font-weight: 700;
  font-family: var(--sans); cursor: pointer; transition: background .15s; margin-top: 4px;
}
.btn-submit:hover:not(:disabled) { background: #1e3a5f; }
.btn-submit:disabled { opacity: .5; cursor: not-allowed; }
.success-card {
  background: #F0FDF4; border: 1.5px solid #86EFAC; border-radius: var(--radius-lg);
  padding: 20px; text-align: center; margin-top: 8px;
}
.success-icon   { font-size: 28px; margin-bottom: 8px; }
.success-card h3 { font-size: 15px; font-weight: 700; color: #166534; }
.success-card p  { font-size: 12px; color: #15803D; margin-top: 4px; }


/* ══════════════════════════════════════════════
   HISTORY TAB
   ══════════════════════════════════════════════ */
.hist-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 11px 13px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
}
.hist-date   { font-size: 10px; color: var(--text-light); font-family: var(--mono); white-space: nowrap; }
.hist-loc    { font-size: 13px; font-weight: 600; }
.hist-detail { font-size: 11px; color: var(--text-mid); margin-top: 2px; }
.hist-right  { text-align: right; }
.hist-peak   { font-size: 11.5px; font-weight: 700; font-family: var(--mono); }
.hist-dur    { font-size: 10px; color: var(--text-light); margin-top: 1px; }


/* ══════════════════════════════════════════════
   LEAFLET TWEAKS
   ══════════════════════════════════════════════ */
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow-md) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-control-zoom a { font-family: var(--sans) !important; color: var(--primary) !important; border-bottom: 1px solid var(--border) !important; }
.leaflet-control-attribution { font-size: 9px !important; }
.sim-tooltip-clean { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; }
.sim-tooltip-clean::before { display: none !important; }


/* ══════════════════════════════════════════════
   SIMULATION BUTTON
   ══════════════════════════════════════════════ */
.sim-btn {
  background: linear-gradient(135deg, #7C3AED, #4F46E5);
  border: 1px solid rgba(124,58,237,0.5);
  color: #fff; border-radius: var(--radius);
  padding: 7px 13px; font-size: 11px; font-weight: 700; cursor: pointer;
  font-family: var(--sans); box-shadow: 0 0 12px rgba(124,58,237,0.3), var(--shadow);
  display: flex; align-items: center; gap: 6px; transition: all .2s; letter-spacing: .2px;
}
.sim-btn:hover { background: linear-gradient(135deg, #6D28D9, #4338CA); box-shadow: 0 0 20px rgba(124,58,237,0.5), var(--shadow-md); transform: translateY(-1px); }
.sim-btn.active {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  border-color: rgba(220,38,38,0.5);
  box-shadow: 0 0 16px rgba(220,38,38,0.4);
  animation: simBtnPulse 1.5s ease infinite;
}
@keyframes simBtnPulse { 0%,100%{box-shadow:0 0 16px rgba(220,38,38,0.4)} 50%{box-shadow:0 0 28px rgba(220,38,38,0.7)} }


/* ══════════════════════════════════════════════
   SIMULATION OVERLAY & PANEL
   ══════════════════════════════════════════════ */
.sim-overlay { position: absolute; inset: 0; z-index: 900; pointer-events: none; background: transparent; transition: background .5s; }
.sim-overlay.active { pointer-events: none; }

.sim-panel {
  position: absolute; top: 14px; right: 14px; width: 340px; z-index: 850;
  background: rgba(10,22,40,0.96); backdrop-filter: blur(12px);
  border: 1px solid rgba(124,58,237,0.4); border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(124,58,237,0.15);
  overflow: hidden; transform: translateX(360px); transition: transform .4s cubic-bezier(.4,0,.2,1);
}
.sim-panel.open { transform: translateX(0); }

.sim-panel-header {
  background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(79,70,229,0.2));
  border-bottom: 1px solid rgba(124,58,237,0.25);
  padding: 12px 14px; display: flex; align-items: center; gap: 10px;
}
.sim-icon  { font-size: 18px; }
.sim-title { font-size: 13px; font-weight: 700; color: #fff; flex: 1; }
.sim-close {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6); border-radius: 6px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; transition: all .15s;
}
.sim-close:hover { background: rgba(220,38,38,0.3); color: #fff; border-color: rgba(220,38,38,0.5); }

/* Phase timeline */
.sim-phases { display: flex; padding: 10px 14px; gap: 0; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sim-phase-dot {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative;
}
.sim-phase-dot::after {
  content: ''; position: absolute; top: 7px; left: 50%; width: 100%; height: 2px;
  background: rgba(255,255,255,0.1); z-index: 0;
}
.sim-phase-dot:last-child::after { display: none; }
.sim-phase-circle {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05); z-index: 1; transition: all .4s; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.sim-phase-circle.done   { background: #34D399; border-color: #34D399; }
.sim-phase-circle.active { background: #7C3AED; border-color: #A78BFA; box-shadow: 0 0 8px rgba(124,58,237,0.7); animation: phaseGlow .9s ease infinite; }
.sim-phase-circle.danger { background: #EF4444; border-color: #EF4444; box-shadow: 0 0 8px rgba(239,68,68,0.7); }
@keyframes phaseGlow { 0%,100%{box-shadow:0 0 8px rgba(124,58,237,0.7)} 50%{box-shadow:0 0 16px rgba(124,58,237,1)} }
.sim-phase-label        { font-size: 8px; color: rgba(255,255,255,0.4); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.sim-phase-label.active { color: #A78BFA; }
.sim-phase-label.done   { color: #34D399; }
.sim-phase-label.danger { color: #FCA5A5; }

/* Gauge display */
.sim-gauge-section { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sim-gauge-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sim-gauge-label   { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,0.4); }
.sim-gauge-val     { font-family: var(--mono); font-size: 24px; font-weight: 700; color: #fff; line-height: 1; }
.sim-gauge-val span { font-size: 12px; color: rgba(255,255,255,0.4); }
.sim-gauge-trend   { font-size: 11px; font-weight: 700; }

.sim-bar-bg   { height: 8px; background: rgba(255,255,255,0.08); border-radius: 8px; overflow: visible; position: relative; margin-bottom: 4px; }
.sim-bar-fill { height: 100%; border-radius: 8px; transition: width .8s cubic-bezier(.4,0,.2,1), background .5s; position: relative; }
.sim-bar-fill::after { content:''; position:absolute; right:-2px; top:-3px; bottom:-3px; width:4px; border-radius:4px; background:inherit; box-shadow:0 0 8px currentColor; }
.sim-bar-critical { position:absolute; top:-3px; bottom:-3px; width:2px; background:rgba(239,68,68,0.6); border-radius:2px; }

/* Zone status list */
.sim-zones-section { padding: 8px 14px 0; }
.sim-zones-label   { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,0.3); margin-bottom: 6px; }
.sim-zone-row      { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05); transition: all .3s; }
.sim-zone-row:last-child { border-bottom: none; }
.sim-zone-dot   { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transition: all .3s; }
.sim-zone-name  { font-size: 11px; color: rgba(255,255,255,0.7); flex: 1; font-weight: 500; }
.sim-zone-gauge { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.sim-zone-trend { font-size: 10px; font-weight: 700; }

/* Action feed */
.sim-feed { max-height: 180px; overflow-y: auto; padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.07); }
.sim-feed::-webkit-scrollbar       { width: 2px; }
.sim-feed::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
.sim-feed-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,0.3); margin-bottom: 6px; }

.sim-event      { display: flex; gap: 8px; margin-bottom: 6px; animation: eventSlide .3s ease both; }
@keyframes eventSlide { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:translateY(0)} }
.sim-event-time { font-family: var(--mono); font-size: 9px; color: rgba(255,255,255,0.3); white-space: nowrap; margin-top: 1px; flex-shrink: 0; }
.sim-event-body          { font-size: 11px; line-height: 1.4; }
.sim-event-body.info     { color: rgba(255,255,255,0.65); }
.sim-event-body.warn     { color: #FCD34D; }
.sim-event-body.danger   { color: #FCA5A5; }
.sim-event-body.action   { color: #6EE7B7; font-weight: 600; }
.sim-event-body.critical { color: #F87171; font-weight: 700; }

/* Action card */
.sim-action-card { margin: 0 14px 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid; transition: all .4s; }
.sim-action-card.watch     { background: rgba(234,179,8,0.1);   border-color: rgba(234,179,8,0.3); }
.sim-action-card.warning   { background: rgba(249,115,22,0.1);  border-color: rgba(249,115,22,0.3); }
.sim-action-card.emergency { background: rgba(239,68,68,0.1);   border-color: rgba(239,68,68,0.3); }
.sim-action-card.critical  { background: rgba(220,38,38,0.15);  border-color: rgba(220,38,38,0.5); animation: critPulse 1.2s ease infinite; }
@keyframes critPulse { 0%,100%{border-color:rgba(220,38,38,0.5)} 50%{border-color:rgba(220,38,38,0.9)} }
.sim-action-title          { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 5px; }
.sim-action-title.watch    { color: #FCD34D; }
.sim-action-title.warning  { color: #FB923C; }
.sim-action-title.emergency{ color: #FCA5A5; }
.sim-action-title.critical { color: #F87171; }
.sim-action-steps { display: flex; flex-direction: column; gap: 3px; }
.sim-action-step  { font-size: 11px; color: rgba(255,255,255,0.75); display: flex; gap: 6px; }
.sim-action-step::before { content: '>'; color: rgba(255,255,255,0.3); flex-shrink: 0; }

/* Flash overlay */
.sim-map-flash      { position: absolute; inset: 0; z-index: 800; pointer-events: none; background: rgba(239,68,68,0); transition: background .3s; }
.sim-map-flash.flash { background: rgba(239,68,68,0.08); }

/* Speed control */
.sim-controls     { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid rgba(255,255,255,0.07); }
.sim-speed-label  { font-size: 9px; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: .5px; }
.sim-speed-btn    { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.5); border-radius: 5px; padding: 3px 8px; font-size: 10px; font-weight: 600; cursor: pointer; font-family: var(--sans); transition: all .15s; }
.sim-speed-btn:hover, .sim-speed-btn.active { background: rgba(124,58,237,0.3); border-color: rgba(124,58,237,0.6); color: #A78BFA; }
.sim-progress-text { margin-left: auto; font-family: var(--mono); font-size: 9px; color: rgba(255,255,255,0.3); }

/* Sim epicentre marker */
@keyframes simRing1    { 0%{transform:scale(1);opacity:.7} 100%{transform:scale(3.5);opacity:0} }
@keyframes simRing2    { 0%{transform:scale(1);opacity:.5} 100%{transform:scale(2.8);opacity:0} }
@keyframes simRing3    { 0%{transform:scale(1);opacity:.9} 100%{transform:scale(1.8);opacity:0} }
@keyframes simCorePulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

.sim-epicentre-badge {
  position: absolute; background: rgba(10,22,40,0.92); backdrop-filter: blur(8px);
  border: 1px solid rgba(239,68,68,0.6); border-radius: 20px;
  padding: 4px 10px 4px 7px; display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; color: #FCA5A5; white-space: nowrap;
  box-shadow: 0 0 12px rgba(239,68,68,0.3); z-index: 810;
  animation: badgeIn .3s ease both; pointer-events: none;
}
@keyframes badgeIn { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:translateY(0)} }
.sim-epicentre-dot { width: 6px; height: 6px; border-radius: 50%; background: #EF4444; animation: livePulse 1.2s ease infinite; }

.sim-zone-focus-label { font-size: 9px; font-weight: 600; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.sim-focus-zone       { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: rgba(255,255,255,0.05); border-radius: 7px; margin-bottom: 8px; border: 1px solid rgba(255,255,255,0.08); }
.sim-focus-zone-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sim-focus-zone-name  { font-size: 11px; font-weight: 600; color: #fff; }
.sim-focus-zone-river { font-size: 10px; color: rgba(255,255,255,0.4); margin-left: auto; }
.sim-focus-go-btn     { font-size: 9px; font-weight: 700; color: #60A5FA; background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); border-radius: 4px; padding: 2px 7px; cursor: pointer; font-family: var(--sans); transition: all .15s; white-space: nowrap; }
.sim-focus-go-btn:hover { background: rgba(59,130,246,0.3); }

/* @keyframes mapPulse used inline in JS */
@keyframes mapPulse { 0%,100%{transform:scale(1);opacity:.25} 50%{transform:scale(2.2);opacity:0} }


/* ══════════════════════════════════════════════
   RESPONSIVE — TABLET  (≤ 900px)
   ══════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-width: 360px; }

  /* Shrink metrics strip */
  .metrics-strip { display: none; }
  .header-sep:nth-child(4) { display: none; }

  /* Sim panel narrower */
  .sim-panel { width: 300px; }
}


/* ══════════════════════════════════════════════
   RESPONSIVE — MOBILE  (≤ 640px)
   ══════════════════════════════════════════════ */
@media (max-width: 640px) {
  :root {
    --header-height:  50px;
    --tab-bar-height: 52px;
  }

  /* ── Header ── */
  .header { padding: 0 12px; gap: 10px; }
  .logo-sub       { display: none; }
  .header-sep     { display: none; }
  .metrics-strip  { display: none; }
  .live-badge     { display: none; }
  .mobile-panel-toggle { display: flex; align-items: center; justify-content: center; }

  /* ── Layout: stack vertically ── */
  .main { flex-direction: column; }

  /* Map takes ~55% of viewport height */
  .map-wrap { height: 55vh; flex: none; }

  /* ── Sidebar slides up from bottom as a sheet ── */
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: calc(45vh + var(--tab-bar-height));
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    transform: translateY(0);
    z-index: 900;
  }
  .sidebar.hidden {
    transform: translateY(100%);
  }

  /* Backdrop shown when sidebar is open on mobile */
  .sidebar-backdrop.visible {
    display: block;
  }

  /* Drag handle */
  .sidebar::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 8px auto 4px;
    flex-shrink: 0;
  }

  /* Tabs */
  .tabs { border-radius: 0; }
  .tab-btn { font-size: 11px; padding: 10px 4px; }

  /* Map overlays */
  .map-overlay { top: 8px; left: 8px; }
  .overlay-card { padding: 8px 10px; }
  .overlay-title { font-size: 9px; margin-bottom: 5px; }
  .legend-row { font-size: 10.5px; }

  /* Map controls */
  .map-ctrl { left: 50px; bottom: 8px; }
  .map-btn  { padding: 6px 10px; font-size: 10px; }
  .sim-btn  { padding: 6px 10px; font-size: 10px; }

  /* Layer switcher: collapse to icons-only strip across top-right */
  .layer-switcher {
    top: 8px; right: 8px;
    min-width: unset;
  }
  .layer-switcher-title { display: none; }
  .layer-list { flex-direction: row; }
  .layer-btn  { padding: 6px 7px; gap: 0; border-bottom: none; border-right: 1px solid var(--border); flex-direction: column; }
  .layer-btn:last-child { border-right: none; }
  .layer-thumb { width: 28px; height: 20px; }
  .layer-name  { font-size: 8px; margin-top: 3px; color: var(--text-mid); }
  .layer-check { display: none; }

  /* Sim panel full-width */
  .sim-panel {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
  }
  .sim-panel.open { transform: translateY(0); }

  /* Alert cards */
  .alert-loc  { font-size: 12.5px; }
  .impact-icons { display: none; }
  .alert-time { display: none; }

  /* Dashboard */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card-val { font-size: 18px; }
  .basin-name { min-width: 70px; font-size: 11px; }

  /* History */
  .hist-card { grid-template-columns: 1fr auto; }
  .hist-date { display: none; }
}


/* ══════════════════════════════════════════════
   RESPONSIVE — VERY SMALL  (≤ 380px)
   ══════════════════════════════════════════════ */
@media (max-width: 380px) {
  .logo-text { font-size: 15px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .tab-btn   { font-size: 10px; padding: 9px 2px; }
  .chart-zone-tab { font-size: 9px; padding: 2px 6px; }
}