:root {
  color-scheme: dark;
  --bg: #060b14;
  --sidebar-bg: rgba(8, 14, 28, 0.97);
  --panel: rgba(10, 18, 36, 0.95);
  --line: rgba(148, 163, 184, 0.1);
  --line-hover: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #64748b;
  --accent: #7c3aed;
  --accent2: #22d3ee;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --sidebar-w: 380px;
  --glow-accent: 0 0 20px rgba(124, 58, 237, 0.3);
  --glow-cyan: 0 0 20px rgba(34, 211, 238, 0.3);
  --glow-green: 0 0 20px rgba(74, 222, 128, 0.3);
  --glow-blue: 0 0 20px rgba(56, 189, 248, 0.3);
  --glow-amber: 0 0 20px rgba(251, 191, 36, 0.3);
  --bg-subtle: rgba(15, 23, 42, 0.5);
  --bg-card: rgba(6, 11, 20, 0.7);
  --bg-deep: rgba(6, 11, 20, 0.98);
  --bg-input: rgba(15, 23, 42, 0.6);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-overlay: rgba(6, 11, 20, 0.7);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle animated gradient background behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 10% 90%, rgba(124, 58, 237, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 90% 10%, rgba(34, 211, 238, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  height: 100vh;
  flex-shrink: 0;
  transition: width 0.25s ease, min-width 0.25s ease, border-color 0.25s ease;
}
.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  border-right-color: transparent;
}
.app-shell.sidebar-collapsed .sidebar-resize {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-svg {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.4));
}
.logo-icon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  opacity: 0.25;
  z-index: -1;
  filter: blur(8px);
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 1px;
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.sidebar-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--line-hover);
}
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.theme-toggle:hover {
  color: var(--accent2);
  border-color: var(--accent2);
}

/* Light theme overrides */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f0f2f5;
  --sidebar-bg: rgba(255, 255, 255, 0.97);
  --panel: rgba(255, 255, 255, 0.95);
  --line: rgba(0, 0, 0, 0.08);
  --line-hover: rgba(0, 0, 0, 0.16);
  --text: #1e293b;
  --text-secondary: #475569;
  --muted: #94a3b8;
  --accent: #7c3aed;
  --accent2: #0891b2;
  --blue: #0284c7;
  --purple: #7c3aed;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --glow-accent: 0 0 12px rgba(124, 58, 237, 0.12);
  --glow-cyan: 0 0 12px rgba(8, 145, 178, 0.12);
  --glow-green: 0 0 12px rgba(22, 163, 74, 0.12);
  --glow-blue: 0 0 12px rgba(2, 132, 199, 0.12);
  --glow-amber: 0 0 12px rgba(217, 119, 6, 0.12);
  --bg-subtle: rgba(241, 245, 249, 0.8);
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-deep: rgba(255, 255, 255, 0.98);
  --bg-input: rgba(241, 245, 249, 0.8);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-overlay: rgba(255, 255, 255, 0.85);
}
[data-theme="light"] .sidebar-toggle:hover {
  background: rgba(0,0,0,0.04);
}
[data-theme="light"] .chat-msg.bot-msg .msg-body,
[data-theme="light"] .nearby-item,
[data-theme="light"] .project-item {
  background: rgba(241, 245, 249, 0.7);
  border-color: var(--line);
}
[data-theme="light"] .chat-input,
[data-theme="light"] .nearby-input {
  background: rgba(241, 245, 249, 0.6);
  color: var(--text);
}
[data-theme="light"] .sources-toggle {
  background: rgba(241, 245, 249, 0.5);
}
[data-theme="light"] .detail-panel {
  background: var(--panel);
  color: var(--text);
}
[data-theme="light"] .advisor-chat,
[data-theme="light"] .impact-detail-card {
  background: rgba(241, 245, 249, 0.5);
}
[data-theme="light"] .leaflet-popup-content-wrapper {
  background: #fff;
  color: #1e293b;
}
[data-theme="light"] .leaflet-popup-tip { background: #fff; }
[data-theme="light"] .popup-title { color: #1e293b; }
[data-theme="light"] .popup-meta { color: #64748b; }
[data-theme="light"] .map-glow { display: none; }
[data-theme="light"] body::before { opacity: 0.15; }
[data-theme="light"] .stat-bar {
  background: rgba(241, 245, 249, 0.5);
}

/* SIDEBAR NAV */
.sidebar-nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 13px 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
}
.nav-btn:hover { color: var(--text-secondary); }
.nav-btn.active {
  color: var(--accent2);
  border-bottom-color: var(--accent2);
}
.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent2);
  border-radius: 2px;
  filter: blur(3px);
  opacity: 0.6;
}
.nav-icon { font-size: 0.85rem; }

.nav-alert-count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.61rem;
  line-height: 16px;
  text-align: center;
  font-weight: 800;
}
.nav-alert-count.hidden { display: none; }

/* TAB CONTENT */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}
.tab-content.active { display: flex; flex-direction: column; gap: 14px; }

.tab-content::-webkit-scrollbar { width: 5px; }
.tab-content::-webkit-scrollbar-track { background: transparent; }
.tab-content::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.15); border-radius: 3px; }
.tab-content::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.3); }

