/* ==========================================================================
   SolGrid Thermal Sync — Apple Frosted Glass (Glassmorphism) Design System
   ========================================================================== */

:root {
  /* Surface & Glass Tokens */
  --bg-app: #070B14;
  --bg-radial: radial-gradient(circle at 10% 15%, #162032 0%, #070B14 75%);
  
  --glass-panel: rgba(15, 23, 42, 0.65);
  --glass-card: rgba(15, 23, 42, 0.65);
  --glass-inner: rgba(255, 255, 255, 0.035);
  --glass-inner-hover: rgba(255, 255, 255, 0.065);
  --glass-border: 1px solid rgba(255, 255, 255, 0.12);
  --glass-border-subtle: 1px solid rgba(255, 255, 255, 0.08);
  
  --glass-filter: blur(20px) saturate(180%);
  --glass-filter-heavy: blur(28px) saturate(190%);
  --glass-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  --glass-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  --glass-shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.25);

  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-dim: #475569;

  /* Severity Color Palette & Ambient Glows */
  --emerald: #10B981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.32);
  --emerald-glow: 0 0 14px rgba(16, 185, 129, 0.3);

  --amber: #F59E0B;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.32);
  --amber-glow: 0 0 14px rgba(245, 158, 11, 0.3);

  --crimson: #EF4444;
  --crimson-bg: rgba(239, 68, 68, 0.12);
  --crimson-border: rgba(239, 68, 68, 0.32);
  --crimson-glow: 0 0 14px rgba(239, 68, 68, 0.3);

  --brand-orange: #F97316;
  --brand-orange-bg: rgba(249, 115, 22, 0.12);
  --brand-orange-border: rgba(249, 115, 22, 0.35);
  --brand-orange-glow: 0 0 16px rgba(249, 115, 22, 0.35);

  /* Geometry & Curves */
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-full: 9999px;

  /* Animation & Micro-Interactions */
  --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: all 0.3s var(--ease-apple);
  --transition-fast: all 0.15s var(--ease-apple);
}

/* ==========================================================================
   CSS Reset & Base
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-system);
  background-color: var(--bg-app);
  background-image: var(--bg-radial);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Navbar / Header (Frosted Glass with Gradient)
   ========================================================================== */
.navbar {
  height: 64px;
  min-height: 64px;
  background: linear-gradient(135deg, #0a0e1a 0%, #111827 100%);
  border-bottom: 1px solid rgba(249, 115, 22, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 50;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-orange-bg);
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-orange-border);
  box-shadow: var(--brand-orange-glow);
}

.logo-text-group {
  display: flex;
  flex-direction: column;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.logo-sub {
  color: var(--brand-orange);
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: normal;
}

.logo-tagline {
  font-size: 10px;
  color: #6b7280;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.navbar-right,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#refresh-btn,
.btn-refresh {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 6px 14px;
  color: #f3f4f6;
  font-family: var(--font-system);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

#refresh-btn:hover,
.btn-refresh:hover {
  background: rgba(249, 115, 22, 0.15);
  border-color: #f97316;
  color: #ffffff;
}

#refresh-btn:active,
.btn-refresh:active {
  transform: translateY(0);
}

#refresh-btn.loading,
.btn-refresh.loading {
  opacity: 0.75;
  cursor: not-allowed;
}

#refresh-btn.loading .refresh-icon,
.btn-refresh.loading .refresh-icon {
  animation: spin 1s infinite linear;
}

.badge-tag {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-orange);
  background: var(--brand-orange-bg);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--brand-orange-border);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.15);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}

/* ==========================================================================
   Main Dashboard Layout (Floating Glass Panels)
   ========================================================================== */
.dashboard-layout {
  display: flex;
  height: calc(100vh - 64px);
  width: 100%;
  padding: 16px;
  gap: 16px;
  overflow: hidden;
}

