/* ================================================================
   SafeUp — main.css  (Production v3 — All Bugs Fixed)

   KEY FIXES:
   ✅ SCROLL: body overflow NEVER hidden globally
   ✅ SCROLL: .dash-content has no overflow trap
   ✅ SCROLL: .app-shell allows natural height growth
   ✅ MAP: Leaflet CSS loaded blocking, map always has height
   ✅ MOBILE: sidebar slides in/out correctly
   ✅ RESPONSIVE: 360 / 480 / 640 / 768 / 900 / 1100px breakpoints
   ✅ CARDS: no contain:layout (broke mobile stacking context)
   ✅ ROUTE: metrics visible after route is found
   ================================================================ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  --orange:        #f97316;
  --orange-d:      #ea6a0a;
  --orange-light:  #fff4ed;
  --orange-mid:    #fed7aa;
  --orange-border: rgba(249,115,22,.22);
  --orange-glow:   rgba(249,115,22,.18);
  --white:   #ffffff;
  --bg:      #faf9f7;
  --bg2:     #f3f2ef;
  --card:    #ffffff;
  --sidebar: #1c1917;
  --danger:       #ef4444;
  --danger-light: #fef2f2;
  --warn:         #f59e0b;
  --warn-light:   #fffbeb;
  --safe:         #10b981;
  --safe-light:   #f0fdf4;
  --blue:         #3b82f6;
  --blue-light:   #eff6ff;
  --t1: #1c1917;
  --t2: #78716c;
  --t3: #a8a29e;
  --t4: #d6d3d1;
  --sb-t1: #fafaf9;
  --sb-t2: #a8a29e;
  --sb-t3: #57534e;
  --f-display: 'Outfit', system-ui, sans-serif;
  --f-body:    'DM Sans', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', monospace;
  --r:    14px;
  --r-sm:  9px;
  --r-lg: 20px;
  --r-xl: 28px;
  --sb-w: 252px;
  --topbar-h: 58px;
  --sh-xs:     0 1px 3px  rgba(0,0,0,.06);
  --sh-sm:     0 2px 10px rgba(0,0,0,.08);
  --sh-md:     0 4px 24px rgba(0,0,0,.10);
  --sh-lg:     0 12px 40px rgba(0,0,0,.14);
  --sh-orange: 0 4px 20px rgba(249,115,22,.32);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14.5px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* ✅ FIX: body scrolls naturally — NEVER set overflow:hidden globally */
body {
  font-family: var(--f-body);
  background: var(--bg);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a      { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--f-body); border: none; outline: none; background: none; }
input, select, textarea { font-family: var(--f-body); }
img    { max-width: 100%; display: block; }

.hidden { display: none !important; }
.mono        { font-family: var(--f-mono); }
.orange-text { color: var(--orange); }
.danger-text { color: var(--danger); }
.safe-text   { color: var(--safe);   }
.muted       { color: var(--t2);     }

/* ── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: var(--sh-sm);
  /* ✅ FIX: NO contain:layout — was breaking mobile stacking context */
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; background: var(--orange); color: #fff;
  font-weight: 700; font-size: .88rem; border-radius: var(--r-sm);
  box-shadow: var(--sh-orange); transition: all .18s; position: relative; overflow: hidden;
}
.btn-primary::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg,rgba(255,255,255,.12),transparent 60%); }
.btn-primary:hover  { background: var(--orange-d); transform: translateY(-1px); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.full   { width: 100%; }
.btn-primary:disabled { opacity: .6; pointer-events: none; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; background: transparent;
  border: 1.5px solid var(--orange-border); color: var(--orange);
  font-weight: 600; font-size: .84rem; border-radius: var(--r-sm); transition: all .18s;
}
.btn-outline:hover { background: var(--orange-light); border-color: var(--orange); }

.btn-outline-sm {
  padding: 7px 13px; background: transparent;
  border: 1.5px solid var(--orange-border); color: var(--orange);
  font-size: .76rem; font-weight: 600; border-radius: var(--r-sm);
  transition: all .18s; cursor: pointer;
}
.btn-outline-sm:hover { background: var(--orange-light); }

.btn-danger-sm {
  padding: 7px 13px; background: var(--danger-light);
  border: 1.5px solid rgba(239,68,68,.2); color: var(--danger);
  font-size: .76rem; font-weight: 600; border-radius: var(--r-sm); cursor: pointer;
}

.btn-report {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; background: var(--orange-light);
  border: 1.5px solid var(--orange-border); color: var(--orange);
  font-weight: 600; font-size: .8rem; border-radius: var(--r-sm);
  transition: all .18s; cursor: pointer; white-space: nowrap;
}
.btn-report:hover { background: var(--orange-mid); }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.badge-safe   { background: var(--safe-light);   color: var(--safe);   }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warn   { background: var(--warn-light);   color: var(--warn);   }
.badge-orange { background: var(--orange-light); color: var(--orange); }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--t1); color: #fff; padding: 10px 22px;
  border-radius: 30px; font-size: .83rem; white-space: nowrap;
  z-index: 9000; box-shadow: var(--sh-lg);
  opacity: 0; transition: opacity .3s, transform .3s;
  pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show   { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.orange { background: var(--orange); }
.toast.red    { background: var(--danger); }
.toast.green  { background: var(--safe);   }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-right: 6px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   AUTH PAGE  (index.html)
   ================================================================ */
.auth-page { min-height: 100dvh; display: grid; grid-template-columns: 460px 1fr; }

.auth-left {
  background: linear-gradient(150deg,#ff8c42 0%,#f97316 45%,#ea580c 100%);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 52px 48px; position: relative; overflow: hidden;
}
.auth-left::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px,transparent 1px);
  background-size: 24px 24px;
}
.auth-left-inner { position: relative; z-index: 1; }

