:root {
  --bg: #0b1220;
  --bg-clear: #22345c;
  --panel: #131c2e;
  --panel-2: #1a2740;
  --text: #e6ecf5;
  --muted: #93a1bd;
  --border: #24324f;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --accent: #3b82f6;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-clear);
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.8s ease;
}

body.outage-active {
  background-color: var(--bg);
}

.wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  padding: 32px 0 8px;
}

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

main { padding: 20px 0 40px; }

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 1.15rem;
  font-weight: 600;
}

.banner__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.banner--ok { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.08); }
.banner--ok .banner__dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15); }

.banner--warn { border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.08); }
.banner--warn .banner__dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15); }

.banner--bad { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); }
.banner--bad .banner__dot { background: var(--bad); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }

.banner--error { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.06); }
.banner--error .banner__dot { background: var(--bad); }

.meta {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.panel {
  margin-top: 26px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel__head h2 { margin: 0; }

.range {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.range select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* List / Map segmented toggle on the Current outages panel. */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
}

.view-toggle__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-toggle__btn + .view-toggle__btn {
  border-left: 1px solid var(--border);
}

.view-toggle__btn:hover { color: var(--text); }

.view-toggle__btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* Experimental "all outages" overview map. */
.overview-map-wrap { position: relative; }
.overview-map-wrap[hidden] { display: none; }

.overview-map {
  height: min(65vh, 560px);
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.overview-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  background: rgba(11, 18, 32, 0.82);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.78rem;
  color: var(--text);
  pointer-events: none;
}

.overview-legend__item { display: inline-flex; align-items: center; gap: 6px; }

.overview-legend__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
}

/* Dark theming for MapLibre popups so they match the panel palette. */
.overview-map .maplibregl-popup-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.overview-map .maplibregl-popup-content strong { color: #fff; }

.overview-map .maplibregl-popup-close-button {
  color: var(--muted);
  font-size: 1.1rem;
  padding: 2px 6px;
}

.overview-map .maplibregl-popup-tip {
  border-top-color: var(--panel);
  border-bottom-color: var(--panel);
}

.overview-popup__title { font-weight: 600; color: #fff; margin-bottom: 2px; }
.overview-popup__kind { color: var(--muted); font-size: 0.78rem; }

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-input {
  flex: 1 1 240px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.filter-input::placeholder { color: var(--muted); }

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-count {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  margin: 6px 0;
}

.current-group + .current-group {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.current-group__title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.current-group--unplanned .current-group__title { color: #fff; }

.outage {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  margin-bottom: 10px;
}

.outage:last-child { margin-bottom: 0; }

.outage__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.outage__title {
  font-weight: 600;
  margin: 0;
  flex: 1 1 auto;
}

/* Keep multiple badges (state + source) grouped together on the right. */
.outage__badges {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge--active { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.badge--cleared { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.badge--planned { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.badge--scheduled { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge--ongoing { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge--done { background: rgba(34, 197, 94, 0.16); color: #86efac; }

/* Source tag: a small attribution pinned to the bottom-right of the card. */
.outage__source {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.outage__source .badge {
  font-size: 0.62rem;
  padding: 2px 7px;
  opacity: 0.85;
}

.badge--enemalta { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.badge--crowdsourced { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.badge--unverified { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

/* Corroboration buttons on a crowdsourced card. */
.outage__actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.outage__act {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.outage__act:disabled {
  cursor: default;
  opacity: 0.7;
}

/* "I am affected too" leans warning/amber; "Mark resolved" leans clear/green. */
.outage__act.js-affected:hover:not(:disabled) {
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.6);
}

.outage__act--resolve:hover:not(:disabled) {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.6);
}

/* --- outage report form + community section --- */
.report__note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.report-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.report-form .filter-input {
  flex: 1 1 220px;
}

/* Report-type toggle sits on its own row above the postcode input. */
.report-kind {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-kind__option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.report-kind__option:has(input:checked) {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(59, 130, 246, 0.12);
}

.report-kind__option input {
  accent-color: var(--accent);
  margin: 0;
}

.report-submit {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.report-submit:hover { filter: brightness(1.08); }
.report-submit:disabled { opacity: 0.6; cursor: default; }

.report__status {
  margin: 12px 2px 0;
  font-size: 0.88rem;
  min-height: 1.2em;
  color: var(--muted);
}

.report__status--ok { color: #86efac; }
.report__status--error { color: #fca5a5; }

.outage__link { color: var(--accent); text-decoration: none; }
.outage__link:hover { text-decoration: underline; }

.outage__meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.outage__desc {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 40px;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p { margin: 4px 0; }

.outage--clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.outage--clickable:hover,
.outage--clickable:focus-visible {
  border-color: var(--accent);
  background: #1f2f4d;
  outline: none;
}

.outage__hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--accent);
}

.map-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(4, 8, 16, 0.6);
  cursor: pointer;
}

.map-backdrop[hidden] { display: none; }

/* Slide-in side panel anchored to the right edge; full width on small screens. */
.map-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.5);
}

.map-overlay[hidden] { display: none; }

.map-overlay__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.map-overlay__title {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.back-button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}

.back-button:hover { border-color: var(--accent); }

.map-canvas {
  flex: 1 1 auto;
  min-height: 240px;
  margin: 16px 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.leaflet-container { background: #0b1220; font-family: inherit; }
/* Standard OSM tiles are light and have no dark variant, so invert them to
   match the panel background. Scoped to .leaflet-tile so the outage markers,
   area circles and popups drawn above them keep their intended colours. */
.leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9) saturate(0.75); }

.map-info {
  flex: 0 0 auto;
  margin: 14px 16px 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.9rem;
  max-height: 38vh;
  overflow-y: auto;
}

.map-info p { margin: 6px 0; }
.map-info strong { color: var(--text); font-weight: 600; }

.outage-marker { background: transparent; border: none; }

.outage-marker__inner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b);
  border: 2px solid #0b1220;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
