:root {
  --bg: #08101d;
  --panel: #0f1a2e;
  --panel-2: #15233c;
  --border: rgba(255,255,255,0.09);
  --text: #edf4ff;
  --muted: #9cb2d3;
  --accent: #67d6ff;
  --danger: #ff8b5e;
  --success: #6fe3a9;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
body { overflow: hidden; }
.app-shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(103,214,255,0.11), rgba(255,139,94,0.07));
}
.topbar-brand {
  display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 auto;
}
.topbar-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex: 0 0 auto;
}
.topbar-logo.naec-logo {
  height: 56px; width: auto; display: block; flex: 0 0 auto;
}
.brand-copy { min-width: 0; }
.brand-title { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.2px; }
.brand-subtitle { font-size: 0.88rem; color: var(--muted); }
.powered-by-chip {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 0; padding: 6px 10px;
  border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.04);
  box-shadow: 0 6px 18px rgba(0,0,0,0.15); max-width: min(560px, 100%);
}
.powered-by-chip span {
  color: var(--muted); font-size: 0.8rem; line-height: 1.25; font-weight: 600;
}
.powered-by-logo {
  height: 28px; width: auto; display: block; flex: 0 0 auto;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--muted); font-size: 0.82rem;
}
.cards-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 12px 18px 0 18px; }
.summary-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px; box-shadow: 0 10px 24px rgba(0,0,0,0.24);
}
.summary-label { font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.summary-value { margin-top: 4px; font-size: 1.85rem; font-weight: 800; }
.summary-note { margin-top: 4px; color: var(--muted); font-size: 0.9rem; line-height: 1.35; }
.main-grid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; gap: 12px; padding: 12px 18px 18px 18px;
}
.card-panel {
  min-height: 0; display: flex; flex-direction: column; background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 12px 28px rgba(0,0,0,0.28); overflow: hidden;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.panel-body { min-height: 0; overflow: auto; padding: 14px 16px; }
.control-block { margin-bottom: 18px; }
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }
.small-text { font-size: 0.88rem; }
.alerts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.alert-chip { padding: 8px 10px; border-radius: 12px; background: rgba(255,139,94,0.12); border: 1px solid rgba(255,139,94,0.22); font-size: 0.84rem; }
.alert-chip.warning { background: rgba(255,107,107,0.12); border-color: rgba(255,107,107,0.28); }
.alert-chip.watch { background: rgba(255,193,7,0.12); border-color: rgba(255,193,7,0.28); }
.alert-chip.advisory { background: rgba(103,214,255,0.12); border-color: rgba(103,214,255,0.28); }
#map { width: 100%; height: 100%; min-height: 420px; background: #07111f; }
.map-panel .panel-header { align-items: flex-start; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.8rem; }
.legend-dot { display: inline-block; width: 11px; height: 11px; border-radius: 999px; margin-right: 6px; vertical-align: middle; }
.legend-dot.outage { background: #ff5a1f; }
.legend-dot.individual { background: #00d5ff; }
.legend-dot.substation { background: #8d7bff; }
.right-stack { display: flex; flex-direction: column; gap: 18px; }
.list-stack { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.03); color: var(--text); cursor: pointer;
}
.list-item:hover { border-color: rgba(103,214,255,0.35); background: rgba(103,214,255,0.08); }
.list-item-title { font-size: 0.93rem; font-weight: 700; line-height: 1.28; word-break: break-word; }
.list-item-meta { font-size: 0.8rem; color: var(--muted); margin-top: 4px; line-height: 1.28; word-break: break-word; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0f1c31; color: var(--text); }
.leaflet-container a { color: #8ddfff; }
.leaflet-control-layers, .leaflet-bar a { background: #10203a; color: var(--text); border-color: rgba(255,255,255,0.15); }
.leaflet-bar a:hover { background: #183052; color: var(--text); }
.hazard-label {
  background: rgba(8, 16, 29, 0.92); color: #fff4c7; border: 1px solid rgba(255, 197, 61, 0.55);
  border-radius: 8px; box-shadow: none; padding: 2px 6px; font-size: 0.72rem; font-weight: 700;
}
.hazard-label:before { display: none; }
.individual-zoom-hint { margin-top: 10px; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
@media (max-width: 1400px) {
  .cards-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card.wide { grid-column: span 2; }
  .main-grid { grid-template-columns: 280px minmax(0, 1fr) 320px; }
}
@media (max-width: 1080px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .topbar { order: 0; align-items: flex-start; }
  .topbar-brand { width: 100%; }
  .topbar-right { align-items: flex-start; width: 100%; }
  .main-grid { display: contents; }
  .map-panel { order: 1; height: 62vh; margin: 12px 18px 0 18px; }
  .cards-row { order: 2; grid-template-columns: 1fr 1fr; padding-top: 12px; }
  .summary-card.wide { grid-column: span 2; }
  .sidebar-left { order: 3; margin: 12px 18px 0 18px; }
  .sidebar-right { order: 4; margin: 12px 18px 18px 18px; }
}
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-brand { align-items: flex-start; }
  .topbar-logo.naec-logo { height: 44px; }
  .brand-title { font-size: 1.15rem; }
  .powered-by-chip {
    display: flex; width: 100%; max-width: 100%; border-radius: 14px; padding: 8px 10px;
  }
  .powered-by-chip span { font-size: 0.78rem; }
  .powered-by-logo { height: 24px; }
  .topbar-actions { justify-content: flex-start; }
  .cards-row { grid-template-columns: 1fr; }
  .summary-card.wide { grid-column: span 1; }
}