/* FILTERS */
.filter-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 600;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.chip:hover {
  border-color: var(--line-hover);
  color: var(--text-secondary);
  background: var(--bg-subtle);
}
.chip.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(34, 211, 238, 0.15));
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.15);
}

.topic-chip.active {
  background: rgba(248, 113, 113, 0.12);
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.1);
  text-decoration: line-through;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s;
}
.search-input:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}
.search-input::placeholder { color: rgba(100, 116, 139, 0.6); }

/* ========== PROJECT LIST ========== */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.project-item {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font: inherit;
  overflow: hidden;
  min-height: 64px;
}
.project-item:hover {
  border-color: var(--line-hover);
  background: var(--bg-deep);
}

.project-item-type-strip {
  width: 5px;
  flex-shrink: 0;
  border-radius: 14px 0 0 14px;
}

.project-item-body {
  flex: 1;
  min-width: 0;
  padding: 16px 16px 15px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.project-item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.project-item-name {
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  color: var(--text);
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.project-item-score {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent2);
  flex-shrink: 0;
  line-height: 1;
  letter-spacing: -0.02em;
}
.project-item-score small {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.project-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.project-item-type-label {
  font-weight: 700;
  font-size: 0.78rem;
}

.project-item-sep {
  color: rgba(100, 116, 139, 0.35);
  font-size: 0.65rem;
}

.project-item-state {
  color: var(--text-secondary);
  font-weight: 500;
}

.project-item-cap {
  color: var(--accent2);
  font-weight: 600;
  font-size: 0.82rem;
}

.project-item-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-operational { background: rgba(74, 222, 128, 0.12); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.2); }
.status-proposed { background: rgba(56, 189, 248, 0.12); color: var(--blue); border: 1px solid rgba(56, 189, 248, 0.2); }
.status-under-construction { background: rgba(251, 191, 36, 0.12); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.2); }
.status-in-review { background: rgba(167, 139, 250, 0.12); color: var(--purple); border: 1px solid rgba(167, 139, 250, 0.2); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-size: 0.9rem;
}

/* ========== SIDEBAR RESIZE ========== */
.sidebar-resize {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 1001;
  flex-shrink: 0;
  transition: background 0.2s;
}
.sidebar-resize:hover,
.sidebar-resize.dragging {
  background: var(--accent2);
}
.sidebar-resize::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 40px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.2s, height 0.2s;
}
.sidebar-resize:hover::before,
.sidebar-resize.dragging::before {
  background: var(--accent2);
  height: 60px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--bg-card) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 500;
}

.hamburger {
  display: none;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 1.2rem;
  padding: 7px 11px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.hamburger:hover { border-color: var(--line-hover); background: rgba(30, 41, 59, 0.6); }
.app-shell.sidebar-collapsed .hamburger { display: block; }

.top-bar-info {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg-subtle);
  backdrop-filter: blur(4px);
  transition: all 0.2s;
}
.stat-pill:hover { border-color: var(--line-hover); }
.stat-pill.accent { color: var(--accent2); border-color: rgba(34,211,238,0.2); background: rgba(34, 211, 238, 0.06); }
.stat-pill.green { color: var(--green); border-color: rgba(74,222,128,0.2); background: rgba(74, 222, 128, 0.06); }

.map-container {
  flex: 1;
  z-index: 1;
}

/* ========== LEAFLET MARKER ========== */
.custom-marker { background: none !important; border: none !important; box-shadow: none !important; }
.leaflet-marker-icon { background: none !important; border: none !important; }
.marker-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  transition: all 0.2s;
  position: relative;
}
.marker-dot::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: inherit;
  opacity: 0;
  transition: opacity 0.2s;
  filter: blur(6px);
}
.marker-dot:hover { transform: scale(1.4); }
.marker-dot:hover::after { opacity: 0.4; }

/* ========== LEAFLET POPUP ========== */
.gridhalo-popup .leaflet-popup-content-wrapper {
  background: var(--bg-deep);
  border: 1px solid var(--line-hover);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.6), 0 0 40px rgba(34, 211, 238, 0.05);
  color: var(--text);
  padding: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.gridhalo-popup .leaflet-popup-content {
  margin: 0;
  padding: 0;
}
.gridhalo-popup .leaflet-popup-tip {
  background: var(--bg-deep);
  border: 1px solid var(--line-hover);
  box-shadow: none;
}
.gridhalo-popup .leaflet-popup-close-button {
  color: var(--muted) !important;
  font-size: 20px !important;
  padding: 8px 10px !important;
}
.gridhalo-popup .leaflet-popup-close-button:hover {
  color: var(--text) !important;
}

.popup-card { padding: 18px; min-width: 290px; max-width: 340px; }
.popup-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.popup-type-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.popup-type { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.popup-status { margin-left: auto; }
.popup-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}
.popup-state { font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }
.popup-watts { margin-bottom: 10px; }
.popup-watts-value {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent2), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.popup-detail { font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; line-height: 1.5; }
.popup-detail strong { color: var(--text-secondary); }
.popup-summary {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}
.popup-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.mini-score {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--line);
}
.mini-score span { display: block; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.mini-score strong { font-size: 0.95rem; font-weight: 700; }
.popup-detail-btn {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(34, 211, 238, 0.3);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.08), rgba(124, 58, 237, 0.06));
  color: var(--accent2);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}