.brand-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 56px; }
.brand-icon {
  width: 46px; height: 46px; background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.3); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.brand-name      { font-family: var(--f-display); font-size: 1.6rem; font-weight: 900; color: #fff; letter-spacing: -.02em; }
.auth-hero-title { font-family: var(--f-display); font-size: 2.5rem; font-weight: 900; color: #fff; line-height: 1.18; letter-spacing: -.03em; margin-bottom: 18px; }
.auth-hero-sub   { font-size: .98rem; color: rgba(255,255,255,.78); line-height: 1.65; max-width: 360px; margin-bottom: 40px; }
.auth-features   { display: flex; flex-direction: column; gap: 12px; }
.auth-feature    { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); border-radius: 12px; }
.auth-feature-icon { font-size: 1.2rem; flex-shrink: 0; }
.auth-feature-text { font-size: .84rem; color: rgba(255,255,255,.92); font-weight: 500; }
.auth-stats { display: flex; gap: 28px; position: relative; z-index: 1; }
.auth-stat span:first-child { display: block; font-family: var(--f-display); font-size: 1.4rem; font-weight: 800; color: #fff; }
.auth-stat span:last-child  { display: block; font-size: .7rem; color: rgba(255,255,255,.65); margin-top: 1px; }

.auth-right    { display: flex; align-items: center; justify-content: center; padding: 48px 40px; background: var(--white); overflow-y: auto; }
.auth-form-box { width: 100%; max-width: 420px; }
.auth-form-title { font-family: var(--f-display); font-size: 1.6rem; font-weight: 900; letter-spacing: -.02em; margin-bottom: 4px; }
.auth-form-sub   { font-size: .84rem; color: var(--t2); margin-bottom: 28px; }

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; background: var(--bg2); border-radius: 10px; margin-bottom: 26px; }
.auth-tab  { padding: 9px; text-align: center; font-size: .84rem; font-weight: 600; color: var(--t2); border-radius: 8px; transition: all .2s; cursor: pointer; }
.auth-tab.active { background: var(--white); color: var(--orange); box-shadow: var(--sh-xs); }

.field-stack { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field  { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: .72rem; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: .07em; }
.input-wrap  { position: relative; }
.input-ico   { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--t3); width: 16px; height: 16px; pointer-events: none; }
.form-field input {
  width: 100%; padding: 11px 13px 11px 36px;
  background: var(--bg); border: 1.5px solid var(--t4);
  border-radius: var(--r-sm); color: var(--t1); font-size: .88rem;
  transition: border-color .2s, box-shadow .2s;
}
.form-field input:focus    { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.form-field input::placeholder { color: var(--t3); }
.auth-note  { text-align: center; font-size: .7rem; color: var(--t3); margin-top: 16px; }
.auth-error {
  color: var(--danger); font-size: .78rem; padding: 8px 12px;
  background: var(--danger-light); border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--r-sm); text-align: center; margin-bottom: 12px; display: none;
}
.auth-error.show { display: block; }

/* ================================================================
   APP SHELL  (dashboard)

   ✅ FIX: body.app-body has ZERO extra CSS — body scrolls naturally
   ✅ FIX: .dash-content has NO overflow-y — window scrolls
   ✅ FIX: .app-shell does NOT have fixed 100dvh height
   ================================================================ */

body.app-body {
  /* Intentionally empty — body scrolls freely */
}

.app-shell {
  display: flex;
  min-height: 100dvh; /* min- not max- — allows growth */
}

.overlay     { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 490; display: none; touch-action: none; }
.overlay.on  { display: block; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w);
  flex-shrink: 0;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 500;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sb-logo-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 10px; flex-shrink: 0;
}
.sb-logo-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--orange); display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 0 16px rgba(249,115,22,.4); flex-shrink: 0; }
.sb-logo-name { font-family: var(--f-display); font-size: 1.1rem; font-weight: 800; color: var(--sb-t1); letter-spacing: -.01em; }