/* Left Panel: Mapbox Container */
.map-panel {
  flex: 0 0 42%;
  height: 100%;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background-color: #070B14;
  background-image: 
    linear-gradient(rgba(31,41,55,0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,41,55,0.3) 1px, transparent 1px);
  background-size: 40px 40px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

/* Ensure map container has relative positioning so absolute works correctly */
#map,
.map-container,
.map-panel {
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background-color: transparent;
  background-image: 
    linear-gradient(rgba(31,41,55,0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,41,55,0.3) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Map Controls */
.map-controls {
  position: absolute !important;
  top: 12px !important;
  right: 56px !important;
  z-index: 20 !important;
}

.map-style-btn, 
#style-toggle,
#satellite-btn,
.map-style-toggle,
button[onclick*="toggleSatellite"],
button[onclick*="toggleStyle"] {
  position: absolute !important;
  top: 12px !important;
  right: 56px !important; /* Shifted left to clear the + / - zoom control box */
  z-index: 20 !important;
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 6px !important;
  color: #f8fafc !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  white-space: nowrap !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.map-style-btn:hover, 
#style-toggle:hover,
#satellite-btn:hover,
.map-style-toggle:hover,
button[onclick*="toggleSatellite"]:hover,
button[onclick*="toggleStyle"]:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  border-color: #f97316 !important;
  color: #f97316 !important;
}

/* Mapbox Navigation Controls */
.mapboxgl-ctrl-top-right {
  top: 10px !important;
  right: 10px !important;
}

.mapboxgl-ctrl-group {
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
  overflow: hidden;
}

.mapboxgl-ctrl-group button {
  width: 29px !important;
  height: 29px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  background-color: transparent !important;
}

.mapboxgl-ctrl-group button:last-child {
  border-bottom: none !important;
}

.mapboxgl-ctrl-group button:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.mapboxgl-ctrl-group button .mapboxgl-ctrl-icon {
  filter: invert(1) brightness(0.85);
}

/* Mapbox Attribution styling */
.mapboxgl-ctrl-attrib {
  padding: 2px 6px !important;
  background-color: rgba(15, 23, 42, 0.7) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
  font-size: 9px !important;
  border-radius: 4px !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.mapboxgl-ctrl-attrib a {
  color: #64748b !important;
  text-decoration: none !important;
}

.mapboxgl-ctrl-attrib a:hover {
  color: #94a3b8 !important;
  text-decoration: underline !important;
}

.mapboxgl-ctrl-bottom-right {
  bottom: 8px !important;
  right: 8px !important;
}

/* Map Legend Overlay */
#thermal-legend,
.map-overlay-legend,
.legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.legend-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.08em;
}

.legend-gradient {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #41b6c4, #7fcb7b, #c7e9b4, #ffeda0, #fd8d3c, #e31a1c);
  margin: 6px 0 4px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 8.5px;
  color: #9ca3af;
  font-weight: 500;
  margin-bottom: 4px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.red {
  background-color: var(--crimson);
  box-shadow: var(--crimson-glow);
}
.dot.amber {
  background-color: var(--amber);
  box-shadow: var(--amber-glow);
}
.dot.green {
  background-color: var(--emerald);
  box-shadow: var(--emerald-glow);
}

/* ==========================================================================
   Marker Styling (24px circles)
   ========================================================================== */
.custom-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-sizing: border-box;
  cursor: pointer;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 0 10px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

.custom-marker:hover {
  transform: scale(1.3);
  z-index: 25;
}

.custom-marker.active-marker {
  transform: scale(1.3);
  border-color: #FFFFFF !important;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.95), 0 0 18px var(--brand-orange) !important;
  z-index: 30;
}

.custom-marker.marker-pulse-high {
  animation: pulse-risk 2s infinite;
}

/* Mapbox Hover Popup Styling */
.mapboxgl-popup.solar-hover-popup {
  z-index: 40;
  pointer-events: none;
}
.mapboxgl-popup.solar-hover-popup .mapboxgl-popup-content {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
}
.mapboxgl-popup.solar-hover-popup .mapboxgl-popup-tip {
  border-top-color: #0f172a;
  border-bottom-color: #0f172a;
}

/* ==========================================================================
   Right Panel: Scrollable Controls & Cards
   ========================================================================== */
.controls-panel {
  flex: 1 1 58%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Apple Sleek Scrollbar */
.controls-panel::-webkit-scrollbar {
  width: 6px;
}
.controls-panel::-webkit-scrollbar-track {
  background: transparent;
}
.controls-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
}
.controls-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   Darker Cards (High Contrast #0f172a)
   ========================================================================== */
.card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 16px rgba(249, 115, 22, 0.08);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.card-subtitle {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
}

/* Section Headers Left Border Accent */
.section-accent-header,
.loss-card .card-subtitle,
.simulator-card .card-title,
.forecast-card .card-title,
.roi-card .card-title {
  border-left: 3px solid #f97316;
  padding-left: 10px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.building-address {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.card-description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
}

/* Badges with Severity Glow */
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

@keyframes pulse-risk {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.risk-badge.high {
  background: var(--crimson-bg);
  color: var(--crimson);
  border: 1px solid var(--crimson-border);
  animation: pulse-risk 2s infinite;
}

.risk-badge.mid {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  box-shadow: var(--amber-glow);
}

.risk-badge.low {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  box-shadow: var(--emerald-glow);
}

.info-badge {
  background: var(--brand-orange-bg);
  color: var(--brand-orange);
  border: 1px solid var(--brand-orange-border);
  box-shadow: var(--brand-orange-glow);
}

.asset-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
  font-size: 0.68rem;
  padding: 3px 10px;
  text-transform: none;
  font-weight: 600;
}

/* ==========================================================================
   1. Building Card Grid
   ========================================================================== */
.building-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.85rem;
  background: var(--glass-inner);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  border: var(--glass-border-subtle);
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 3px;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   2. Loss Card
   ========================================================================== */
.loss-metrics-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.big-loss-metric {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.big-number {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.05;
  margin: 6px 0 2px 0;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: #ef4444;
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.35);
}

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

.loss-countup {
  animation: countup 0.5s ease;
}

.annual-loss-text {
  font-size: 15px;
  color: #ef4444;
  font-weight: 700;
  margin-top: 5px;
  letter-spacing: 0.01em;
  text-shadow: 0 0 18px rgba(239, 68, 68, 0.5), 0 0 32px rgba(239, 68, 68, 0.25);
}

.red-text, .danger-text {
  color: var(--crimson);
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

.green-text, .success-text {
  color: var(--emerald);
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

.metric-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.secondary-loss-metrics {
  display: flex;
  gap: 0.85rem;
}

.stat-box {
  background: var(--glass-inner);
  border: var(--glass-border-subtle);
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 140px;
  transition: var(--transition-smooth);
}

.stat-box:hover {
  background: var(--glass-inner-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-subtext {
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 500;
  margin-top: 3px;
  white-space: nowrap;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   3. Simulator Sliders & Results
   ========================================================================== */
.sliders-container {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.slider-value {
  color: var(--brand-orange);
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--brand-orange-bg);
  border: 1px solid var(--brand-orange-border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.slider-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Apple Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  outline: none;
  margin: 6px 0;
  transition: var(--transition-fast);
}

input[type="range"]:hover {
  background: rgba(255, 255, 255, 0.16);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--brand-orange);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 10px rgba(249, 115, 22, 0.4);
  transition: transform 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), 0 0 16px rgba(249, 115, 22, 0.6);
}

/* Simulation Results / What-If Before vs After Comparison Grid */
.sim-compare-container {
  background: var(--glass-inner);
  border: var(--glass-border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sim-compare-header {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.compare-heading {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compare-heading.before-head {
  color: #F87171;
}

.compare-heading.after-head {
  color: #34D399;
}

.sim-compare-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.compare-row {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: center;
  gap: 0.5rem;
}

.compare-col {
  display: flex;
  flex-direction: column;
}

.compare-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compare-value {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.text-muted-red {
  color: #EF4444;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.25);
}

.text-green {
  color: #10B981;
  text-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
}

.compare-arrow {
  color: var(--text-muted);
  font-size: 1.15rem;
  text-align: center;
  font-weight: 700;
}

.compare-val-wrapper {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.compare-delta {
  font-size: 0.75rem;
  font-weight: 700;
}

.delta-green {
  color: #34D399;
}

/* Payback Grid */
.payback-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.payback-item {
  background: var(--glass-inner);
  border: var(--glass-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
}

.payback-item:hover {
  background: var(--glass-inner-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.p-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.p-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   4. Forecast Chart Card
   ========================================================================== */
#forecast-chart,
.chart-container {
  width: 100%;
  height: 220px;
}

/* ==========================================================================
   5. ROI Portfolio Allocation List
   ========================================================================== */
.roi-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.roi-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass-inner);
  border: var(--glass-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  transition: var(--transition-smooth);
}

.roi-item:hover {
  background: var(--glass-inner-hover);
  border-color: var(--brand-orange-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.roi-left {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}

.roi-rank {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--brand-orange);
  background: var(--brand-orange-bg);
  border: 1px solid var(--brand-orange-border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.roi-info {
  display: flex;
  flex-direction: column;
}

.roi-bname {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.roi-itype {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: capitalize;
  margin-top: 1px;
}

.roi-right {
  display: flex;
  align-items: center;
  gap: 1.35rem;
}

.roi-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.roi-stat-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.roi-stat-val {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.text-primary {
  color: var(--text-primary);
}

.loading-spinner {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 1.5rem;
  text-align: center;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1024px) {
  .dashboard-layout {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }
  .map-panel {
    flex: none;
    height: 420px;
    width: 100%;
  }
  .controls-panel {
    flex: none;
    width: 100%;
    overflow-y: visible;
  }
  .building-details-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Live Data Banner, Refresh Button & Badges (FIX 3, FIX 4, FIX 5)
   ========================================================================== */
.card-subtitle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.live-badge {
  background: var(--emerald-bg) !important;
  color: var(--emerald) !important;
  border: 1px solid var(--emerald-border) !important;
  box-shadow: var(--emerald-glow) !important;
  font-size: 0.68rem;
  padding: 2px 8px;
  text-transform: none;
}

.live-data-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(15, 23, 42, 0.75) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.2), inset 0 0 15px rgba(16, 185, 129, 0.05);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: var(--transition-smooth);
}

.live-data-banner.hidden {
  display: none;
}

.live-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
  animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.live-indicator-dot {
  width: 10px;
  height: 10px;
  background-color: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--emerald);
  animation: pulseLive 2s infinite ease-in-out;
}

@keyframes pulseLive {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 10px var(--emerald);
  }
  50% {
    transform: scale(1.3);
    opacity: 0.75;
    box-shadow: 0 0 18px var(--emerald);
  }
}

.live-banner-title {
  display: flex;
  flex-direction: column;
}

.live-banner-title strong {
  font-size: 0.85rem;
  color: var(--emerald);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
}

.live-banner-meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.live-banner-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-stat-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.live-stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.live-stat-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}



.badge-tag.live-active {
  background: var(--emerald-bg) !important;
  color: var(--emerald) !important;
  border-color: var(--emerald-border) !important;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.25) !important;
}

/* ==========================================================================
   AI Thermal Advisor Section
   ========================================================================== */
.ai-powered-badge {
  font-size: 10px;
  color: #4b5563;
  margin-bottom: 8px;
}
#ai-btn {
  width: 100%;
  padding: 12px;
  background: #0f172a;
  border: 1px solid #f97316;
  border-radius: 8px;
  color: #f97316;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 10px;
}
#ai-btn:hover {
  background: #f97316;
  color: #0a0e1a;
}
.ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ai-badge {
  background: #f97316;
  color: white;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
}
.ai-model {
  font-size: 10px;
  color: #4b5563;
}
#ai-output,
.ai-text {
  max-height: 420px;
  overflow-y: auto !important;
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
  padding: 12px;
  padding-right: 12px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12.5px;
  color: #d1d5db;
  margin-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: #f97316 rgba(255, 255, 255, 0.05);
}

#ai-output strong,
.ai-text strong {
  color: #f97316; /* SolGrid Orange accent for bold headers */
  font-weight: 700;
}

#ai-output table,
.ai-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

#ai-output th,
.ai-text th {
  background: rgba(255, 255, 255, 0.05);
  color: #f97316;
  font-weight: 600;
  text-align: left;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11.5px;
}

#ai-output td,
.ai-text td {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: #d1d5db;
}

#ai-output table::-webkit-scrollbar,
.ai-text table::-webkit-scrollbar {
  height: 4px;
}

#ai-output table::-webkit-scrollbar-track,
.ai-text table::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

#ai-output table::-webkit-scrollbar-thumb,
.ai-text table::-webkit-scrollbar-thumb {
  background: #f97316;
  border-radius: 2px;
}

#ai-output ul,
.ai-text ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

#ai-output ol,
.ai-text ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

#ai-output li,
.ai-text li {
  margin-bottom: 6px;
}

#ai-output p,
.ai-text p {
  margin-bottom: 10px;
}

#ai-output p:last-child,
.ai-text p:last-child {
  margin-bottom: 0;
}

#ai-output hr,
.ai-text hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 16px 0;
}

#ai-output h1, #ai-output h2, #ai-output h3, #ai-output h4,
.ai-text h1, .ai-text h2, .ai-text h3, .ai-text h4 {
  color: #f97316;
  margin-top: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

/* Custom styled scrollbar for dark mode theme */
#ai-output::-webkit-scrollbar,
.ai-text::-webkit-scrollbar {
  width: 6px;
}

#ai-output::-webkit-scrollbar-track,
.ai-text::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

#ai-output::-webkit-scrollbar-thumb,
.ai-text::-webkit-scrollbar-thumb {
  background: #f97316; /* SolGrid Orange */
  border-radius: 4px;
}
.ai-refresh {
  font-size: 11px;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.ai-refresh:hover { color: #f97316; }
.ai-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #1f2937;
  border-top-color: #f97316;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Panel Footer
   ========================================================================== */
.panel-footer {
  font-size: 11px;
  color: #4b5563;
  text-align: center;
  padding: 16px;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.5;
}