.popup-detail-btn:hover {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(124, 58, 237, 0.12));
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.1);
  transform: translateY(-1px);
}

/* ========== DETAIL PANEL ========== */
.detail-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(440px, 100%);
  background: var(--bg-deep);
  border-left: 1px solid var(--line);
  z-index: 600;
  overflow-y: auto;
  padding: 24px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.detail-panel.hidden { display: none; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.detail-panel::-webkit-scrollbar { width: 5px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.15); border-radius: 3px; }

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1.2rem;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.detail-close:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--line-hover);
}

.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding-right: 44px; }
.detail-type-badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 0 0 12px currentColor;
}
.detail-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.detail-owner {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.detail-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}
.detail-big-stat {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  transition: all 0.2s;
}
.detail-big-stat:hover {
  border-color: var(--line-hover);
  background: var(--bg-input);
}
.detail-big-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: -0.02em;
}
.detail-big-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.detail-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-scores {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-score-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
}
.detail-score-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.detail-score-header strong { color: var(--accent2); }
.score-grade { font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-left: 4px; }

/* ========== SCORING EXPLANATIONS ========== */
.scoring-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.6;
}
.scoring-section {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  transition: border-color 0.2s;
}
.scoring-section:hover { border-color: var(--line-hover); }
.scoring-section-header {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.scoring-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.scoring-factors {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.scoring-factor {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg-subtle);
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.scoring-factor:hover { border-color: var(--line); }
.factor-positive { color: var(--green); background: rgba(74, 222, 128, 0.06); border-color: rgba(74, 222, 128, 0.1); }
.factor-negative { color: var(--red); background: rgba(248, 113, 113, 0.06); border-color: rgba(248, 113, 113, 0.1); }
.factor-neutral { color: var(--muted); background: var(--bg-subtle); border-color: var(--line); }

.scoring-methodology { margin-top: 8px; }

/* ========== IMPACT TAB ========== */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

.halo-tagline {
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--accent2), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.01em;
}

.score-scale {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}
.score-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 650;
}
.score-band strong { font-size: 0.64rem; color: var(--muted); }
.score-band-excellent { border-color: rgba(74, 222, 128, 0.35); }
.score-band-good { border-color: rgba(34, 211, 238, 0.3); }
.score-band-fair { border-color: rgba(250, 204, 21, 0.28); }
.score-band-poor,
.score-band-very-poor { border-color: rgba(248, 113, 113, 0.3); }
.score-band:last-child { grid-column: 1 / -1; }

.dropdown-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.dropdown-control:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}
.dropdown-control option { background: var(--bg); color: var(--text); }

.avg-score-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.06), rgba(124, 58, 237, 0.06));
  position: relative;
  overflow: hidden;
}
.avg-score-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(34, 211, 238, 0.03), transparent, rgba(124, 58, 237, 0.03), transparent);
  animation: rotateGlow 8s linear infinite;
}
@keyframes rotateGlow { to { transform: rotate(360deg); } }
.avg-score-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
  z-index: 1;
}
.avg-score-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent2), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  z-index: 1;
}
.avg-score-value small {
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.7;
}

.impact-scores {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.impact-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  transition: all 0.2s;
}
.impact-card:hover {
  border-color: var(--line-hover);
  background: var(--bg-subtle);
}
.impact-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.impact-label { font-size: 0.9rem; font-weight: 600; }
.impact-grade { font-size: 1.1rem; font-weight: 800; }
.impact-grade small { font-size: 0.75rem; font-weight: 600; opacity: 0.7; }

.impact-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 8px;
}
.impact-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.impact-note { font-size: 0.82rem; color: var(--muted); margin: 0; }
.impact-details { margin-top: 8px; }

/* IMPACT TYPE CARDS */
.impact-type-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.impact-type-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  cursor: default;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.impact-type-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.impact-type-card:hover {
  border-color: var(--line-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.impact-type-card:hover::before { opacity: 0.5; }
.impact-type-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.impact-type-icon {
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-hover);
}
.impact-type-name { font-size: 0.95rem; font-weight: 700; }
.impact-type-count { font-size: 0.73rem; color: var(--muted); margin-left: auto; font-weight: 500; }
.impact-type-overall {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.impact-type-grade {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}
.impact-type-grade-letter {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}
.impact-type-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.impact-mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.impact-mini-row span:first-child {
  font-size: 0.68rem;
  color: var(--muted);
  width: 88px;
  flex-shrink: 0;
  letter-spacing: 0.01em;
  font-weight: 600;
}
.impact-mini-row .impact-bar { flex: 1; margin-bottom: 0; }
.impact-mini-row strong { font-size: 0.8rem; width: 68px; text-align: right; flex-shrink: 0; font-weight: 600; }
.impact-mini-score small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1;
}

/* POPUP SCORE ROW */
.popup-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
}
.popup-avg-score {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent2), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.popup-avg-grade {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* ========== DETAIL PANEL TABS ========== */
.detail-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  background: var(--bg-subtle);
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 18px;
}
.detail-tab {
  min-width: 0;
  padding: 8px 4px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
}
.detail-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}
.detail-tab.active {
  color: white;
  background: linear-gradient(135deg, var(--accent), rgba(124, 58, 237, 0.8));
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}
.detail-tab-panel { display: none; }
.detail-tab-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