.sb-user {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 14px; padding: 12px;
  background: rgba(255,255,255,.05); border-radius: 12px;
  flex-shrink: 0; min-width: 0;
}
.sb-avatar    { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg,var(--orange),#ff8c42); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem; color: #fff; flex-shrink: 0; }
.sb-user-name { font-size: .82rem; font-weight: 600; color: var(--sb-t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-city { font-size: .68rem; color: var(--sb-t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sb-nav     { flex: 1; padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-section { font-size: .62rem; font-weight: 700; color: var(--sb-t3); text-transform: uppercase; letter-spacing: .12em; padding: 10px 10px 4px; }
.sb-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; font-size: .86rem; font-weight: 500; color: var(--sb-t2);
  transition: all .2s; cursor: pointer; position: relative; text-decoration: none;
  min-width: 0;
}
.sb-nav-item svg     { width: 17px; height: 17px; flex-shrink: 0; }
.sb-nav-item > span  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-nav-item:hover   { background: rgba(255,255,255,.07); color: var(--sb-t1); }
.sb-nav-item.active  { background: rgba(249,115,22,.15); color: var(--orange); border: 1px solid rgba(249,115,22,.2); }
.sb-nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--orange); border-radius: 0 3px 3px 0; box-shadow: 0 0 8px rgba(249,115,22,.5);
}
.nav-badge { margin-left: auto; padding: 2px 7px; border-radius: 10px; background: var(--danger); font-size: .62rem; font-weight: 700; color: #fff; flex-shrink: 0; }

.sb-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.sb-logout {
  width: 100%; padding: 9px; border-radius: 9px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.18);
  color: #f87171; font-size: .82rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px; transition: background .2s; cursor: pointer;
}
.sb-logout:hover { background: rgba(239,68,68,.18); }

/* ── Main area ──────────────────────────────────────────────────── */
/* ✅ FIX: No min-height trap — content flows naturally */
.main-area {
  flex: 1;
  margin-left: var(--sb-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid rgba(0,0,0,.07);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 0 22px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--sh-xs); flex-shrink: 0;
}
.topbar-left  { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ham-btn      { display: none; flex-direction: column; gap: 4px; padding: 6px 4px; }
.ham-btn span { display: block; width: 20px; height: 2px; background: var(--t1); border-radius: 2px; }
.topbar-title { font-family: var(--f-display); font-size: 1rem; font-weight: 700; color: var(--t1); white-space: nowrap; }
.topbar-clock { font-family: var(--f-mono); font-size: .76rem; color: var(--t2); padding: 4px 11px; background: var(--bg); border: 1px solid var(--t4); border-radius: 8px; }
.topbar-city  { font-size: .78rem; font-weight: 600; color: var(--orange); padding: 4px 11px; background: var(--orange-light); border: 1px solid var(--orange-border); border-radius: 8px; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.topbar-sos   { padding: 7px 14px; background: var(--danger); color: #fff; font-weight: 700; font-size: .78rem; border-radius: 8px; box-shadow: 0 2px 10px rgba(239,68,68,.35); letter-spacing: .04em; white-space: nowrap; flex-shrink: 0; cursor: pointer; }

/* ── Dashboard content ──────────────────────────────────────────── */
/* ✅ FIX: NO overflow-y:auto — page/window scrolls naturally */
.dash-content {
  flex: 1;
  padding: 20px 22px 60px;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  max-width: 1440px;
  animation: fadeIn .3s ease both;
}
.col-left  { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ── Section label ──────────────────────────────────────────────── */
.sec-label {
  font-size: .7rem; font-weight: 700; color: var(--t3);
  text-transform: uppercase; letter-spacing: .12em;
}

/* ── Welcome ────────────────────────────────────────────────────── */
.welcome-strip { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.welcome-title { font-family: var(--f-display); font-size: 1.45rem; font-weight: 900; letter-spacing: -.02em; }
.welcome-sub   { font-size: .84rem; color: var(--t2); margin-top: 3px; }
.welcome-date  { font-family: var(--f-mono); font-size: .72rem; color: var(--t3); white-space: nowrap; }

/* ── KPI row ────────────────────────────────────────────────────── */
.kpi-row  { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.kpi-card {
  background: var(--white); border-radius: var(--r); padding: 15px;
  border: 1px solid rgba(0,0,0,.06); box-shadow: var(--sh-xs);
  transition: transform .2s, box-shadow .2s;
  /* ✅ NO contain:layout */
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0; }
.kpi-icon.o { background: var(--orange-light); }
.kpi-icon.r { background: var(--danger-light); }
.kpi-icon.g { background: var(--safe-light);   }
.kpi-icon.b { background: var(--blue-light);   }
.kpi-trend      { font-size: .68rem; font-weight: 600; }
.kpi-trend.up   { color: var(--safe);  }
.kpi-trend.warn { color: var(--warn);  }
.kpi-val  { font-family: var(--f-display); font-size: 1.35rem; font-weight: 900; letter-spacing: -.02em; }
.kpi-lbl  { font-size: .68rem; color: var(--t3); margin-top: 2px; }

/* ── Profile card ───────────────────────────────────────────────── */
.profile-card { padding: 20px; }
.pc-top   { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.pc-avatar { width: 54px; height: 54px; border-radius: 15px; background: linear-gradient(135deg,var(--orange),#ff8c42); display: flex; align-items: center; justify-content: center; font-family: var(--f-display); font-weight: 900; font-size: 1.3rem; color: #fff; flex-shrink: 0; box-shadow: var(--sh-orange); }
.pc-name  { font-family: var(--f-display); font-size: 1.05rem; font-weight: 800; }
.pc-meta  { display: flex; gap: 7px; margin-top: 5px; flex-wrap: wrap; }
.pc-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.pc-item  { background: var(--bg); border-radius: 9px; padding: 9px 12px; min-width: 0; }
.pc-item-lbl { font-size: .63rem; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 2px; }
.pc-item-val { font-size: .8rem; font-weight: 500; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-edit { width: 100%; margin-top: 13px; padding: 9px; border: 1.5px solid var(--orange-border); border-radius: var(--r-sm); font-size: .8rem; font-weight: 600; color: var(--orange); background: var(--orange-light); transition: all .18s; cursor: pointer; }
.pc-edit:hover { background: var(--orange-mid); }

/* ── Alert feed ─────────────────────────────────────────────────── */
.alert-feed { display: flex; flex-direction: column; gap: 9px; }
.alert-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 15px; background: var(--white);
  border: 1px solid rgba(0,0,0,.06); border-radius: var(--r);
  box-shadow: var(--sh-xs); transition: all .2s; position: relative; overflow: hidden;
}
.alert-row::before    { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.alert-row.high::before   { background: var(--danger); }
.alert-row.medium::before { background: var(--warn); }
.alert-row.low::before    { background: var(--safe); }
.alert-row:hover          { transform: translateX(2px); box-shadow: var(--sh-sm); }
.alert-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0; }
.alert-icon.high   { background: var(--danger-light); }
.alert-icon.medium { background: var(--warn-light);   }
.alert-icon.low    { background: var(--safe-light);   }
.alert-title { font-size: .86rem; font-weight: 600; margin-bottom: 2px; }
.alert-desc  { font-size: .74rem; color: var(--t2); line-height: 1.45; }
.alert-foot  { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; flex-wrap: wrap; gap: 6px; }
.alert-when  { font-family: var(--f-mono); font-size: .65rem; color: var(--t3); }

.alerts-list { display: flex; flex-direction: column; gap: 10px; }
.alert-card  { display: flex; gap: 12px; padding: 14px; background: var(--white); border-radius: var(--r); border: 1px solid rgba(0,0,0,.06); box-shadow: var(--sh-xs); border-left: 3px solid transparent; }
.alert-card.danger { border-left-color: var(--danger); }
.alert-card.warn   { border-left-color: var(--warn);   }
.alert-card.safe   { border-left-color: var(--safe);   }
.alert-card.read   { opacity: .65; }
.alert-card-icon    { font-size: 1.15rem; flex-shrink: 0; padding-top: 2px; }
.alert-card-title   { font-size: .84rem; font-weight: 700; margin-bottom: 4px; }
.alert-card-message { font-size: .74rem; color: var(--t2); line-height: 1.45; }
.alert-card-time    { font-family: var(--f-mono); font-size: .65rem; color: var(--t3); margin-top: 5px; }
.alert-card-body    { flex: 1; min-width: 0; }
.empty-state        { text-align: center; font-size: .82rem; color: var(--t3); padding: 24px 0; }

/* ── Activity feed ──────────────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 7px; }
.act-item { display: flex; align-items: center; gap: 11px; padding: 10px 13px; background: var(--white); border-radius: var(--r-sm); border: 1px solid rgba(0,0,0,.05); box-shadow: var(--sh-xs); transition: border-color .18s; }
.act-item:hover { border-color: var(--orange-border); }
.act-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.act-dot.orange { background: var(--orange); }
.act-dot.red    { background: var(--danger); }
.act-dot.green  { background: var(--safe);   }
.act-dot.blue   { background: var(--blue);   }
.act-body { flex: 1; min-width: 0; }
.act-text { font-size: .81rem; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-sub  { font-size: .69rem; color: var(--t3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-time { font-family: var(--f-mono); font-size: .65rem; color: var(--t3); margin-left: auto; flex-shrink: 0; }

/* ── Device status ──────────────────────────────────────────────── */
.device-card { padding: 15px; }
.dev-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dev-item    { display: flex; flex-direction: column; gap: 4px; }
.dev-header  { display: flex; align-items: center; gap: 6px; }
.dev-ico     { font-size: .88rem; }
.dev-lbl     { font-size: .65rem; color: var(--t3); }
.dev-val     { font-size: .8rem; font-weight: 600; color: var(--t1); }
.dev-bar-wrap { height: 3px; background: var(--bg2); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.dev-bar     { height: 100%; border-radius: 2px; transition: width .8s ease; }
.dev-bar.orange { background: linear-gradient(90deg,var(--orange),#ff8c42); }
.dev-bar.blue   { background: linear-gradient(90deg,var(--blue),#60a5fa); }
.dev-bar.green  { background: linear-gradient(90deg,var(--safe),#34d399); }

.gps-indicator  { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.gps-live       { background: var(--safe); box-shadow: 0 0 6px rgba(16,185,129,.6); animation: blink .9s infinite; }
.gps-city       { background: var(--warn); }
.gps-acquiring  { background: var(--t3); animation: blink 1.2s infinite; }
.gps-denied     { background: var(--danger); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ── Map card ────────────────────────────────────────────────────── */
/* ✅ FIX: map card allows natural height, no contain:layout */
.map-card {
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
}

/* ✅ FIX: explicit height — Leaflet NEEDS a real pixel height to render */
#map {
  height: 320px;
  width: 100%;
  display: block;
  min-height: 200px;
}

.map-status {
  padding: 7px 13px; font-size: .73rem; font-family: var(--f-mono);
  border-top: 1px solid rgba(0,0,0,.06); min-height: 32px; flex-shrink: 0;
}
.map-status-live     { background: var(--safe-light);   color: #15803d; }
.map-status-city     { background: var(--orange-light); color: var(--orange-d); }
.map-status-fallback { background: var(--bg2);          color: var(--t3); }

/* Leaflet overrides */
.leaflet-popup-content-wrapper { background: var(--white) !important; border-radius: 12px !important; box-shadow: var(--sh-lg) !important; border: 1px solid rgba(0,0,0,.07) !important; }
.leaflet-popup-tip  { background: var(--white) !important; }
.leaflet-popup-content { font-family: var(--f-body) !important; font-size: .83rem !important; margin: 10px 14px !important; }
.leaflet-control-attribution { background: rgba(255,255,255,.9) !important; font-size: 9px !important; }
.leaflet-top, .leaflet-bottom { z-index: 400; }

/* ── Live share ─────────────────────────────────────────────────── */
.share-link-box   { background: var(--bg); border: 1.5px solid var(--orange-border); border-radius: var(--r-sm); padding: 12px 14px; margin-top: 10px; }
.share-link-row   { display: flex; gap: 8px; align-items: center; }
.share-link-input { flex: 1; padding: 8px 10px; background: var(--white); border: 1px solid var(--t4); border-radius: 6px; font-size: .78rem; font-family: var(--f-mono); color: var(--t1); min-width: 0; }

/* ── Route section ──────────────────────────────────────────────── */
.route-card { padding: 17px; }
.route-input-row { display: flex; gap: 8px; margin-bottom: 11px; }
.dest-wrap { flex: 1; position: relative; min-width: 0; }
.dest-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--t3); }
.dest-wrap input {
  width: 100%; padding: 10px 12px 10px 34px;
  background: var(--bg); border: 1.5px solid var(--t4);
  border-radius: var(--r-sm); font-size: .86rem; color: var(--t1); transition: all .2s;
}
.dest-wrap input:focus       { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.dest-wrap input::placeholder { color: var(--t3); }

.btn-find-route {
  padding: 10px 14px; background: var(--orange); color: #fff;
  font-weight: 700; font-size: .82rem; border-radius: var(--r-sm);
  box-shadow: var(--sh-orange); transition: all .18s;
  white-space: nowrap; display: flex; align-items: center; gap: 6px; flex-shrink: 0; cursor: pointer;
}
.btn-find-route:hover    { background: var(--orange-d); transform: translateY(-1px); }
.btn-find-route:disabled { opacity: .6; pointer-events: none; }

.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }
.qchip { padding: 5px 12px; background: var(--bg); border: 1px solid var(--t4); border-radius: 20px; font-size: .73rem; font-weight: 500; color: var(--t2); transition: all .18s; cursor: pointer; }
.qchip:hover { background: var(--orange-light); border-color: var(--orange-border); color: var(--orange); }

.route-status { display: flex; align-items: center; gap: 7px; padding: 8px 12px; background: var(--bg); border-radius: 8px; font-size: .74rem; font-family: var(--f-mono); color: var(--t2); margin-bottom: 10px; }
.rs-dot     { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.rs-loading { background: var(--warn); animation: blink .8s infinite; }
.rs-ok      { background: var(--safe); }
.rs-error   { background: var(--danger); }

/* ✅ FIX: route-metrics is always display:grid; hidden via JS display:none */
.route-metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin-bottom: 13px; }
.rm-box { padding: 11px; background: var(--bg); border-radius: 10px; text-align: center; border: 1px solid rgba(0,0,0,.05); }
.rm-box.highlight { background: var(--orange-light); border-color: var(--orange-border); }
.rm-val { font-family: var(--f-display); font-size: 1.05rem; font-weight: 900; color: var(--t1); }
.rm-box.highlight .rm-val { color: var(--orange); }
.rm-lbl { font-size: .62rem; color: var(--t3); text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }

.map-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .71rem; color: var(--t2); margin-top: 10px; }
.ml-item    { display: flex; align-items: center; gap: 5px; }
.ml-dot     { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ml-line    { width: 16px; height: 3px; border-radius: 2px; flex-shrink: 0; }

.ai-explanation { font-size: .77rem; color: var(--t1); line-height: 1.55; padding: 10px 13px; background: var(--bg); border-radius: var(--r-sm); border-left: 3px solid var(--orange); margin-bottom: 12px; font-style: italic; }

/* ── PSS Panel ──────────────────────────────────────────────────── */
.pss-panel { background: linear-gradient(135deg,#fff8f4,var(--white)); border: 1.5px solid var(--orange-border); border-radius: var(--r); padding: 17px; margin-bottom: 13px; box-shadow: 0 2px 12px rgba(249,115,22,.07); }
.pss-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; flex-wrap: wrap; gap: 8px; }
.pss-title  { font-family: var(--f-display); font-size: .88rem; font-weight: 800; }
.pss-time-tag { padding: 3px 10px; background: var(--orange-light); border: 1px solid var(--orange-border); border-radius: 20px; font-size: .67rem; font-weight: 700; color: var(--orange); }
.pss-score-row { display: flex; align-items: center; gap: 15px; margin-bottom: 13px; flex-wrap: wrap; }
.pss-score-circle { width: 62px; height: 62px; border-radius: 50%; border: 3px solid var(--sc,var(--safe)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(255,255,255,.9); position: relative; }
.pss-score-num  { font-family: var(--f-display); font-size: 1.3rem; font-weight: 900; color: var(--sc,var(--safe)); }
.pss-score-pct  { font-size: .58rem; font-weight: 700; color: var(--sc,var(--safe)); position: absolute; bottom: 11px; right: 8px; }
.pss-score-label { font-family: var(--f-display); font-size: .95rem; font-weight: 800; }
.pss-route-tag  { font-size: .68rem; color: var(--t3); font-family: var(--f-mono); margin-top: 2px; }
.pss-explanation { font-size: .76rem; color: var(--t1); line-height: 1.55; padding: 9px 12px; background: var(--bg); border-radius: var(--r-sm); border-left: 3px solid var(--orange); margin-bottom: 11px; font-style: italic; }
.pss-zones-title { font-size: .67rem; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 7px; }
.pss-zones  { display: flex; flex-direction: column; gap: 5px; }
.pss-zone   { font-size: .74rem; padding: 6px 10px; border-radius: 8px; border: 1px solid transparent; }
.pss-zone.high   { background: var(--danger-light); border-color: rgba(239,68,68,.2);  color: #b91c1c; }
.pss-zone.medium { background: var(--warn-light);   border-color: rgba(245,158,11,.2); color: #92400e; }
.pss-zone.low, .pss-zone.safe { background: var(--safe-light); border-color: rgba(16,185,129,.2); color: #065f46; }
.pss-zone-count  { opacity: .65; font-size: .67rem; margin-left: 4px; }
.pss-score-meta  { flex: 1; min-width: 0; }

/* ── Route comparison ───────────────────────────────────────────── */
.route-comparison { margin-bottom: 13px; }
.comp-title       { font-size: .7rem; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 9px; }
.comp-card        { background: var(--bg); border: 1px solid var(--t4); border-radius: var(--r-sm); padding: 11px 13px; margin-bottom: 7px; transition: border-color .18s; }
.comp-card:hover  { border-color: var(--orange-border); }
.comp-best        { background: var(--orange-light); border-color: var(--orange-border); }
.comp-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; gap: 8px; }
.comp-name        { font-size: .78rem; font-weight: 700; }
.comp-recommended { font-size: .62rem; font-weight: 700; color: var(--safe); background: var(--safe-light); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.comp-score       { font-family: var(--f-display); font-size: .86rem; font-weight: 800; margin-bottom: 5px; }
.comp-bar-wrap    { height: 3px; background: var(--bg2); border-radius: 2px; overflow: hidden; margin-bottom: 5px; }
.comp-bar         { height: 100%; border-radius: 2px; transition: width .6s ease; }
.comp-zones       { font-size: .7rem; color: var(--t2); }

/* ── Emergency ──────────────────────────────────────────────────── */
.emerg-card  { padding: 16px; }
.emerg-grid  { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-bottom: 12px; }
.emerg-btn   { padding: 13px 10px; text-align: center; background: var(--bg); border: 1px solid rgba(0,0,0,.05); border-radius: 10px; cursor: pointer; transition: all .18s; }
.emerg-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-sm); }
.emerg-icon  { font-size: 1.2rem; display: block; margin-bottom: 4px; }
.emerg-label { font-size: .64rem; color: var(--t3); margin-bottom: 2px; }
.emerg-num   { font-family: var(--f-mono); font-size: .84rem; font-weight: 700; color: var(--orange); }
.personal-ec { display: flex; align-items: center; gap: 11px; padding: 11px 13px; background: var(--orange-light); border: 1px solid var(--orange-border); border-radius: 10px; margin-bottom: 12px; }
.pec-icon    { font-size: 1.1rem; flex-shrink: 0; }
.pec-label   { font-size: .64rem; color: var(--t2); }
.pec-value   { font-size: .82rem; font-weight: 600; color: var(--t1); }
.pec-call    { margin-left: auto; padding: 6px 13px; background: var(--orange); color: #fff; border-radius: var(--r-sm); font-size: .74rem; font-weight: 600; transition: all .18s; white-space: nowrap; cursor: pointer; }
.pec-call:hover { background: var(--orange-d); }
.sos-hero-btn { width: 100%; padding: 15px; border-radius: var(--r); background: linear-gradient(135deg,#ef4444,#dc2626); color: #fff; font-weight: 800; font-size: .92rem; letter-spacing: .04em; box-shadow: 0 4px 20px rgba(239,68,68,.4); animation: sosPulse 2.5s infinite; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.sos-hero-btn:hover { transform: scale(1.01); }

/* ── SOS FAB ────────────────────────────────────────────────────── */
.sos-fab { position: fixed; bottom: 28px; right: 28px; width: 60px; height: 60px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 24px rgba(239,68,68,.5); animation: sosPulse 2.5s infinite; z-index: 300; border: 3px solid #fff; font-weight: 700; cursor: pointer; }

/* ── Banners ────────────────────────────────────────────────────── */
.banner-base {
  position: fixed; top: var(--topbar-h); left: 50%; transform: translateX(-50%);
  width: calc(100% - 40px); max-width: 520px;
  background: var(--white); border-radius: var(--r); padding: 13px 17px;
  z-index: 400; display: flex; align-items: flex-start; gap: 11px;
  box-shadow: var(--sh-lg); animation: slideDown .3s cubic-bezier(.22,1,.36,1);
}
.route-warning    { border: 2px solid var(--warn);   box-shadow: 0 6px 28px rgba(245,158,11,.2); }
#proximity-banner { border: 2px solid var(--orange); box-shadow: 0 6px 28px rgba(249,115,22,.22); }
.banner-icon  { font-size: 1.2rem; flex-shrink: 0; }
.banner-body  { flex: 1; min-width: 0; }
.banner-title { font-size: .86rem; font-weight: 700; margin-bottom: 2px; }
.banner-desc  { font-size: .75rem; color: var(--t2); }
.banner-close { color: var(--t3); font-size: 1rem; flex-shrink: 0; align-self: flex-start; padding: 2px; cursor: pointer; }

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px); z-index: 800;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.modal-sheet {
  width: 100%; max-width: 480px; background: var(--white);
  border-radius: var(--r-xl) var(--r-xl) 16px 16px;
  padding: 6px 22px 22px; box-shadow: var(--sh-lg);
  animation: sheetUp .32s cubic-bezier(.22,1,.36,1);
  position: relative; overflow: hidden;
  max-height: 92dvh; overflow-y: auto;
}
.modal-sheet::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg,transparent,var(--danger),transparent); }
.modal-handle { width: 40px; height: 4px; background: var(--t4); border-radius: 2px; margin: 12px auto 22px; }
.modal-title  { font-family: var(--f-display); font-size: 1.1rem; font-weight: 800; margin-bottom: 18px; }
.sos-options  { display: flex; flex-direction: column; gap: 9px; }
.sos-opt { display: flex; align-items: center; gap: 13px; padding: 13px 15px; background: var(--bg); border: 1.5px solid rgba(0,0,0,.06); border-radius: 12px; cursor: pointer; transition: all .18s; }
.sos-opt:hover { border-color: var(--orange-border); background: var(--orange-light); }
.sos-opt-icon { font-size: 1.2rem; }
.sos-opt-info { flex: 1; min-width: 0; }
.sos-opt-name { font-size: .88rem; font-weight: 600; }
.sos-opt-num  { font-family: var(--f-mono); font-size: .78rem; color: var(--t2); margin-top: 1px; }
.sos-opt-arrow { margin-left: auto; color: var(--t3); font-size: 1.1rem; }
.modal-cancel { width: 100%; margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 12px; color: var(--t2); font-size: .86rem; font-weight: 500; transition: background .18s; cursor: pointer; }
.modal-cancel:hover { background: var(--bg2); }

.report-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); z-index: 810; display: flex; align-items: flex-end; justify-content: center; padding-bottom: max(20px,env(safe-area-inset-bottom)); }
.report-modal-sheet   { width: 100%; max-width: 480px; background: var(--white); border-radius: var(--r-xl) var(--r-xl) 16px 16px; padding: 6px 22px 22px; box-shadow: var(--sh-lg); animation: sheetUp .32s cubic-bezier(.22,1,.36,1); max-height: 92dvh; overflow-y: auto; }
.report-modal-title   { font-family: var(--f-display); font-size: 1.05rem; font-weight: 800; margin-bottom: 16px; }
.rm-field             { margin-bottom: 12px; }
.rm-field label       { display: block; font-size: .72rem; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; }
.rm-field select, .rm-field textarea, .rm-field input { width: 100%; padding: 10px 12px; background: var(--bg); border: 1.5px solid var(--t4); border-radius: var(--r-sm); font-size: .87rem; color: var(--t1); font-family: var(--f-body); transition: border-color .2s; }
.rm-field select:focus, .rm-field textarea:focus, .rm-field input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.rm-field textarea { resize: vertical; min-height: 72px; }
.rm-coords { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Skeleton ───────────────────────────────────────────────────── */
#page-skeleton {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px; transition: opacity .4s, visibility .4s;
}
#page-skeleton.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.sk-logo { font-size: 2.4rem; animation: skPulse 1.4s ease-in-out infinite; }
.sk-bar  { width: 200px; height: 4px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.sk-fill { height: 100%; background: linear-gradient(90deg,var(--orange),#ff8c42); border-radius: 4px; animation: skLoad 1.8s ease-in-out infinite; }
.sk-text { font-size: .82rem; color: var(--t3); }
@keyframes skPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes skLoad  { 0% { width:0; margin-left:0; } 60% { width:100%; margin-left:0; } 100% { width:0; margin-left:100%; } }

/* ── User location marker ───────────────────────────────────────── */
.su-user-marker { position: relative; width: 32px; height: 32px; }
.su-dot { position: absolute; top:50%; left:50%; transform: translate(-50%,-50%); width: 14px; height: 14px; background: var(--orange); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 2px 8px rgba(249,115,22,.7); z-index: 2; }
.su-pulse-ring { position: absolute; top:50%; left:50%; transform: translate(-50%,-50%); width: 32px; height: 32px; border-radius: 50%; background: rgba(249,115,22,.2); border: 2px solid rgba(249,115,22,.5); animation: suPulse 1.8s ease-out infinite; z-index: 1; }
@keyframes suPulse { 0% { transform: translate(-50%,-50%) scale(.6); opacity:1; } 70%,100% { transform: translate(-50%,-50%) scale(1.9); opacity:0; } }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeIn    { from { opacity:0; } to { opacity:1; } }
@keyframes slideDown { from { opacity:0; transform:translateX(-50%) translateY(-14px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes sheetUp   { from { opacity:0; transform:translateY(36px); } to { opacity:1; transform:none; } }
@keyframes sosPulse  { 0%,100% { box-shadow:0 4px 16px rgba(239,68,68,.35); } 50% { box-shadow:0 4px 32px rgba(239,68,68,.65); } }

/* ================================================================
   RESPONSIVE BREAKPOINTS (mobile-first, all screen sizes)
   ================================================================ */

/* 1100px — small laptop */
@media(max-width:1100px) {
  .dash-grid { grid-template-columns: 1fr 300px; }
  .kpi-row   { grid-template-columns: repeat(2,1fr); }
}

/* 900px — tablet portrait */
@media(max-width:900px) {
  .dash-grid  { grid-template-columns: 1fr; }
  .col-right  { order: -1; }
  .emerg-grid { grid-template-columns: repeat(4,1fr); }
  #map        { height: 260px; }
}

/* 768px — mobile */
@media(max-width:768px) {
  :root { --sb-w: 0px; }
  .sidebar { transform: translateX(-252px); width: 252px; z-index: 600; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--sh-lg); }
  .ham-btn { display: flex; }
  .main-area { margin-left: 0; }
  .auth-page  { grid-template-columns: 1fr; }
  .auth-left  { display: none; }
  .auth-right { padding: 32px 22px; align-items: flex-start; }
  .kpi-row  { grid-template-columns: repeat(2,1fr); }
  .pc-grid  { grid-template-columns: 1fr; }
  .emerg-grid { grid-template-columns: repeat(2,1fr); }
  .field-row  { grid-template-columns: 1fr; }
  .topbar-clock { display: none; }
  .topbar-city  { display: none; }
  .topbar-title { font-size: .9rem; }
  .dash-content { padding: 14px 14px 60px; }
  .dash-grid    { gap: 14px; }
  #map          { height: 220px; }
  .sos-fab      { bottom: 20px; right: 16px; width: 52px; height: 52px; font-size: 1rem; }
  .banner-base  { width: calc(100% - 24px); }
  .quick-chips  { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .quick-chips::-webkit-scrollbar { display: none; }
  .topbar { padding: 0 12px; }
  .btn-report { font-size: .74rem; padding: 6px 10px; }
  .welcome-strip { flex-direction: column; gap: 4px; }
  .welcome-date  { display: none; }
  .route-input-row { flex-direction: column; }
  .btn-find-route  { width: 100%; justify-content: center; }
}

/* 480px — small phones */
@media(max-width:480px) {
  html { font-size: 13.5px; }
  .kpi-row    { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-val    { font-size: 1.1rem; }
  .emerg-grid { grid-template-columns: repeat(2,1fr); }
  .dash-content { padding: 12px 12px 60px; }
  .rm-coords  { grid-template-columns: 1fr; }
}

/* 360px — very small phones */
@media(max-width:360px) {
  html { font-size: 13px; }
  .kpi-row  { grid-template-columns: 1fr; }
  .pc-grid  { grid-template-columns: 1fr; }
  .topbar   { padding: 0 10px; }
  .btn-report { display: none; }
}

/* Landscape mobile */
@media(max-height:500px) and (orientation:landscape) {
  #map { height: 160px; }
  .topbar { height: 48px; }
  :root { --topbar-h: 48px; }
}
/* ================================================================
   SafeUp v2.0 — Upgraded Components
   Safety Score Card · Smart Alert Banner · Report Cards ·
   Verified Badge · Map Score Card · Upvote Button
   ================================================================ */

/* ── Safety Score Card (map overlay) ──────────────────────────── */
#map-score-card {
  transition: border-left-color .4s ease;
  backdrop-filter: blur(4px);
}

/* ── Smart Alert Banner (high-risk proximity) ─────────────────── */
#proximity-banner { transition: border-color .3s, box-shadow .3s; }
#proximity-banner strong { font-size: .88rem; }

/* ── Community report list cards ──────────────────────────────── */
.report-list-card {
  transition: transform .15s, box-shadow .15s;
}
.report-list-card:hover {
  transform: translateX(2px);
  box-shadow: 0 3px 12px rgba(0,0,0,.1) !important;
}

/* ── Upvote button ─────────────────────────────────────────────── */
button[onclick*="_upvoteReport"]:not([disabled]) { transition: transform .15s; }
button[onclick*="_upvoteReport"]:not([disabled]):hover  { transform: scale(1.06); }
button[onclick*="_upvoteReport"]:not([disabled]):active { transform: scale(.94); }

/* ── PSS zone border-left accent ──────────────────────────────── */
.pss-zone.high   { border-left: 3px solid var(--danger); }
.pss-zone.medium { border-left: 3px solid var(--warn); }
.pss-zone.safe, .pss-zone.low { border-left: 3px solid var(--safe); }

/* ── AI explanation upgrade ────────────────────────────────────── */
.ai-explanation {
  background: linear-gradient(135deg,#fff8f4,#fff);
  border-left: 3px solid var(--orange);
}

/* ── Score circle transition ───────────────────────────────────── */
.pss-score-circle { transition: border-color .4s ease; }

/* ── Report modal location status ─────────────────────────────── */
#report-loc-status { transition: color .3s, background .3s; }

/* ── KPI safety score colour transition ────────────────────────── */
#kpi-score { transition: color .4s ease; }

/* ── Community reports section scroll target ───────────────────── */
#sec-community { scroll-margin-top: 80px; }

/* ── Verified badge pulse animation ────────────────────────────── */
@keyframes verifiedGlow {
  0%,100% { box-shadow: 0 0 0 2px rgba(245,158,11,.3); }
  50%      { box-shadow: 0 0 0 4px rgba(245,158,11,.15); }
}

/* ── Map score card ─────────────────────────────────────────────── */
#map-score-card { min-width: 110px; }
@media(max-width:360px) { #map-score-card { display: none !important; } }

/* ── Leaflet report marker hover ───────────────────────────────── */
.leaflet-marker-icon div { transition: transform .2s; }
.leaflet-marker-icon div:hover { transform: scale(1.15); }

/* ================================================================
   SafeUp v3.0 — Self-Learning AI System Styles
   Learning Panel · Predictions · Area Stats · Weekly Insights
   ================================================================ */

/* ── Learning Panel ─────────────────────────────────────────────── */
.lp-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 13px;
}
.lp-title  { font-family: var(--f-display); font-size: .88rem; font-weight: 800; }
.lp-badge  {
  font-size: .62rem; font-weight: 700; padding: 3px 10px;
  background: linear-gradient(135deg,#8b5cf6,#7c3aed);
  color: #fff; border-radius: 20px; letter-spacing: .04em;
}
.lp-empty  { font-size: .8rem; color: var(--t3); text-align: center; padding: 12px 0; }

.lp-stats-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 13px;
}
.lp-stat {
  background: var(--bg); border-radius: 10px; padding: 10px 8px;
  text-align: center; border: 1px solid rgba(0,0,0,.05);
}
.lp-stat-val { font-family: var(--f-display); font-size: 1.1rem; font-weight: 900; color: var(--t1); }
.lp-stat-lbl { font-size: .6rem; color: var(--t3); margin-top: 2px; line-height: 1.3; }

.lp-top-area {
  background: var(--orange-light); border: 1px solid var(--orange-border);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 12px;
}
.lp-top-label { font-size: .65rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .06em; }
.lp-top-row   { display: flex; align-items: center; justify-content: space-between; margin: 4px 0; }
.lp-top-name  { font-size: .86rem; font-weight: 700; color: var(--t1); }
.lp-top-score { font-family: var(--f-display); font-size: 1rem; font-weight: 900; }
.lp-bar-wrap  { height: 4px; background: var(--orange-mid); border-radius: 2px; overflow: hidden; }
.lp-bar       { height: 100%; border-radius: 2px; transition: width .8s ease; }

.lp-areas     { display: flex; flex-direction: column; gap: 7px; }
.lp-area-row  {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 10px; background: var(--bg);
  border-radius: 8px; border: 1px solid rgba(0,0,0,.04);
  transition: border-color .2s;
}
.lp-area-row:hover { border-color: var(--orange-border); }
.lp-area-info { flex: 1; min-width: 0; }
.lp-area-name { font-size: .8rem; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-area-meta { font-size: .66rem; color: var(--t3); }
.lp-area-score-wrap { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lp-area-bar-wrap   { width: 60px; height: 4px; background: var(--bg2); border-radius: 2px; overflow: hidden; }
.lp-area-bar        { height: 100%; border-radius: 2px; transition: width .6s ease; }
.lp-area-num        { font-family: var(--f-display); font-size: .82rem; font-weight: 800; min-width: 22px; text-align: right; }

/* ── Predictions Panel ──────────────────────────────────────────── */
.pred-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.pred-title { font-family: var(--f-display); font-size: .84rem; font-weight: 800; }
.pred-count {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--orange); color: #fff;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pred-empty { font-size: .78rem; color: var(--t3); padding: 8px 0; text-align: center; }

.pred-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent; margin-bottom: 7px;
}
.pred-card.pred-high   { background: var(--danger-light); border-color: rgba(239,68,68,.2); }
.pred-card.pred-medium { background: var(--warn-light);   border-color: rgba(245,158,11,.2); }
.pred-icon   { font-size: 1.1rem; flex-shrink: 0; }
.pred-body   { flex: 1; min-width: 0; }
.pred-label  { font-size: .81rem; font-weight: 700; margin-bottom: 2px; }
.pred-detail { font-size: .71rem; color: var(--t2); line-height: 1.4; }

/* ── Area Risk Card ─────────────────────────────────────────────── */
.arc-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.arc-title  { font-size: .84rem; font-weight: 700; }
.arc-badge  { font-size: .62rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.arc-danger { background: var(--danger-light); color: var(--danger); }
.arc-safe   { background: var(--safe-light);   color: var(--safe);   }
.arc-score-row { display: flex; align-items: center; gap: 13px; }
.arc-circle {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid var(--safe); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.arc-num   { font-family: var(--f-display); font-size: 1.15rem; font-weight: 900; }
.arc-label { font-size: .75rem; font-weight: 700; margin-bottom: 2px; }
.arc-meta  { font-size: .66rem; color: var(--t2); }
.arc-night { font-size: .66rem; color: #7c3aed; margin-top: 2px; }

/* ── Weekly Insights strip ──────────────────────────────────────── */
.wi-row  { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.wi-chip {
  padding: 4px 12px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.wi-danger { background: var(--danger-light); color: var(--danger); }
.wi-safe   { background: var(--safe-light);   color: var(--safe);   }
.wi-info   { background: #ede9fe; color: #7c3aed; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media(max-width:768px) {
  .lp-stats-grid { grid-template-columns: repeat(2,1fr); }
  .lp-area-bar-wrap { width: 40px; }
}
@media(max-width:480px) {
  .lp-stats-grid { grid-template-columns: repeat(2,1fr); gap: 6px; }
}
