:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #131722;
  --text-muted: #5b6472;
  --border: #dfe3ea;
  --accent: #d97706;
  --accent-strong: #b45309;
  --danger: #dc2626;
  --safe: #16a34a;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --header-h: 56px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f19;
    --surface: #141a26;
    --surface-2: #1b2230;
    --text: #e8ebf1;
    --text-muted: #93a0b4;
    --border: #262f40;
    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --danger: #f87171;
    --safe: #4ade80;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #141a26;
  --surface-2: #1b2230;
  --text: #e8ebf1;
  --text-muted: #93a0b4;
  --border: #262f40;
  --accent: #f59e0b;
  --accent-strong: #fbbf24;
  --danger: #f87171;
  --safe: #4ade80;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

:root[data-theme="light"] {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #131722;
  --text-muted: #5b6472;
  --border: #dfe3ea;
  --accent: #d97706;
  --accent-strong: #b45309;
  --danger: #dc2626;
  --safe: #16a34a;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

.brand-bolt {
  font-size: 18px;
}

.header-status {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.app-main {
  padding-top: calc(var(--header-h) + env(safe-area-inset-top) + 12px);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  min-height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.placeholder-card,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.placeholder-card h2,
.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.placeholder-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.field-label:first-of-type {
  margin-top: 0;
}

select,
textarea,
input[type="password"],
input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
}

select:focus,
textarea:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
}

.btn-block {
  width: 100%;
  margin-top: 16px;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:active {
  opacity: 0.85;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#myReportBanner {
  border-color: var(--accent);
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.section-title-row h2 {
  margin: 0;
}

.report-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
}

.report-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.report-item:last-child {
  border-bottom: none;
}

.report-item-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.report-item-locality {
  font-weight: 600;
  font-size: 14px;
}

.report-item-note {
  margin-top: 2px;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 0;
  text-align: center;
}

/* Map view */

.map-stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-pill {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-number {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.map-shell {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: 60vh;
  min-height: 320px;
}

#mapContainer {
  width: 100%;
  height: 100%;
  background: var(--surface-2);
}

.map-empty-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 500;
  pointer-events: none;
}

.map-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.legend-swatch {
  display: inline-block;
  width: 120px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fde8d0, #f7b571, #f2954a, #d97706, #b45309, #7c3a06);
  border: 1px solid var(--border);
}

.leaflet-popup-content {
  font-size: 13px;
}

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

.outage-marker {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 0;
}

.tab-btn .tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab-btn.active {
  color: var(--accent-strong);
}

.tab-btn:active {
  opacity: 0.7;
}