.env-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.detail-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  transition: all 0.2s;
}
.detail-item:hover {
  border-color: var(--line-hover);
  background: var(--bg-subtle);
}
.detail-label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
  font-weight: 600;
}
.detail-value { font-size: 0.88rem; font-weight: 600; color: var(--accent2); }

/* ========== AI ADVISOR ========== */
.advisor-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-card);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.15); border-radius: 3px; }

.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-msg { justify-content: flex-end; }
.user-msg .msg-body {
  background: linear-gradient(135deg, var(--accent), rgba(124, 58, 237, 0.9));
  color: white;
  border-radius: 16px 16px 4px 16px;
  padding: 11px 16px;
  font-size: 0.88rem;
  max-width: 85%;
  line-height: 1.55;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.bot-msg .msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.2);
}

.bot-msg .msg-body {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  padding: 12px 16px;
  font-size: 0.88rem;
  max-width: 85%;
  line-height: 1.6;
  color: var(--text-secondary);
}
.bot-msg .msg-body strong { color: var(--accent2); }

.advisor-warning {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 7px;
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  font-size: 12px;
  line-height: 1.45;
}

[data-theme="light"] .advisor-warning {
  color: #92400e;
  background: #fffbeb;
  border-color: #fcd34d;
}

/* SOURCES SECTION */
.sources-section {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.sources-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.sources-toggle:hover,
.sources-toggle.open {
  border-color: var(--accent2);
  color: var(--accent2);
  background: rgba(34, 211, 238, 0.06);
}
.sources-list {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.sources-list.open {
  display: flex;
}
.source-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  color: var(--accent2);
  font-size: 0.78rem;
  text-decoration: none;
  transition: all 0.2s;
  line-height: 1.4;
}
.source-link-text { flex: 1; min-width: 0; }
.source-link:hover {
  border-color: var(--line-hover);
  background: rgba(34, 211, 238, 0.06);
}
.source-link::before {
  content: '\2197 ';
  font-size: 0.7rem;
  opacity: 0.5;
  flex-shrink: 0;
}
.source-link-trusted {
  border-color: rgba(74, 222, 128, 0.22);
  background: rgba(74, 222, 128, 0.05);
}
.source-link-trusted:hover {
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.08);
}
.source-trusted {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green);
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.25);
  padding: 2px 7px;
  border-radius: 999px;
}

.loading-dots span {
  animation: blink 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.3s; }
.loading-dots span:nth-child(3) { animation-delay: 0.6s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  padding: 10px 14px;
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  transition: all 0.2s;
}
.chat-input:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}
.chat-input::placeholder { color: rgba(100, 116, 139, 0.5); }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), rgba(124, 58, 237, 0.9));
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}
.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}

/* ========== CIVIC ACTION HUB ========== */
.community-controls {
  margin-bottom: 12px;
}
.community-filter-row {
  display: flex;
  gap: 6px;
}
.community-filter-row .dropdown-control {
  flex: 1;
}
.community-compose {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}
.community-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.community-input:focus { border-color: var(--accent2); }
.community-topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.community-topic-row .dropdown-control { flex: 1; }
.community-field-label {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}
.community-other-topic.hidden { display: none; }
.community-other-topic .community-field-label { display: block; margin: 0 0 5px 2px; }
.community-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.2s;
}
.community-textarea:focus { border-color: var(--accent2); }
.community-post-btn {
  margin-top: 8px;
  padding: 9px 20px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.community-post-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}
