/* ---------- THEME ----------
   Single source of truth for the app's palette (shared with calibrate.css,
   which loads this file too). Change a value here to reskin both pages.
   *-rgb companions exist so rgba()/tint effects stay themeable — CSS can't
   pull the components back out of a hex color, so we keep both forms. */
:root {
  /* Brand accents */
  --color-primary: #E5A833;
  --color-primary-rgb: 229, 168, 51;
  --color-secondary: #38bdf8;
  --color-secondary-rgb: 56, 189, 248;
  --color-danger: #f87171;
  --color-danger-rgb: 248, 113, 113;
  --color-warning: #fbbf24;

  /* Sidebar gauge/stat-row accent — kept separate from --color-secondary
     (used throughout calibrate.css for the admin selection highlight) so
     this doesn't change that page's colors too. */
  --color-neon: #22e0ff;
  --color-neon-rgb: 34, 224, 255;

  /* Dot on the "Live Generation" pill over the panel view. */
  --color-live-dot: #ef4444;

  /* Light, semi-transparent backing behind the Besolar/site logo
     lockup */
  --color-brand-panel-rgb: 15, 23, 42;
  --color-brand-panel: rgba(var(--color-brand-panel-rgb), 0.62);

  /* Surfaces (dark navy scale, darkest to lightest) */
  --color-bg: #020617;
  --color-surface: #0f172a;
  --color-surface-rgb: 15, 23, 42;
  --color-surface-alt: oklch(0.16 0.04 266.37);
  --color-surface-card: oklch(0.22 0.04 265.46);

  /* Borders */
  --color-border: #1e293b;
  --color-border-rgb: 30, 41, 59;

  /* Text */
  --color-text: #e2e8f0;
  --color-text-bright: #ffffff;
  --color-text-muted: #94a3b8;
  --color-text-muted-rgb: 148, 163, 184;
  --color-text-dim: #64748b;
  --color-text-dim-rgb: 100, 116, 139;

  /* Shared shadow */
  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- GLOBAL ---------- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

/* ---------- SETTINGS PANEL ---------- */
.settings-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.settings-panel {
  display: none;
  position: absolute;
  top: 46px;
  right: 0; /* opens leftward, into the stats column, since the trigger sits at its right edge */
  min-width: 240px;
  background: var(--color-surface-card);
  border: 1px solid rgba(var(--color-text-dim-rgb), 0.4);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-card);
  z-index: 100;
}

.settings-wrapper.open .settings-panel {
  display: block;
}

.settings-panel-title {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 0.95rem;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
}

.settings-row:hover {
  color: var(--color-primary);
}

.settings-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.settings-row input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.settings-divider {
  border: none;
  border-top: 1px solid rgba(var(--color-text-dim-rgb), 0.4);
  margin: 4px 0;
}

/* ---------- LOCKUP (sidebar header — site name + Besolar) ---------- */
.lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}
.lockup img {
  height: 40px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(var(--color-neon-rgb), 0.45));
}
.lockup-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  font-family: 'Manrope', Arial, sans-serif;
}
.lockup-brand {
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
  color: var(--color-text-bright);
}
.lockup-tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-top: 3px;
}

/* ---------- GAUGE ---------- */
.gauge-module {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: 'Manrope', Arial, sans-serif;
}
.gauge-eyebrow {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}
.gauge-svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
  margin-top: 6px;
}
.gauge-readout {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: -34px;
}
.gauge-value {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 2.3rem;
  color: var(--color-text-bright);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(var(--color-neon-rgb), 0.3);
}
/* ---------- ENVIRONMENTAL IMPACT SECTION ---------- */
.section-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Manrope', Arial, sans-serif;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: center;
}

/* Cards, stacked one on top of the other. Each card is two sections side
   by side: a darker icon panel (full height, icon centered) on the left,
   then the title on top and the big value + unit word below —
   left-justified on the right. */
.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: 'Manrope', Arial, sans-serif;
}
.stat-row {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--color-surface-card);
  border: 1px solid rgba(var(--color-text-dim-rgb), 0.4);
  border-radius: 16px;
}
/* Traveling neon "comet" traced around each row's outline, added by
   statCards.js (needs measured pixel geometry via getTotalLength, so it
   isn't pure CSS). Absolutely positioned + pointer-events:none so it never
   affects row layout. */
