:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --critical: #dc2626;
  --info: #06b6d4;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
  --surface-soft: rgba(15,23,42,0.5);
  --on-primary: #ffffff;
  --card-bg: var(--bg-card);
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-hover: #e2e8f0;
  --border: #cbd5e1;
  --text: #172033;
  --text-muted: #526176;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --shadow: 0 4px 12px -4px rgba(15,23,42,0.18);
  --surface-soft: #f8fafc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.2s;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header img.logo {
  max-height: 40px;
  max-width: 120px;
  object-fit: contain;
}

.sidebar-header .app-title {
  font-weight: 700;
  font-size: 1rem;
  color: #f8fafc;
  line-height: 1.2;
}
html[data-theme="light"] .sidebar-header .app-title { color: var(--text); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section { margin-bottom: 20px; }
.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  margin-bottom: 2px;
  transition: background 0.15s;
}
.nav-link:hover { background: var(--bg-hover); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link .icon { font-size: 1.1rem; width: 24px; text-align: center; }

.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-size: 1.25rem; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-menu { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }

.content-area { padding: 24px; flex: 1; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 1.1rem; font-weight: 600; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: rgba(59,130,246,0.15);
}

.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
tr:hover td { background: rgba(51,65,85,0.4); }
html[data-theme="light"] tr:hover td { background: rgba(226,232,240,0.7); }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-success { background: rgba(34,197,94,0.2); color: #4ade80; }
.badge-warning { background: rgba(245,158,11,0.2); color: #fbbf24; }
.badge-danger { background: rgba(239,68,68,0.2); color: #f87171; }
.badge-critical { background: rgba(220,38,38,0.35); color: #fca5a5; }
.badge-info { background: rgba(6,182,212,0.2); color: #22d3ee; }
.badge-secondary { background: rgba(148,163,184,0.2); color: #94a3b8; }
.badge-dark { background: rgba(30,41,59,0.8); color: #cbd5e1; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.875rem; color: var(--text-muted); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  color: #fff;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-secondary { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 1rem;
}
.theme-toggle:hover { background: var(--bg-hover); }

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.alert-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-info { background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { max-height: 60px; max-width: 180px; }
.login-logo h1 { font-size: 1.5rem; margin-top: 12px; }

/* Marker / logo preview */
.marker-preview {
  width: 48px; height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* Pagination */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}
.pagination a, .pagination span {
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
}
.pagination a:hover { background: var(--bg-hover); text-decoration: none; }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 2000;
    width: min(86vw, 320px);
    box-shadow: 12px 0 30px rgba(0,0,0,0.45);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block !important; }
  .topbar { padding: 10px 12px; }
  .content-area { padding: 10px; }
  .page-title { font-size: 1rem; }
  .user-menu > span { display: none; }
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; }

/* Operations Suite */
.ops-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 20px; margin-bottom: 20px; border: 1px solid var(--border);
  background: var(--bg-card);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, var(--bg-card)), var(--bg-card));
  border-radius: var(--radius);
}
.ops-hero h2 { margin-bottom: 5px; }
.ops-hero p, .ops-lead { color: var(--text-muted); }
.connection-status { white-space: nowrap; color: var(--text-muted); font-size: .85rem; }
.connection-status span { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--success); margin-right: 6px; }
.connection-status.is-offline span { background: var(--warning); }
.ops-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.ops-module-card {
  min-width: 0; display: grid; grid-template-columns: 48px minmax(0,1fr) auto; align-items: center;
  gap: 14px; padding: 18px; color: var(--text); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.ops-module-card:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); }
.ops-module-icon { width: 48px; height: 48px; display: grid; place-items: center; font-size: 1.55rem; border-radius: 12px; background: rgba(59,130,246,.15); background: color-mix(in srgb,var(--primary) 15%,transparent); }
.ops-module-body { min-width: 0; }
.ops-module-body h3 { font-size: 1rem; margin-bottom: 4px; }
.ops-module-body p { font-size: .82rem; color: var(--text-muted); }
.ops-module-count { text-align: center; min-width: 54px; }
.ops-module-count strong, .ops-module-count span { display: block; }
.ops-module-count strong { font-size: 1.35rem; }
.ops-module-count span { color: var(--text-muted); font-size: .7rem; text-transform: uppercase; }
.ops-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.ops-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ops-editor { display: none; }
.ops-editor.is-open { display: block; }
.ops-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 16px; }
.ops-span-2 { grid-column: span 2; }
.draft-notice { padding: 10px 12px; margin-bottom: 14px; border-radius: 8px; color: #92400e; background: #fef3c7; border: 1px solid #f59e0b; }
.draft-status { color: var(--text-muted); font-size: .8rem; }
.ops-delete-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.ops-filter { display: grid; grid-template-columns: minmax(160px,240px) minmax(200px,1fr) auto; gap: 12px; align-items: end; padding: 14px; }
.ops-filter .form-group { margin: 0; }
.ops-record-list { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ops-record { margin: 0; border-left-width: 5px; }
.ops-record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.ops-record h3 { margin: 8px 0 3px; }
.ops-meta { color: var(--text-muted); font-size: .82rem; }
.ops-details { margin-top: 14px; }
.ops-facts { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; margin-top: 14px; }
.ops-facts div { padding: 10px; border-radius: 8px; background: var(--surface-soft); border: 1px solid var(--border); }
.ops-facts dt { color: var(--text-muted); text-transform: uppercase; font-size: .65rem; }
.ops-facts dd { margin: 2px 0 0; font-size: .9rem; font-weight: 600; }
.ops-photo-link { display: inline-flex; align-items: center; gap: 10px; margin-top: 14px; }
.ops-photo-link img { width: 74px; height: 56px; object-fit: cover; border-radius: 7px; border: 1px solid var(--border); }
.ops-inline-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ops-inline-list a { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); }
.priority-border-routine { border-left-color: var(--text-muted); }
.priority-border-priority { border-left-color: var(--primary); }
.priority-border-immediate { border-left-color: var(--warning); }
.priority-border-critical { border-left-color: var(--danger); }
.priority-routine { background: rgba(148,163,184,.2); background: color-mix(in srgb,var(--text-muted) 20%,transparent); color: var(--text-muted); }
.priority-priority { background: rgba(59,130,246,.2); background: color-mix(in srgb,var(--primary) 20%,transparent); color: #3b82f6; }
.priority-immediate { background: rgba(245,158,11,.2); background: color-mix(in srgb,var(--warning) 20%,transparent); color: #f59e0b; }
.priority-critical { background: rgba(239,68,68,.2); background: color-mix(in srgb,var(--danger) 20%,transparent); color: #ef4444; }

html[data-theme="light"] .alerts-card,
html[data-theme="light"] .feed-item-card { background: var(--bg-card); }
html[data-theme="light"] .alert-item { background: #f8fafc; }
html[data-theme="light"] .alert-level-critical { background: #fef2f2; }
html[data-theme="light"] .alert-level-high { background: #fff7ed; }
html[data-theme="light"] .alert-level-medium { background: #fffbeb; }
html[data-theme="light"] .alert-level-low { background: #f0fdf4; }
html[data-theme="light"] .alert-headline,
html[data-theme="light"] .alert-body,
html[data-theme="light"] .feed-item-title a,
html[data-theme="light"] .feed-item-area { color: var(--text); }
html[data-theme="light"] .weather-card,
html[data-theme="light"] .flood-card { background: linear-gradient(145deg,#eff6ff,#fff); }
html[data-theme="light"] .weather-stat,
html[data-theme="light"] .forecast-day,
html[data-theme="light"] .flood-metric { background: #f8fafc; border: 1px solid var(--border); }

@media (max-width: 1050px) {
  .ops-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .ops-toolbar, .ops-record-head, .ops-hero { align-items: stretch; flex-direction: column; }
  .ops-actions .btn { flex: 1 1 auto; justify-content: center; }
  .ops-filter { grid-template-columns: 1fr; }
  .ops-filter .btn { width: 100%; justify-content: center; }
  .ops-form-grid { grid-template-columns: 1fr; }
  .ops-span-2 { grid-column: span 1; }
  .ops-table thead { display: none; }
  .ops-table, .ops-table tbody, .ops-table tr, .ops-table td { display: block; width: 100%; }
  .ops-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .ops-table td { border: 0; padding: 5px 8px 5px 42%; position: relative; min-height: 30px; }
  .ops-table td::before { content: attr(data-label); position: absolute; left: 8px; width: 36%; color: var(--text-muted); font-size: .72rem; text-transform: uppercase; }
}

@media (max-width: 480px) {
  .ops-module-card { grid-template-columns: 42px minmax(0,1fr); padding: 14px; }
  .ops-module-icon { width: 42px; height: 42px; }
  .ops-module-count { grid-column: 2; text-align: left; display: flex; gap: 5px; align-items: baseline; }
  .ops-module-count strong, .ops-module-count span { display: inline; }
  .card { padding: 14px; }
  .topbar-right { gap: 6px; }
  .theme-toggle { width: 36px; height: 36px; }
}

/* Incident type icons in list */
.type-icon { font-size: 1.25rem; }

/* Weather card */
.weather-card {
  background: linear-gradient(145deg, #1e3a5f 0%, #1e293b 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.weather-unavailable {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}
.weather-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.weather-icon { font-size: 2.5rem; line-height: 1; }
.weather-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.weather-condition { font-size: 1rem; font-weight: 500; }
.weather-temp { margin-left: auto; font-size: 2rem; font-weight: 700; }
.weather-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.weather-stat {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  padding: 8px 10px;
}
.weather-stat .label { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.weather-stat .value { font-weight: 600; font-size: 0.95rem; }
.weather-alerts { margin-bottom: 12px; }
.weather-alert {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.weather-alert-medium { background: rgba(245,158,11,0.2); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.weather-alert-high { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.weather-alert-critical { background: rgba(220,38,38,0.35); color: #fca5a5; border: 1px solid rgba(220,38,38,0.5); }
.weather-forecast {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.forecast-day {
  flex: 1;
  text-align: center;
  background: rgba(15, 23, 42, 0.45);
  border-radius: 8px;
  padding: 10px 6px;
}
.forecast-day .f-day { font-size: 0.75rem; color: var(--text-muted); }
.forecast-day .f-icon { font-size: 1.4rem; margin: 4px 0; }
.forecast-day .f-temps { font-size: 0.85rem; font-weight: 600; }
.forecast-day .f-precip { font-size: 0.7rem; color: #60a5fa; margin-top: 2px; }
.weather-footer {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}
.weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  .weather-grid { grid-template-columns: 1fr; }
}

/* Flood risk card */
.flood-card {
  background: linear-gradient(145deg, #0c4a6e 0%, #1e293b 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.flood-card.flood-level-critical {
  border-color: rgba(220, 38, 38, 0.6);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}
.flood-card.flood-level-high {
  border-color: rgba(239, 68, 68, 0.45);
}
.flood-card.flood-level-medium {
  border-color: rgba(245, 158, 11, 0.4);
}
.flood-unavailable {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}
.flood-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.flood-icon { font-size: 2.2rem; line-height: 1; }
.flood-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.flood-summary { font-size: 0.95rem; font-weight: 500; margin-top: 2px; }
.flood-badge-wrap { margin-left: auto; text-align: right; }
.flood-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.flood-badge-low { background: rgba(34,197,94,0.25); color: #4ade80; }
.flood-badge-medium { background: rgba(245,158,11,0.25); color: #fbbf24; }
.flood-badge-high { background: rgba(239,68,68,0.25); color: #f87171; }
.flood-badge-critical { background: rgba(220,38,38,0.4); color: #fca5a5; }
.flood-badge-unknown { background: rgba(148,163,184,0.2); color: #94a3b8; }
.flood-score { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.flood-score-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.flood-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.flood-metric {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  padding: 8px 10px;
}
.flood-metric .label { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.flood-metric .value { font-weight: 600; font-size: 0.95rem; }
.flood-alerts { margin-bottom: 12px; }
.flood-alert {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.flood-alert-info { background: rgba(59,130,246,0.15); color: #93c5fd; border: 1px solid rgba(59,130,246,0.25); }
.flood-alert-medium { background: rgba(245,158,11,0.2); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.flood-alert-high { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.flood-alert-critical { background: rgba(220,38,38,0.35); color: #fca5a5; border: 1px solid rgba(220,38,38,0.5); }
.flood-forecast {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  margin-bottom: 8px;
  min-height: 56px;
}
.flood-day { flex: 1; text-align: center; }
.flood-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 44px;
  margin-bottom: 4px;
}
.flood-bar {
  width: 8px;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
}
.flood-bar-discharge { background: #38bdf8; }
.flood-bar-precip { background: #818cf8; }
.flood-legend {
  display: flex;
  gap: 16px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.flood-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.flood-legend .leg-dis { background: #38bdf8; }
.flood-legend .leg-pre { background: #818cf8; }
.flood-footer {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}


/* Severe weather alerts */
.alerts-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.alerts-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.alerts-icon { font-size: 1.8rem; }
.alerts-title { font-weight: 700; font-size: 1.05rem; }
.alerts-source { color: var(--text-muted, #94a3b8); font-size: 0.85rem; }
.alerts-count {
  margin-left: auto;
  background: #7f1d1d;
  color: #fecaca;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.alerts-empty { color: var(--text-muted, #94a3b8); padding: 8px 0; }
.alerts-hint { color: var(--text-muted, #64748b); font-size: 0.85rem; margin-top: 8px; }
.alerts-list { display: flex; flex-direction: column; gap: 12px; }
.alert-item {
  border-radius: 10px;
  padding: 14px 16px;
  border-left: 4px solid #f59e0b;
  background: #0f172a;
}
.alert-level-critical { border-left-color: #ef4444; background: #450a0a; }
.alert-level-high { border-left-color: #f97316; background: #431407; }
.alert-level-medium { border-left-color: #f59e0b; background: #422006; }
.alert-level-low { border-left-color: #22c55e; background: #052e16; }
.alert-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.alert-event { font-weight: 700; font-size: 1.05rem; }
.alert-headline { color: #e2e8f0; margin-bottom: 8px; font-size: 0.95rem; }
.alert-meta { color: #94a3b8; font-size: 0.85rem; margin-bottom: 6px; }
.alert-body { color: #cbd5e1; font-size: 0.9rem; line-height: 1.5; margin-top: 8px; white-space: pre-wrap; }
.alert-instruction {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 8px;
  color: #bfdbfe;
  font-size: 0.9rem;
}
.alert-sender { margin-top: 8px; font-size: 0.8rem; color: #64748b; }
.alerts-disabled { color: #94a3b8; }


/* Local EM feeds board */
.feed-board { display: flex; flex-direction: column; gap: 14px; }
.feed-item-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  padding: 16px 18px;
}
.feed-item-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.feed-source { font-weight: 600; color: #93c5fd; font-size: 0.85rem; }
.feed-region { color: #94a3b8; font-size: 0.85rem; }
.feed-item-title { margin: 0 0 8px; font-size: 1.05rem; }
.feed-item-title a { color: #f8fafc; text-decoration: none; }
.feed-item-title a:hover { color: #60a5fa; }
.feed-item-area { color: #cbd5e1; font-size: 0.9rem; margin-bottom: 6px; }
.feed-item-summary { color: #94a3b8; font-size: 0.9rem; line-height: 1.5; }
.feed-item-time { margin-top: 10px; font-size: 0.8rem; color: #64748b; }


/* Weather radar map */
.radar-page-card { overflow: hidden; }
.radar-map-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, #334155);
}
.radar-map {
  width: 100%;
  height: 520px;
  background: #0f172a;
  z-index: 1;
}
.radar-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.radar-layer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text, #e2e8f0);
  margin: 4px 0;
  font-size: 0.9rem;
}
.radar-time-label {
  margin-left: auto;
  color: #93c5fd;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.radar-coords {
  color: #64748b;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.radar-timeline-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.radar-timeline { flex: 1; }
.radar-frame-info {
  color: #94a3b8;
  font-size: 0.85rem;
  min-width: 52px;
  text-align: right;
}
.hq-marker { background: transparent; border: none; }
.hq-marker-dot {
  background: #3b82f6;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.incident-label {
  background: transparent !important;
  border: none !important;
}
.incident-label span {
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  border: 1px solid #334155;
}
.radar-options {
  background: #0f172a;
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}
.radar-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.radar-opt-group h4 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}
.radar-field-label {
  display: block;
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 8px 0 4px;
}
.radar-select {
  max-width: 100%;
  font-size: 0.9rem;
  padding: 6px 8px;
}
.radar-range { width: 100%; }
.radar-goto {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.radar-legend {
  position: absolute;
  right: 12px;
  bottom: 28px;
  z-index: 500;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  pointer-events: none;
  min-width: 120px;
}
.radar-legend-title {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.radar-legend-bar {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #a7f3d0, #34d399, #fbbf24, #f97316, #ef4444, #a855f7);
}
.radar-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 2px;
}
.radar-map-wrap:fullscreen {
  background: #0f172a;
  padding: 0;
}
.radar-map-wrap:fullscreen .radar-map {
  height: 100vh;
  border-radius: 0;
}
@media (max-width: 700px) {
  .radar-map { height: 360px; }
  .radar-time-label { margin-left: 0; width: 100%; }
  .radar-options-grid { grid-template-columns: 1fr 1fr; }
}

/* Final light-theme overrides for legacy modules defined above. */
html[data-theme="light"] .alerts-card,
html[data-theme="light"] .feed-item-card,
html[data-theme="light"] .dashboard-toolbar { background: var(--bg-card); border-color: var(--border); }
html[data-theme="light"] .alert-item { background: #f8fafc; }
html[data-theme="light"] .alert-level-critical { background: #fef2f2; }
html[data-theme="light"] .alert-level-high { background: #fff7ed; }
html[data-theme="light"] .alert-level-medium { background: #fffbeb; }
html[data-theme="light"] .alert-level-low { background: #f0fdf4; }
html[data-theme="light"] .alert-headline,
html[data-theme="light"] .alert-body,
html[data-theme="light"] .feed-item-title a,
html[data-theme="light"] .feed-item-area,
html[data-theme="light"] .live-clock-date,
html[data-theme="light"] .live-clock-time { color: var(--text); }
html[data-theme="light"] .weather-card,
html[data-theme="light"] .flood-card { background: linear-gradient(145deg,#eff6ff,#fff); }
html[data-theme="light"] .weather-stat,
html[data-theme="light"] .forecast-day,
html[data-theme="light"] .flood-metric { background: #f8fafc; border: 1px solid var(--border); }



/* Lightning layer status */
.radar-lightning-status {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #94a3b8;
}
.radar-lightning-status.ok { color: #4ade80; }
.radar-lightning-status.err { color: #f87171; }
.radar-lightning-count {
  color: #fbbf24;
  font-weight: 600;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}


/* NWS warning color legend */
.radar-legend {
  max-height: 70%;
  overflow-y: auto;
  min-width: 160px;
  max-width: 200px;
}
.radar-legend-section {
  margin-bottom: 10px;
}
.radar-legend-section:last-child {
  margin-bottom: 0;
}
.nws-legend-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.nws-legend-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: #cbd5e1;
  line-height: 1.35;
  margin: 2px 0;
}
.nws-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.35);
  flex-shrink: 0;
}
.lightning-legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #ffffff, #fef08a, #fb923c, #ef4444, #7f1d1d);
  margin-top: 4px;
}


/* Live clock & display pop-out */
.dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
}
.dashboard-clock.live-clock { text-align: left; }
.live-clock-day {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #93c5fd;
  font-weight: 600;
}
.live-clock-date {
  font-size: 1rem;
  color: #cbd5e1;
  margin-top: 2px;
}
.live-clock-time {
  font-size: 1.85rem;
  font-weight: 700;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  margin-top: 2px;
  line-height: 1.15;
}
.popout-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.popout-label {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
@media (max-width: 700px) {
  .live-clock-time { font-size: 1.4rem; }
  .dashboard-toolbar { flex-direction: column; align-items: flex-start; }
}

/* Theme overrides remain last so older component-specific colors cannot win. */
html[data-theme="light"] .alerts-card,
html[data-theme="light"] .feed-item-card,
html[data-theme="light"] .dashboard-toolbar { background: var(--bg-card); border-color: var(--border); }
html[data-theme="light"] .alert-item { background: #f8fafc; }
html[data-theme="light"] .alert-level-critical { background: #fef2f2; }
html[data-theme="light"] .alert-level-high { background: #fff7ed; }
html[data-theme="light"] .alert-level-medium { background: #fffbeb; }
html[data-theme="light"] .alert-level-low { background: #f0fdf4; }
html[data-theme="light"] .alert-headline,
html[data-theme="light"] .alert-body,
html[data-theme="light"] .feed-item-title a,
html[data-theme="light"] .feed-item-area,
html[data-theme="light"] .live-clock-date,
html[data-theme="light"] .live-clock-time { color: var(--text); }