.community-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 450px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.community-post {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  transition: border-color 0.2s;
}
.community-post:hover { border-color: var(--line-hover); }
.community-post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.community-post-author {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}
.community-post-time {
  font-size: 0.72rem;
  color: var(--muted);
}
.community-post-category {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.community-post-topic {
  display: inline-block;
  margin: 0 0 6px 6px;
  color: var(--accent2);
  font-size: 0.68rem;
  font-weight: 700;
}
.cat-General { background: rgba(100, 116, 139, 0.15); color: var(--muted); }
.cat-Concern { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.cat-Support { background: rgba(74, 222, 128, 0.12); color: var(--green); }
.cat-Question { background: rgba(56, 189, 248, 0.12); color: var(--blue); }
.cat-Action { background: rgba(251, 191, 36, 0.12); color: var(--amber); }
.community-post-text {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.community-post-project {
  font-size: 0.72rem;
  color: var(--accent2);
  margin-bottom: 8px;
  cursor: pointer;
}
.community-post-project:hover { text-decoration: underline; }
.community-post-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.community-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.community-action-btn:hover {
  border-color: var(--line);
  color: var(--text);
  background: var(--bg-hover);
}
.community-action-btn.liked { color: var(--red); }
.community-action-btn.delete-btn:hover { border-color: var(--red); color: var(--red); background: rgba(248, 113, 113, 0.08); }
.community-replies {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.community-reply {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--line);
}
.community-reply-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
.community-reply-author { font-weight: 600; font-size: 0.78rem; color: var(--text); }
.community-reply-time { font-size: 0.68rem; color: var(--muted); }
.community-reply-text { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.45; }
.community-reply-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.community-reply-input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  outline: none;
}
.community-reply-input:focus { border-color: var(--accent2); }
.community-reply-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent2);
  color: #0f172a;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

/* ========== NEAR ME ========== */
.nearby-search {
  margin-bottom: 16px;
}
.nearby-address-form {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.nearby-field-number { grid-column: span 4; }
.nearby-field-street { grid-column: span 8; }
.nearby-field-city { grid-column: span 5; }
.nearby-field-state { grid-column: span 3; }
.nearby-field-zip { grid-column: span 4; }
.nearby-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}
.nearby-field span {
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nearby-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}
.nearby-input:focus {
  border-color: var(--accent2);
}
.nearby-field-state .nearby-input {
  padding-left: 9px;
  padding-right: 9px;
}
.nearby-address-hint {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}
.nearby-address-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.nearby-search-btn {
  min-width: 170px;
  height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--accent2);
  background: var(--accent2);
  color: #0f172a;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.nearby-search-btn:hover {
  background: var(--accent);
}
.nearby-clear-btn {
  min-width: 72px;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.nearby-clear-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.nearby-radius-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nearby-radius-row .filter-label {
  margin-bottom: 0;
}
.nearby-type-search {
  margin-top: 10px;
}
.nearby-type-search .nearby-input {
  width: 100%;
}
@media (max-width: 620px) {
  .nearby-field-number { grid-column: span 4; }
  .nearby-field-street { grid-column: span 8; }
  .nearby-field-city { grid-column: span 5; }
  .nearby-field-state { grid-column: span 3; }
  .nearby-field-zip { grid-column: span 4; }
}
.nearby-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.nearby-stat-btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.25);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}
.nearby-stat-btn:hover,
.nearby-stat-btn.active {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.2);
  transform: translateY(-1px);
}
.nearby-stat-btn .nearby-stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.nearby-stat-btn .nearby-stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.3;
}
.nearby-results {
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.nearby-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.nearby-item:hover {
  border-color: var(--line-hover);
  background: rgba(34, 211, 238, 0.04);
  transform: translateY(-1px);
}
.nearby-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.nearby-item-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}
.nearby-item-dist {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(34, 211, 238, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.nearby-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}
.nearby-item-type {
  font-weight: 600;
}

/* ========== DATA SOURCES ========== */
.source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plain-language-card,
.plain-language-callout {
  padding: 12px 14px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-left: 3px solid var(--accent2);
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.06);
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.55;
}
.plain-language-card strong,
.plain-language-callout strong { color: var(--text); }
.plain-language-card p { margin: 5px 0 0; }
.plain-language-callout { margin: 10px 0 14px; }

.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.glossary-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.glossary-item summary {
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}
.glossary-item summary:hover,
.glossary-item[open] summary { color: var(--accent2); background: var(--bg-hover); }
.glossary-item p {
  padding: 0 12px 12px 28px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.55;
}
.sources-heading { margin-top: 8px; }
.value-explanation {
  display: block;
  max-width: 240px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.4;
}

.source-item {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  transition: all 0.2s;
}
.source-item:hover {
  border-color: var(--line-hover);
  background: var(--bg-subtle);
}
.source-item strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 4px;
  color: var(--accent2);
  font-weight: 700;
}
.source-item p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.evidence-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}
.evidence-heading span {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent2);
  font-size: 0.7rem;
  text-align: center;
}
.evidence-source-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.evidence-source-card {
  display: flex;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-subtle);
}
.evidence-source-card:hover { border-color: var(--line-hover); }
.evidence-source-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent2);
  font-size: 0.7rem;
  font-weight: 800;
}
.evidence-source-content { min-width: 0; }
.evidence-source-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.evidence-source-title-row strong {
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.35;
}
.evidence-source-badge {
  padding: 2px 6px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 999px;
  color: var(--accent2);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.3;
}
.evidence-source-content p {
  margin: 6px 0 2px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.evidence-source-content ul {
  margin: 0 0 7px 16px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.45;
}
.evidence-source-link {
  color: var(--accent2);
  font-size: 0.7rem;
  font-weight: 700;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 100vw) !important;
    min-width: min(var(--sidebar-w), 100vw) !important;
    max-width: 100vw !important;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0,0,0,0.5);
  }
  .app-shell.sidebar-collapsed .sidebar {
    width: min(var(--sidebar-w), 100vw) !important;
    min-width: min(var(--sidebar-w), 100vw) !important;
    max-width: 100vw !important;
    border-right-color: var(--line);
  }
  .hamburger { display: block; }
  .detail-panel { width: 100%; }
}

