:root{
  --bg:#0a1220;
  --panel:#0f1b33;
  --panel2:#0d172c;
  --text:#eaf1ff;
  --muted:rgba(234,241,255,.68);
  --border:rgba(255,255,255,.10);

  --safe:#2bd576;
  --watch:#f6c945;
  --warn:#ff9d3c;
  --evac:#ff4d57;

  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1100px 650px at 20% 0%, #1a2f63 0%, var(--bg) 55%);
  color:var(--text);
}

a{
  color:rgba(234,241,255,.9);
  text-decoration:none;
  border-bottom:1px dashed rgba(234,241,255,.35);
}
a:hover{border-bottom-color:rgba(234,241,255,.75)}

.srOnly{
  position:absolute; left:-10000px; top:auto; width:1px; height:1px; overflow:hidden;
}

/* ===== Topbar (mobile-first) ===== */
.topbar{
  position:sticky; top:0; z-index:50;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:flex-start;
  justify-content:space-between;
  padding:12px 12px;
  background: rgba(10,18,32,.78);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}

/* Brand takes full width on small screens */
.brand{
  display:flex; gap:12px; align-items:center;
  width:100%;
  min-width:0;
}
.brandMark{
  width:36px; height:36px; border-radius:12px;
  background: radial-gradient(circle at 30% 30%, #6bb8ff 0%, #2c6cff 40%, #0b2b6c 100%);
  box-shadow: 0 0 24px rgba(77,163,255,.25);
  border:1px solid var(--border);
  flex:0 0 auto;
}
.brandText{min-width:0}
.brandTitle{
  font-weight:900;
  letter-spacing:.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.brandSub{
  font-size:12px;
  color:var(--muted);
  margin-top:3px;
  white-space:normal;
  line-height:1.25;
}

/* Controls: full width on mobile, grid layout */
.controls{
  width:100%;
  display:grid;
  grid-template-columns: 1fr auto;
  gap:10px;
  align-items:center;
}

select,button{
  background: rgba(255,255,255,.07);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
  box-shadow:none;
}

#stationSelect{
  width:100%;
  min-width:0;
}

#refreshBtn{
  white-space:nowrap;
  cursor:pointer;
}
#refreshBtn:hover{background: rgba(255,255,255,.11)}

/* ===== Layout ===== */
.wrap{
  max-width:1200px;
  margin:14px auto;
  padding:0 12px;
}

.hero{
  display:grid;
  gap:12px;
  grid-template-columns: 1fr;
}

.heroCard,.miniCard,.panel{
  background: rgba(15,27,51,.86);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow: var(--shadow);
}

.heroCard{padding:14px}
.heroMeta{
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
}

.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  font-weight:900;
  letter-spacing:.3px;
  background: rgba(255,255,255,.07);
}

.muted{color:var(--muted); font-size:12px}

.heroTitle{font-size:16px; font-weight:950; margin-top:10px; line-height:1.2}
.heroSub{color:var(--muted); margin-top:6px; font-size:13px}

.kpis{
  margin-top:12px;
  display:grid;
  gap:10px;
  grid-template-columns: 1fr; /* single column on small screens */
}

.kpi{
  background: rgba(13,23,44,.70);
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px;
}

.k{color:var(--muted); font-size:12px}
.v{font-size:20px; font-weight:950; margin-top:8px}

.miniCard{
  padding:14px;
  background: rgba(13,23,44,.75);
}
.miniTitle{font-weight:950; margin-bottom:8px}
.miniList{
  margin:0;
  padding-left:18px;
  color:rgba(234,241,255,.85);
  font-size:13px;
}
.miniList li{margin:8px 0}
.note{
  margin-top:12px;
  font-size:12px;
  color:var(--muted);
  border-top:1px solid var(--border);
  padding-top:10px;
}

.grid{
  margin-top:12px;
  display:grid;
  gap:12px;
  grid-template-columns: 1fr; /* stack panels on mobile */
}

.panel{padding:14px}
.panelHead{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  flex-wrap:wrap;
}
h2{margin:0; font-size:15px}

.chartBox{
  margin-top:10px;
  background: rgba(0,0,0,.18);
  border:1px solid var(--border);
  border-radius:16px;
  padding:10px;
  overflow:hidden;
}

canvas{
  width:100%;
  height:220px; /* mobile-friendly height */
  display:block;
}

.alerts{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.alert{
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px;
  background: rgba(0,0,0,.16);
}
.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border-radius:999px;
  padding:5px 10px;
  font-size:12px;
  font-weight:950;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.07);
}
.alertTitle{margin-top:10px; font-weight:950; font-size:14px}
.alertBody{margin-top:6px; color:rgba(234,241,255,.85); font-size:13px; line-height:1.35}

.footer{
  margin:16px 0 28px;
  text-align:center;
}

/* ===== Tablet ===== */
@media (min-width: 520px){
  .wrap{padding:0 16px}
  .topbar{padding:14px 16px}
  .kpis{grid-template-columns: repeat(2, minmax(0, 1fr));}
  canvas{height:260px}
}

/* ===== Desktop ===== */
@media (min-width: 980px){
  .brand{width:auto}
  .controls{width:auto; display:flex}
  .hero{grid-template-columns: 1.5fr .9fr}
  .grid{grid-template-columns: 1.6fr 1fr}
  .kpis{grid-template-columns: repeat(3, minmax(0, 1fr));}
  canvas{height:320px}
  .heroTitle{font-size:18px}
}