.row-trace {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.row-trace path {
  fill: none;
  stroke: var(--color-neon);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 4px rgba(var(--color-neon-rgb), 0.8));
}
.row-icon-panel {
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border-right: 1px solid rgba(var(--color-neon-rgb), 0.6);
  box-shadow: 1px 0 6px rgba(var(--color-neon-rgb), 0.35);
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
}
.row-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  min-width: 0;
}
.stat-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-icon {
  width: 20px;
  height: 20px;
  color: var(--color-neon);
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(var(--color-neon-rgb), 0.5));
}
.row-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.row-value {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--color-text-bright);
  font-variant-numeric: tabular-nums;
}
.row-unit {
  font-family: 'Manrope', Arial, sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-neon);
  margin-left: 6px;
}

/* ---------- MAIN CONTENT ---------- */
.container {
  flex: 1 1 auto; /* fill remaining space */
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* PANEL VIEW (single-system SVG grid, replaces the old fleet map) — the
   dominant element now: 70% of the row width, vs .stats-column's 30%
   (flex-grow ratio 7:3 off a shared flex-basis of 0). Flush against the
   viewport edges (no border-radius, no container padding) for a more
   modern, edge-to-edge look. */
.panel-view {
  position: relative;
  flex: 7 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  border: 1px solid var(--color-border);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: var(--color-surface-alt);
}

/* Besolar + site logo, centered at the top of the panel view. */
.panel-view-brand-lockup {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 26px;
  background: var(--color-brand-panel);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}

.brand-logo {
  display: block;
  width: auto;
}

.brand-logo-besolar {
  height: 54px;
  /* The logo file has a "Powering Tomorrow" subtext baked into its bottom
     margin, which pulls the visible wordmark above center once the box
     itself is vertically centered — nudge down to compensate. */
  margin-top: 12px;
}

.brand-logo-site {
  height: 72px;
}

.brand-lockup-x {
  font-size: 1.2rem;
  font-weight: 300;
  color: var(--color-text-dim);
}

/* Subtle caption overlaid on the satellite image, bottom-left. */
.panel-view-caption {
  position: absolute;
  left: 20px;
  bottom: 16px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  font-size: 0.8rem;
  line-height: 1.5;
  pointer-events: none;
}

.panel-view-caption-line:first-child {
  font-weight: 600;
}

/* "Live Generation" pill, top-right of the panel view. */
.panel-view-live-badge {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-bright);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-card);
  pointer-events: none;
}

.panel-view-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-live-dot);
  flex-shrink: 0;
  animation: live-dot-breathe 2s ease-in-out infinite;
}

.panel-view-live-badge.is-offline .panel-view-live-dot {
  background: var(--color-text-dim);
  animation: none;
}

@keyframes live-dot-breathe {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

/* Slideshow layers (satellite view + gallery media) crossfade via opacity;
   only the .is-active layer is visible/interactive at a time. */
.panel-view-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease;
}

.panel-view-slide.is-active {
  opacity: 1;
  visibility: visible;
}

.panel-view-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.panel-view-live-badge.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel-grid-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.panel-cell {
  fill-opacity: 0.88;
  stroke: rgba(var(--color-surface-rgb), 0.6);
  stroke-width: 1;
  transition: fill 0.6s ease, filter 0.6s ease;
}

/* Invisible on the kiosk — only the spark/trail dots should read as
   visible "wiring", not the path itself. Still a real stroked/geometry
   element under the hood (opacity, not display:none), since the spark
   animation rides along it via getTotalLength()/createMotionPath(), which
   only care about the path's `d` geometry, not its visibility. */
.panel-string-path {
  fill: none;
  stroke: var(--color-surface-alt);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
}

.panel-string-spark {
  fill: var(--color-neon);
  filter: drop-shadow(0 0 3px rgba(var(--color-neon-rgb), 0.9)) drop-shadow(0 0 8px rgba(var(--color-neon-rgb), 0.6));
  pointer-events: none;
}

/* No filter/glow here, deliberately — these animate every frame (~30
   strings × 5 dots), and an SVG drop-shadow filter is expensive to
   repaint continuously; plain fill keeps them compositor-cheap. Only the
   lead .panel-string-spark dot gets the glow. */
.panel-string-spark-trail-dot {
  fill: var(--color-neon);
  pointer-events: none;
}