/* ========== TRANSMISSION ROUTE LABELS ========== */
.route-endpoint {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.route-endpoint span {
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text-secondary);
  line-height: 1;
}
.route-endpoint:hover {
  transform: scale(1.3);
}
.route-label-icon {
  pointer-events: none;
}
.route-label {
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  letter-spacing: -0.01em;
  transform: translate(-50%, -50%);
  position: relative;
  pointer-events: none;
}
.route-tooltip {
  background: var(--bg-deep) !important;
  color: var(--text) !important;
  border: 1px solid var(--line-hover) !important;
  border-radius: 8px !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  padding: 4px 10px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}
.route-tooltip::before {
  border-top-color: var(--line-hover) !important;
}

/* ========== SERPAPI BADGE ========== */
.serpapi-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.15);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent2);
  letter-spacing: 0.02em;
}
.serpapi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 6px var(--accent2);
  animation: serpapiPulse 2s ease-in-out infinite;
}
@keyframes serpapiPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ========== LEAFLET OVERRIDES ========== */
.leaflet-control-zoom a {
  background: var(--bg-deep) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.leaflet-control-zoom a:hover {
  background: var(--bg-input) !important;
}
.leaflet-control-zoom-in { border-radius: 10px 10px 0 0 !important; }
.leaflet-control-zoom-out { border-radius: 0 0 10px 10px !important; }
.leaflet-control-zoom { border: none !important; border-radius: 10px !important; overflow: hidden; }

.leaflet-control-attribution {
  background: var(--bg-card) !important;
  color: var(--muted) !important;
  font-size: 0.65rem !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: var(--accent2) !important; }

/* Keep the Nearby search radius visible above busy transmission routes. */
.nearby-radius-circle {
  filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.9));
  stroke-linecap: round;
}
.nearby-location-marker {
  filter: drop-shadow(0 0 7px rgba(34, 211, 238, 1));
}
[data-theme="light"] .nearby-radius-circle {
  filter: drop-shadow(0 0 4px rgba(8, 145, 178, 0.72));
}

/* ========== SELECTION / FOCUS ========== */
::selection {
  background: rgba(124, 58, 237, 0.3);
  color: white;
}

:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* ========== LIGHT THEME FULL OVERRIDES ========== */
[data-theme="light"] .chip.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(8, 145, 178, 0.1));
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}
[data-theme="light"] .topic-chip.active {
  background: rgba(220, 38, 38, 0.08);
  border-color: var(--red);
  color: var(--red);
}
[data-theme="light"] .chip:hover {
  border-color: var(--line-hover);
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .project-item:hover,
[data-theme="light"] .nearby-item:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--line-hover);
}
[data-theme="light"] .status-badge { box-shadow: none; }
[data-theme="light"] .project-item-bottom { border-color: var(--line); }
[data-theme="light"] .chat-msg.user-msg .msg-body {
  color: white;
}
[data-theme="light"] .msg-avatar {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
[data-theme="light"] .detail-tab.active {
  color: white;
}
[data-theme="light"] .send-btn,
[data-theme="light"] .nearby-search-btn,
[data-theme="light"] .filter-apply {
  box-shadow: none;
}
[data-theme="light"] .map-glow { display: none; }
[data-theme="light"] .stat-bar { box-shadow: none; }
[data-theme="light"] .detail-panel .stat-bar {
  background: var(--bg-subtle);
}
[data-theme="light"] .project-item-score {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}
[data-theme="light"] .detail-big-stat {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
}
[data-theme="light"] .impact-detail-card .detail-big-value { text-shadow: none; }
[data-theme="light"] .sources-list { background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
[data-theme="light"] .detail-tab-panel { color: var(--text); }
[data-theme="light"] .impact-overview-grid .impact-grid-cell { border-color: var(--line); }
[data-theme="light"] .env-bar-fill { opacity: 0.85; }
[data-theme="light"] .detail-spec-row { border-color: var(--line); }
[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 60% 50% at 10% 90%, rgba(124, 58, 237, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 90% 10%, rgba(8, 145, 178, 0.03) 0%, transparent 60%);
}

/* ============================================================
   VISUAL POLISH
   ============================================================ */

/* Global scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.18);
  border-radius: 9px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Sidebar nav as a segmented pill row */
.sidebar-nav {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.nav-btn {
  flex: none;
  width: 100%;
  min-width: 0;
  border-radius: 11px;
  border-bottom: none;
  padding: 9px 5px;
  font-size: 0.75rem;
  line-height: 1.1;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.nav-btn:nth-child(-n + 4) { grid-column: span 3; }
.nav-btn:nth-child(n + 5) { grid-column: span 4; }
.nav-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.nav-btn.active {
  color: var(--text);
  border-bottom: none;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(34, 211, 238, 0.08));
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.18), 0 6px 16px -8px rgba(124, 58, 237, 0.55);
}
.nav-btn.active::after { display: none; }
.nav-icon { flex-shrink: 0; font-size: 0.95rem; }
[data-theme="light"] .nav-btn.active {
  color: var(--accent);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(8, 145, 178, 0.06));
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.15);
}

/* Top bar: glassy gradient + iconized stat pills */
.top-bar {
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-card) 130%) !important;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(34, 211, 238, 0.05), 0 14px 28px -20px rgba(0, 0, 0, 0.65);
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.stat-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px currentColor;
  opacity: 0.9;
  flex-shrink: 0;
}
.stat-pill.accent::before { background: var(--accent2); }
.stat-pill.green::before { background: var(--green); }

/* Map depth: vignette edges + tuned basemap tiles */
.map-container { position: relative; }
.map-container .leaflet-tile {
  filter: invert(1) hue-rotate(180deg) brightness(0.72) saturate(0.72) contrast(1.08);
}
[data-theme="light"] .map-container .leaflet-tile {
  filter: saturate(0.88) contrast(1.02);
}
.map-container::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 410;
  pointer-events: none;
  background:
    radial-gradient(ellipse 85% 75% at 50% 45%, transparent 62%, rgba(3, 7, 18, 0.28) 100%),
    linear-gradient(180deg, rgba(3, 7, 18, 0.1) 0%, transparent 10%);
}
[data-theme="light"] .map-container::after {
  background:
    radial-gradient(ellipse 85% 75% at 50% 45%, transparent 62%, rgba(148, 163, 184, 0.18) 100%);
}

/* Leaflet legend / scale / zoom controls */
.leaflet-control-legend {
  background: var(--bg-deep) !important;
  border: 1px solid var(--line) !important;
  border-radius: 14px !important;
  padding: 12px 14px !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(34, 211, 238, 0.04);
  font-size: 0.75rem;
  min-width: 148px;
}
.legend-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 9px;
  padding-bottom: 8px;
}
.legend-title {
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.legend-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 0.75;
  padding: 0;
}
.legend-close:hover,
.legend-close:focus-visible {
  color: var(--text-primary);
}
.legend-close:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 3px;
}
.leaflet-control-legend-toggle {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-deep);
  color: var(--text-secondary);
  cursor: pointer;
  font: 700 0.72rem/1 Inter, sans-serif;
  letter-spacing: 0.02em;
  padding: 8px 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}
.leaflet-control-legend-toggle:hover,
.leaflet-control-legend-toggle:focus-visible {
  border-color: var(--accent2);
  color: var(--text);
}
.leaflet-control-legend-toggle:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 3px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3.5px 0;
}
.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
  flex-shrink: 0;
}
.legend-label {
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}
.leaflet-control-scale {
  background: var(--bg-deep) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  padding: 3px 8px !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.leaflet-control-scale-line {
  background: transparent !important;
  border-color: var(--muted) !important;
  color: var(--muted) !important;
  font-size: 0.66rem !important;
  font-weight: 600;
  border-width: 1px !important;
  padding: 1px 6px !important;
}

/* Popup polish */
.gridhalo-popup .leaflet-popup-content-wrapper {
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.65), 0 0 50px rgba(34, 211, 238, 0.07);
}
.popup-card {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.6) 0%, transparent 40%);
}
[data-theme="light"] .popup-card { background: transparent; }

/* Buttons: tactile active state */
.chip:active,
.search-input:active,
.dropdown-control:active { transform: scale(0.99); }
.chip.active { color: white; }
[data-theme="light"] .chip.active { color: var(--accent); }

/* Transmission route endpoints */
.route-endpoint:hover {
  box-shadow: 0 0 14px currentColor;
}