/* ---------- DONOR SPOTLIGHT (see donorSpotlight.js) ----------
   Its own slide in the panel-view slideshow (plain panels, no production
   colors or string sparks): gold overlay on one donor's panels at a time,
   plus a name card bottom-right. Brand gold (--color-primary) so it reads
   as distinct from the production view's blue/cyan. stroke-width is set
   per rect in JS (scaled to panel size). */
.panel-donor-highlight {
  fill: rgba(var(--color-primary-rgb), 0.22);
  stroke: var(--color-primary);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.panel-donor-highlight.is-spotlit {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(var(--color-primary-rgb), 0.85));
  animation: donor-pulse 2.4s ease-in-out infinite;
}

@keyframes donor-pulse {
  0%, 100% { fill-opacity: 1; stroke-opacity: 1; }
  50% { fill-opacity: 0.45; stroke-opacity: 0.7; }
}

/* Lives inside the donor slide (.panel-view-slide-donors), so it fades in
   and out with that slide on top of its own per-donor fade. */
.panel-view-donor-card {
  position: absolute;
  right: 20px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(420px, 45%);
  padding: 14px 20px 14px 16px;
  background: var(--color-brand-panel);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(var(--color-primary-rgb), 0.45);
  border-left: 4px solid var(--color-primary);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  font-family: 'Manrope', Arial, sans-serif;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.panel-view-donor-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.donor-card-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  fill: var(--color-primary);
  filter: drop-shadow(0 0 6px rgba(var(--color-primary-rgb), 0.6));
}

.donor-card-text {
  min-width: 0;
}

.donor-card-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.donor-card-name {
  margin-top: 2px;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-text-bright);
  /* Long names wrap to two lines max, then ellipsize. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.donor-card-detail {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .panel-donor-highlight.is-spotlit {
    animation: none;
  }
  .panel-view-donor-card {
    transform: none;
  }
}

.panel-view-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.8;
}

.panel-view-empty a {
  color: var(--color-primary);
}

/* ---------- STATS COLUMN (was .sidebar) ---------- */
.stats-column {
  flex: 3 1 0; /* 30% of the row width, vs .panel-view's 70% */
  min-width: 320px;
  margin: 0; /* flush top/bottom/right — fills the full screen height */
  background: var(--color-surface-alt);
  backdrop-filter: blur(10px);
  color: var(--color-text-bright);
  padding: 20px;
  border-radius: 0; /* the cards inside keep their own rounded corners */
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto; /* scrollable if content too tall */
  box-sizing: border-box;
}

/* Footer sticks to bottom */
.footer {
  font-size: 0.75rem;
  color: var(--color-text-dim);
  text-align: center;
  margin-top: auto;
}

/* ---------- STATS HEADER (reserved for future content) ---------- */
.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats-header-icon {
  width: 28px;
  height: 28px;
  display: block;
}

/* Sun-icon settings trigger, top-right of the stats header. Normally just
   the bare amber sun glyph; on hover it inverts — filled amber circle
   behind a white glyph — instead of the plain gear-button treatment. */
.stats-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.stats-settings-btn:hover {
  background: var(--color-primary);
  color: var(--color-text-bright);
}

.stats-settings-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

.stats-divider {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(var(--color-neon-rgb), 0.6);
  box-shadow: 0 0 6px rgba(var(--color-neon-rgb), 0.35);
  margin: 0; /* .stats-column's flex gap already provides spacing */
}

/* ---------- PRODUCTION PILL (cycles Today / This Week / Lifetime) ----------
   Own card, same family as the gauge/stat-row surfaces, with larger type
   than the rest of the sidebar so it reads from across a room. */
.production-pill {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border: 1px solid rgba(var(--color-text-dim-rgb), 0.4);
  border-radius: 16px;
  background: var(--color-surface-card);
  box-sizing: border-box;
}

.production-pill-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: opacity 0.4s ease;
  font-family: 'Manrope', Arial, sans-serif;
}

.production-pill-text.is-fading {
  opacity: 0;
}

.production-pill-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.production-pill-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--color-text-bright);
  font-variant-numeric: tabular-nums;
}

.production-pill-unit {
  font-family: 'Manrope', Arial, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-neon);
  margin-left: 6px;
}

.production-pill-divider {
  width: 48px;
  height: 4px;
  border: none;
  border-radius: 999px;
  background: var(--color-neon);
  box-shadow: 0 0 6px rgba(var(--color-neon-rgb), 0.6);
  margin: 6px 0;
}

.production-pill-caption {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
}