/* ========== PROJECT ALERTS ========== */
.alerts-summary {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 15px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(34, 211, 238, 0.08));
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.alerts-summary strong { color: var(--text); font-size: 0.9rem; }
.alerts-empty-icon { color: var(--accent2); font-size: 1.35rem; margin-bottom: 2px; }
.alerts-list { display: flex; flex-direction: column; gap: 9px; }
.alerts-loading { color: var(--muted); text-align: center; padding: 24px 0; font-size: 0.82rem; }
.followed-project-hub {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-subtle);
}
.watch-project-header {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 38px 11px 12px;
  border-bottom: 1px solid var(--line);
}
.watch-project-header .followed-project-dot { margin-top: 5px; flex: 0 0 8px; }
.watch-project-header .status-badge {
  flex: 0 0 auto;
  max-width: 105px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-project-heading { min-width: 0; flex: 1; }
.followed-project-open {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.followed-project-open:hover { color: var(--accent2); }
.watch-project-heading > span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-section-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.watch-latest-update {
  margin: 11px 12px;
  padding: 10px;
  border-left: 3px solid var(--accent2);
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.06);
}
.watch-latest-update > strong { color: var(--accent2); font-size: 0.72rem; }
.watch-latest-update p {
  margin: 3px 0 5px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.4;
}
.watch-latest-update a,
.watch-action a,
.watch-update-row a {
  color: var(--accent2);
  font-size: 0.66rem;
  font-weight: 700;
}
.watch-actions { padding: 0 12px 11px; }
.watch-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent2);
  border-radius: 8px;
  background: var(--bg-input);
}
.watch-action.soon { border-left-color: var(--amber); }
.watch-action.urgent { border-left-color: var(--red); }
.watch-action strong { display: block; color: var(--text); font-size: 0.72rem; }
.watch-action span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.65rem; }
.watch-none { margin: 0; color: var(--muted); font-size: 0.7rem; line-height: 1.45; }
.watch-details { border-top: 1px solid var(--line); }
.watch-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}
.watch-details summary::-webkit-details-marker { display: none; }
.watch-details summary::before { content: '\25B8'; color: var(--accent2); }
.watch-details[open] summary::before { content: '\25BE'; }
.watch-details summary span {
  min-width: 22px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.1);
  color: var(--accent2);
  font-size: 0.62rem;
  text-align: center;
}
.watch-details[open] summary { background: var(--bg-hover); color: var(--text); }
.watch-update-list,
.watch-learning-list { padding: 4px 12px 12px; }
.watch-update-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.watch-update-row:last-child { border-bottom: 0; }
.watch-update-row time { color: var(--accent2); font-size: 0.66rem; font-weight: 800; }
.watch-update-row strong { display: block; color: var(--text-secondary); font-size: 0.7rem; line-height: 1.35; }
.watch-update-row span { display: block; margin: 2px 0; color: var(--muted); font-size: 0.63rem; }
.watch-learning-list { display: flex; flex-direction: column; gap: 7px; }
.watch-learning-link {
  display: block;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-input);
  text-decoration: none;
}
.watch-learning-link:hover { border-color: var(--accent2); background: rgba(34, 211, 238, 0.06); }
.watch-learning-link strong { display: block; color: var(--text); font-size: 0.71rem; line-height: 1.35; }
.watch-learning-link span { display: block; margin: 2px 0; color: var(--accent2); font-size: 0.61rem; font-weight: 700; }
.watch-learning-link small { display: block; color: var(--muted); font-size: 0.65rem; line-height: 1.4; }
.followed-projects-block {
  margin-bottom: 12px;
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-subtle);
}
.followed-projects-header {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.followed-projects-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.followed-project {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.followed-project:hover {
  border-color: var(--accent2);
  background: rgba(34, 211, 238, 0.08);
}
.followed-project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}
.followed-project-name {
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.alert-card {
  position: relative;
  display: flex;
  gap: 11px;
  padding: 12px 34px 12px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent2);
  border-radius: 13px;
  background: var(--bg-subtle);
}
.alert-card.soon { border-left-color: var(--amber); }
.alert-card.urgent { border-left-color: var(--red); background: rgba(248, 113, 113, 0.06); }
.alert-date {
  min-width: 68px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  font-size: 0.71rem;
  line-height: 1.25;
}
.alert-date strong { font-size: 0.76rem; }
.alert-date span { color: var(--muted); }
.urgent .alert-date span { color: var(--red); font-weight: 700; }
.alert-body { display: flex; flex-direction: column; min-width: 0; gap: 4px; }
.alert-event { color: var(--accent2); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.alert-project {
  color: var(--text);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
}
.alert-project:hover { color: var(--accent2); }
.alert-meta { color: var(--muted); font-size: 0.69rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-unfollow {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 18px;
  cursor: pointer;
}
.alert-unfollow:hover { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.alerts-note { margin-top: auto; color: var(--muted); font-size: 0.69rem; line-height: 1.55; }

.detail-watch-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin: 14px 0 5px;
}
.watch-project-btn {
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: 9px;
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent2);
  padding: 8px 11px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}
.watch-project-btn:hover { background: rgba(34, 211, 238, 0.16); }
.watch-project-btn.watching { color: var(--green); border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.1); }
.watch-project-help { color: var(--muted); font-size: 0.69rem; }

/* Keep the map and project cards readable on phones. */
@media (max-width: 700px) {
  .leaflet-control-legend { display: none; }

  .top-bar {
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
  }
  .hamburger {
    margin-top: 19px;
    padding: 6px 10px;
  }
  .top-bar-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1;
    gap: 5px;
  }
  .stat-pill {
    justify-content: flex-start;
    min-width: 0;
    padding: 5px 8px;
    border-radius: 10px;
    font-size: 0.63rem;
    line-height: 1.25;
  }
  .stat-pill:first-child { grid-column: 1 / -1; }
  .stat-pill::before { width: 6px; height: 6px; }

  .detail-panel { padding: 18px; }
  .detail-tabs { margin-bottom: 14px; }
  .detail-tab { font-size: 0.68rem; padding: 8px 2px; }

  .gridhalo-popup .leaflet-popup-content {
    width: auto !important;
    max-width: calc(100vw - 48px);
  }
  .popup-card {
    width: min(300px, calc(100vw - 56px));
    min-width: 0;
    padding: 14px;
  }
  .popup-header { margin-bottom: 7px; }
  .popup-title { font-size: 0.98rem; }
  .popup-state { margin-bottom: 8px; font-size: 0.75rem; }
  .popup-watts { margin-bottom: 7px; }
  .popup-watts-value { font-size: 1.35rem; }
  .popup-summary {
    display: -webkit-box;
    overflow: hidden;
    margin-bottom: 9px;
    font-size: 0.75rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }
  .popup-score-row { margin-bottom: 9px; padding: 8px 10px; }
  .popup-detail-btn { padding: 9px; font-size: 0.78rem; }
}
