/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   DESIGN TOKENS  (CSS custom properties)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ── Variables ──────────────────────────────────────────────── */
:root {
  --input-bg:       #ffffff;
  --input-text:     #111111;
  --calc-bg:        #ffffff;
  --charging-bg:    #d4edda;
  --charging-text:  #1a5e2a;
  --deficit-bg:     #fff3cd;
  --deficit-text:   #7d5a00;
  --overdod-bg:     #f8d7da;
  --overdod-text:   #7b1d24;
  --nosolar-bg:     #e9ecef;
  --nosolar-text:   #495057;
  --toppedoff-bg:   #d0f0e8;
  --toppedoff-text: #0d4f3c;
  --approaching-bg: #fde9c3;
  --approaching-text: #6b3d00;
  --border:         #b8cfe0;
  --border-light:   #dde8f0;
  --primary:        #1a6fa0;
  --primary-hover:  #145880;
  --text:           #1a1a1a;
  --text-muted:     #5a6a75;
  --bg-page:        #f4f7fa;
  --bg-panel:       #ffffff;
  --bg-fieldset:    #f9fbfd;
  --radius:         6px;
  --shadow:         0 1px 4px rgba(0,0,0,0.08);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LAYOUT  (reset, base, global structure)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-page);
}

/* ── Skip link ──────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}
.skip-link:focus { top: 0; }

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.array-type-hidden { display: none !important; }

/* ── Safety Banner (first-use modal) ───────────────────────── */
.safety-banner {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.safety-banner-inner {
  background: #fff;
  border-left: 5px solid #c0392b;
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.safety-banner-inner h2 {
  color: #c0392b;
  margin-bottom: 0.75rem;
}
.safety-banner-inner p {
  margin-bottom: 1.25rem;
  color: #333;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  background: var(--primary);
  color: #fff;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
}
.header-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}
.tagline {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.15rem;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.safety-persistent {
  background: #c0392b;
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  padding: 0.3rem 1rem;
}

/* ── Main layout ────────────────────────────────────────────── */
main {
  display: grid;
  grid-template-columns: minmax(380px, 440px) 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   COMPONENTS  (panels, cards, fields, widgets)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ── Inputs Panel ───────────────────────────────────────────── */
.inputs-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

fieldset {
  background: var(--bg-fieldset);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: var(--shadow);
}
legend {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
  padding: 0 0.4rem;
}

/* Field rows */
.field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.field-row label {
  flex: 0 0 160px;
  font-size: 0.88rem;
  color: var(--text);
}
.field-row input[type="number"],
.field-row input[type="text"],
.field-row select {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  background: var(--input-bg);
  color: var(--input-text);
  font-weight: 600;
}
.field-row select {
  background: var(--input-bg);
}
.field-row input[type="number"]::placeholder,
.field-row input[type="text"]::placeholder {
  color: #a09080;
  font-style: italic;
  font-weight: 400;
}
.field-row input[type="number"]:focus,
.field-row input[type="text"]:focus,
.field-row select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.unit {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.explanation {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  margin-left: 0;
  line-height: 1.4;
}
.section-label {
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.fetch-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

/* Month rows (irradiance & TSRF) */
.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.month-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.month-cell label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.month-cell input {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  background: var(--input-bg);
  color: var(--input-text);
  font-weight: 600;
}
.month-cell input::placeholder {
  color: #a09080;
  font-style: italic;
  font-weight: 400;
}
.month-cell input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* Solar status */
.solar-status {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--border-light);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
}
.solar-status button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.82rem;
  text-decoration: underline;
  padding: 0;
}
.manual-irradiance { margin-top: 0.5rem; }
.manual-irradiance > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.manual-irradiance > summary::-webkit-details-marker { display: none; }
.manual-irradiance > summary::marker { display: none; }
.manual-irradiance > summary::after {
  content: ' ▼';
  font-size: 0.7em;
  opacity: 0.6;
}
.manual-irradiance[open] > summary::after { content: ' ▲'; }

/* Chemistry details */
.chemistry-details {
  margin-top: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  background: #fff;
}
.chemistry-details summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
}
.summary-note {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.chemistry-details .field-row { margin-top: 0.5rem; }

.ext-charging-details {
  margin-top: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  background: #fff;
}
.ext-charging-details summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
}
.top-off-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.top-off-label { font-size: 0.88rem; color: var(--text); }
.ext-charging-divider { border: none; border-top: 1px solid var(--border-light); margin: 0.75rem 0 0.5rem; }
.ext-charging-subhead { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem; }
.charger-unit-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; margin-bottom: 0.1rem; }
.charger-unit-label { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }
.charger-unit-group { display: flex; gap: 0; }
.charger-unit-btn { padding: 0.25rem 0.7rem; border: 1px solid var(--primary); background: #fff; color: var(--primary); cursor: pointer; font-size: 0.8rem; font-weight: 600; }
.charger-unit-btn:first-child { border-radius: 4px 0 0 4px; }
.charger-unit-btn:last-child  { border-radius: 0 4px 4px 0; }
.charger-unit-active { background: var(--primary); color: #fff; }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 21px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(17px); }

/* Top-off insufficient flag in Net DoD cell */
.topoff-flag {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 0.1rem;
}
.topoff-insufficient { color: var(--overdod-text); }
.approaching-flag    { color: var(--approaching-text); }

/* Hourly TMY per-month risk chips appended to status cell */
.hourly-flag {
  display: inline-block;
  margin-left: 0.3em;
  font-size: 0.82rem;
  cursor: default;
}
.hourly-flag-over  { color: #c0392b; }
.hourly-flag-warn  { color: #e67e22; }
.adeq-hourly-legend { color: var(--text-muted); }

/* Unit selector */
.unit-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  font-size: 0.88rem;
}
.unit-selector-label { color: var(--text-muted); }
.unit-selector label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

/* Load entries */
.load-entry {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
}
.load-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.1rem;
}
.load-entry .field-row { margin-top: 0.4rem; }
.load-entry .field-row label { flex: 0 0 130px; }

/* Multi-plane (split-array) */
.multi-plane-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-light);
}
.multi-plane-count-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
  background: #eef2f7;
  border-radius: 999px;
  vertical-align: middle;
}
.multi-plane-count-badge:empty { display: none; }
#extra-planes-container { display: flex; flex-direction: column; gap: 0.6rem; }
.plane-card {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
}
.plane-card .field-row { margin-top: 0.4rem; }
.plane-card .field-row label { flex: 0 0 130px; }
.plane-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.plane-card-header .plane-label {
  flex: 1;
  font-weight: 600;
  color: var(--primary);
  padding: 0.25rem 0.35rem;
  border: 1px solid transparent;
  background: transparent;
}
.plane-card-header .plane-label:focus {
  border-color: var(--border-light);
  background: #fafafa;
}
.plane-remove-btn {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
  color: #888;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.plane-remove-btn:hover { color: #c53030; border-color: #f0b4b4; background: #fff5f5; }
.plane-fetch-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.plane-fetch-row button { font-size: 0.85rem; padding: 0.3rem 0.6rem; }
.plane-tilt-opt-toggle,
.plane-tsrf-toggle {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  padding: 0.15rem 0;
  border: none;
  background: none;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}
.plane-tilt-opt-toggle:hover,
.plane-tsrf-toggle:hover { text-decoration: underline; }
.plane-tilt-opt-panel,
.plane-tsrf-panel {
  margin-top: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: #fff;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
}
.plane-tilt-opt-panel .tilt-opt-heading { margin-top: 0.3rem; }
.plane-tilt-opt-panel .tilt-opt-heading:first-child { margin-top: 0; }
.plane-tsrf-section { display: flex; flex-direction: column; }
.plane-tsrf-panel .field-row label { flex: 0 0 100px; }
.plane-tsrf-panel .month-grid { margin-top: 0.4rem; }
.plane-status { margin-top: 0.4rem; font-size: 0.82rem; }
#add-plane-btn { margin-top: 0.6rem; }
#add-plane-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.multi-plane-hint {
  margin-top: 0.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  background: #fff8e1;
  border: 1px solid #f3d382;
  border-radius: var(--radius);
  color: #7a5a00;
}
.easy-multiplane-banner {
  margin-top: 0.75rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  background: #eef6ff;
  border: 1px solid #b9d7fb;
  border-radius: var(--radius);
  color: #1e3a5f;
}
body:not(.mode-easy) .easy-multiplane-banner { display: none; }

/* Advanced section */
.advanced-section {
  margin-top: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  background: #fff;
}
.advanced-section summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.advanced-section .field-row { margin-top: 0.5rem; }

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }

/* ── Results Panel ──────────────────────────────────────────── */
.results-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  position: sticky;
  top: 1.25rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
}

/* Input warnings — out-of-range values */
.input-warnings {
  background: #fff8e1;
  border: 1px solid #f0b429;
  border-left: 4px solid #d97706;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.83rem;
  color: #5c3d00;
}
.input-warning-item + .input-warning-item {
  margin-top: 0.3rem;
}
.input-warnings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.input-warnings-title {
  font-weight: 600;
}
.input-warnings-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #d97706;
  font-size: 0.75rem;
  padding: 0 0.2rem;
  line-height: 1;
}
.input-warnings-body {
  margin-top: 0.3rem;
}
.input-warnings.collapsed .input-warnings-body {
  display: none;
}

/* Guidance banner — shown when inputs are incomplete */
.results-guidance {
  background: #eaf4fb;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 1rem;
}

/* Hero result */
.hero-result {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.hero-label {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-values {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.hero-item { display: flex; flex-direction: column; }
.hero-number {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}
.hero-sub {
  font-size: 0.78rem;
  opacity: 0.8;
  margin-top: 0.2rem;
}

/* Status explainer block (revealed by Show Math toggle) */
.hero-status-explainer {
  background: #f8f9fa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
  line-height: 1.5;
}
.hero-status-explainer p {
  margin: 0 0 0.5rem;
}
.hero-status-explainer p:last-child {
  margin-bottom: 0;
}
.status-label-charging { color: var(--charging-text); }
.status-label-deficit  { color: var(--deficit-text);  }
.status-label-overdod  { color: var(--overdod-text);  }
.status-explainer-note {
  color: #555;
  font-style: italic;
  font-size: 0.78rem;
}
body.show-math .hero-status-explainer { display: block; }

/* Results table */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  white-space: nowrap;
}
thead th {
  background: #eaf2f8;
  color: var(--primary);
  font-weight: 700;
  padding: 0.5rem 0.6rem;
  text-align: right;
  border-bottom: 2px solid var(--border);
  line-height: 1.3;
}
thead th:first-child { text-align: left; }

tbody td {
  padding: 0.4rem 0.6rem;
  text-align: right;
  border-bottom: 1px solid var(--border-light);
}
tbody td:first-child { text-align: left; font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }

/* Row status colors */
tr.status-charging    { background: var(--charging-bg);    color: var(--charging-text);    }
tr.status-deficit     { background: var(--deficit-bg);     color: var(--deficit-text);     }
tr.status-overdod     { background: var(--overdod-bg);     color: var(--overdod-text);     }
tr.status-nosolar     { background: var(--nosolar-bg);     color: var(--nosolar-text);     }
tr.status-toppedoff   { background: var(--toppedoff-bg);   color: var(--toppedoff-text);   }
tr.status-approaching { background: var(--approaching-bg); color: var(--approaching-text); }

/* Rows with missing irradiance or incomplete system inputs */
tr.row-nodata td,
tr.row-noirr td {
  color: var(--text-muted);
  font-style: italic;
}
tr.row-noirr td:nth-child(2) {
  color: var(--primary);
  font-style: italic;
  font-size: 0.78rem;
}

.dod-flag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--overdod-text);
  margin-left: 0.3rem;
}

/* Math columns — hidden by default, shown when Show Math is on */
.math-col { display: none; }
body.show-math .math-col { display: table-cell; }

/* Formulas section */
.math-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-light);
  padding-top: 1rem;
}
.math-section h3 {
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
.formula-block {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-page);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
}
.formula-block h4,
.formula-block > summary {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.formula-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.formula-block > summary::after {
  content: '▲';
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  flex-shrink: 0;
}
.formula-block:not([open]) > summary::after { content: '▼'; }
.formula-block > summary::-webkit-details-marker { display: none; }
.formula-block > summary::marker { display: none; }
.formula-block p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}
.source {
  font-style: italic;
  font-size: 0.78rem !important;
}

/* ── Adequacy summary ───────────────────────────────────────── */
.adequacy-summary {
  margin-top: 0.85rem;
  padding: 0.55rem 0.85rem 0.6rem;
  background: var(--bg-page);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-muted);
}
/* Headline */
.adeq-headline {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
}
.adeq-headline-good { color: var(--charging-text); }
.adeq-headline-warn { color: var(--approaching-text); }
.adeq-headline-fail { color: var(--deficit-text); }

/* Per-month verdict pills */
.adeq-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}
.adeq-pill {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.9rem;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}
.adeq-pill-good    { background: var(--charging-bg,   #e6f4ea); color: var(--charging-text,   #1a6b2c); }
.adeq-pill-warn    { background: var(--approaching-bg, #fff3cd); color: var(--approaching-text,#7a5700); }
.adeq-pill-fail    { background: var(--overdod-bg,    #fde8e8); color: var(--deficit-text,    #8b1a1a); }
.adeq-pill-nosolar { background: var(--bg-alt);  color: var(--text-muted); font-weight: 400; }
.adeq-pill-missing { background: transparent; color: var(--text-muted); font-weight: 400; font-style: italic; }

/* Worst-month callout */
.adeq-worst {
  font-size: 0.8rem;
  color: var(--deficit-text);
  margin-top: 0.2rem;
}
.adeq-worst-warn { color: var(--approaching-text); }

/* Legacy classes kept for hourly legend */
.adeq-surplus     { color: var(--charging-text);    font-weight: 600; }
.adeq-deficit     { color: var(--deficit-text);     font-weight: 600; }
.adeq-nosolar     { color: var(--nosolar-text);     font-weight: 600; }
.adeq-missing     { color: var(--text-muted);       font-style: italic; }
.adeq-approaching { color: var(--approaching-text); font-weight: 600; }
.adeq-hourly-link {
  float: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0.75;
}
.adeq-hourly-link:hover { opacity: 1; text-decoration: underline; }
.hourly-nav-link {
  display: block;
  text-align: right;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.15rem 0;
  opacity: 0.7;
}
.hourly-nav-link:hover { opacity: 1; text-decoration: underline; }

/* ── FAQ Section ────────────────────────────────────────────── */
.faq-section {
  max-width: 1400px;
  margin: 0 auto 1.25rem;
  padding: 0 1.25rem;
}
.faq-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted, #555);
  padding: 0.4rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.faq-details > summary::before {
  content: "▶";
  font-size: 0.65rem;
  transition: transform 0.15s;
}
.faq-details[open] > summary::before {
  transform: rotate(90deg);
}
.faq-list {
  margin: 0.75rem 0 0;
  padding: 0;
}
.faq-item {
  border-top: 1px solid var(--border, #ddd);
  padding: 0.75rem 0;
}
.faq-item dt {
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.faq-item dd {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted, #555);
  line-height: 1.55;
}

/* ── Saved Designs ──────────────────────────────────────────── */
.saved-designs-section {
  max-width: 1400px;
  margin: 0 auto 1.25rem;
  padding: 0 1.25rem;
}
.saved-designs-inner {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}
.saved-designs-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
.save-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.design-name-input {
  flex: 1;
  min-width: 180px;
  max-width: 300px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  background: var(--input-bg);
  color: var(--input-text);
}
.design-name-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.design-name-input.input-error {
  outline: 2px solid #c0392b;
  outline-offset: 1px;
}
.designs-save-notice {
  font-size: 0.82rem;
  color: #c0392b;
}
.saved-designs-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.no-designs {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}
.design-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.7rem;
  background: var(--bg-page);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.design-info {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}
.design-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.design-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.design-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
}
.btn-sm:hover { background: var(--border-light); }
.btn-sm-danger { color: #c0392b; border-color: #e8b4b8; }
.btn-sm-danger:hover { background: #fdf0f0; }

/* ── Coordinate format toggle ───────────────────────────────── */
.coord-format-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.coord-format-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.coord-fmt-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.coord-fmt-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.coord-fmt-btn:last-child { border-right: none; }
.coord-fmt-btn.coord-fmt-active { background: var(--primary); color: #fff; }
.coord-fmt-btn:hover:not(.coord-fmt-active) { background: var(--border-light); color: var(--text); }

/* ── Coordinate error ───────────────────────────────────────── */
.coord-error {
  font-size: 0.78rem;
  color: #c0392b;
  font-weight: 600;
  margin-top: 0.15rem;
  margin-left: 0;
}

/* ── Address search ─────────────────────────────────────────── */
.address-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.address-status-error { color: #c0392b; }

/* ── Secondary button ───────────────────────────────────────── */
.btn-secondary {
  background: var(--bg-panel);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border-light); }

/* ── Subsection headings inside fieldsets ───────────────────── */
.subsection-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 1.1rem 0 0.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}
.subsection-heading:first-child { margin-top: 0.2rem; }

/* ── Link-style button ──────────────────────────────────────── */
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: var(--primary-hover); }

/* ── TSRF expand ────────────────────────────────────────────── */
.tsrf-expand-row { margin-top: 0.4rem; }

/* ── Footer attribution ─────────────────────────────────────── */
.attribution {
  margin-top: 0.3rem;
  font-size: 0.72rem;
}
.attribution a { color: var(--text-muted); }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
}

/* ── PWM estimation note ─────────────────────────────────── */
.pwm-note {
  background: #f0f4ff;
  border: 1px solid #b8c8f0;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  margin-bottom: 0.5rem;
}

/* ── Optional label indicator ─────────────────────────────── */
.optional-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Required field note (under fieldset legend) ───────────── */
.required-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.1rem;
  margin-bottom: 0.25rem;
}

/* ── Formula equations (Show Math) ─────────────────────────── */
.formula-eq {
  font-size: 0.88rem;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0.45rem 0.7rem;
  margin: 0.35rem 0;
  color: var(--text);
  line-height: 1.7;
}
.formula-eq-sub {
  margin-left: 1.5rem;
}
.formula-eq sup {
  font-size: 0.72rem;
}
.formula-example {
  font-size: 0.83rem;
  background: #f0f6ff;
  border-left: 3px solid #6699cc;
  border-radius: 0 4px 4px 0;
  padding: 0.4rem 0.65rem;
  margin: 0.4rem 0 0.2rem;
  line-height: 1.65;
  color: var(--text);
}

/* ── Load management ────────────────────────────────────────── */
.load-header-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.1rem;
}
.btn-delete-load {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.btn-delete-load:hover { color: #c0392b; background: #fdf0f0; }
.load-add-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
}
.btn-add-load {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-add-load:hover { background: var(--border-light); border-color: var(--primary); }
.btn-add-load:disabled { color: var(--text-muted); border-color: var(--border-light); cursor: not-allowed; background: none; }
.load-limit-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Mobile header (tabs + hero bar) ────────────────────────── */
.mobile-header  { display: none; }
.mobile-hero-bar { display: none; }

@media (max-width: 860px) {
  .mobile-header {
    display: block;
    position: sticky;
    top: 2.5rem;   /* sits just below the sticky display-mode-bar (~2.5rem tall on mobile) */
    z-index: 100;
  }
  .mobile-tabs {
    display: flex;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-light);
    padding: 0 0.5rem;
  }
  .tab-btn {
    flex: 1;
    padding: 0.7rem 1rem;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    background: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, border-bottom-color 0.15s;
  }
  .tab-btn.tab-active { color: var(--primary); border-bottom-color: var(--primary); }
  .tab-btn:hover:not(.tab-active) { color: var(--text); }

  .mobile-hero-bar {
    display: block;
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s, color 0.2s;
  }
  .mobile-hero-bar.mobile-hero-incomplete {
    background: var(--bg-page);
    color: var(--text-muted);
    font-style: italic;
  }
  .mobile-hero-bar.mobile-hero-good    { background: var(--charging-bg); color: var(--charging-text); }
  .mobile-hero-bar.mobile-hero-warn    { background: var(--deficit-bg);  color: var(--deficit-text);  }
  .mobile-hero-bar.mobile-hero-danger  { background: var(--overdod-bg);  color: var(--overdod-text);  }
  .mobile-hero-bar.hidden              { display: none; }

  #main-content[data-active-tab="inputs"]  .results-panel { display: none; }
  #main-content[data-active-tab="results"] .inputs-panel  { display: none; }

  .results-panel { position: static; }

  /* Stack label above input on narrow screens to prevent horizontal overflow.
     Long unit strings (e.g. "Ah at C/20") combined with a fixed 160px label
     would otherwise push rows beyond the viewport width. */
  .field-row {
    flex-wrap: wrap;
    row-gap: 0.2rem;
  }
  .field-row label {
    flex: 0 0 100%;
    font-size: 0.82rem;
  }
  .field-row > input,
  .field-row > select {
    flex: 1 1 0;
    min-width: 0;
  }
  /* Units stay inline beside the input on the second line */
  .unit {
    flex-shrink: 0;
    align-self: center;
  }
}

/* ── Mode toggle ─────────────────────────────────────────────── */
.mode-toggle-row { display: flex; gap: 0; margin-bottom: 1rem; }
.mode-btn { padding: 0.4rem 1.1rem; border: 1px solid var(--primary); background: #fff; color: var(--primary); cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.mode-btn:first-child { border-radius: 4px 0 0 4px; }
.mode-btn:last-child  { border-radius: 0 4px 4px 0; }
.mode-btn-active { background: var(--primary); color: #fff; }

/* ── Load collapse ──────────────────────────────────────────── */
.load-body { /* content wrapper — hidden when collapsed */ }
.load-entry.collapsed .load-body { display: none; }

.load-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.15s, color 0.15s;
  flex-shrink: 0;
}
.load-collapse-btn:hover { color: var(--primary); }
.load-entry.collapsed .load-collapse-btn { transform: rotate(-90deg); }

.load-summary {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.4rem;
  /* hidden when expanded — only meaningful when collapsed */
  display: none;
}
.load-entry.collapsed .load-summary { display: block; }

/* ── Load card AC/DC toggle ─────────────────────────────────── */
.load-type-toggle { display: flex; gap: 0; }
.load-type-btn { padding: 0.2rem 0.6rem; border: 1px solid var(--primary); background: #fff; color: var(--primary); cursor: pointer; font-size: 0.78rem; font-weight: 700; }
.load-type-btn:first-child { border-radius: 3px 0 0 3px; }
.load-type-btn:last-child  { border-radius: 0 3px 3px 0; }
.load-type-active { background: var(--primary); color: #fff; }

/* ── PVA three-field row ────────────────────────────────────── */
.load-pva-note { font-size: 0.8rem; color: var(--text-muted); margin: 0.4rem 0 0.25rem; font-style: italic; }
.load-pva-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.load-pva-field { display: flex; flex-direction: column; align-items: flex-start; min-width: 80px; flex: 1; }
.load-pva-field input { width: 100%; }
.load-pva-field .unit { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }
.load-calc-note { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }
.load-calc-field { font-style: italic; font-weight: 400 !important; color: #666; }

/* ── DC-DC notice ───────────────────────────────────────────── */
.load-dcdc-notice { font-size: 0.78rem; color: #7a5c00; background: #fff8e1; border: 1px solid #ffe082; border-radius: 4px; padding: 0.3rem 0.6rem; margin-top: 0.4rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.load-bypass-label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; }

/* ── Show Math in hero ──────────────────────────────────────── */
.hero-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.1rem; }
.hero-show-math { font-size: 0.78rem; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESPONSIVE / MODE VISIBILITY
   (Easy/Hard/Advanced gating; per-mode show/hide rules)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ── Mode CSS visibility ────────────────────────────────────── */
body[data-mode="custom"] .mode-aio-only    { display: none !important; }
body:not([data-mode="custom"]) .mode-custom-only { display: none !important; }

/* ── Capacity unit toggle ────────────────────────────────────── */
.capacity-unit-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.capacity-unit-label { font-size: 0.82rem; color: var(--text-muted); flex-shrink: 0; }
.cap-unit-group { display: flex; gap: 0; }
.cap-unit-btn { padding: 0.3rem 0.8rem; border: 1px solid var(--primary); background: #fff; color: var(--primary); cursor: pointer; font-size: 0.82rem; font-weight: 600; }
.cap-unit-btn:first-child { border-radius: 4px 0 0 4px; }
.cap-unit-btn:last-child  { border-radius: 0 4px 4px 0; }
.cap-unit-active { background: var(--primary); color: #fff; }

/* ── Capacity unit CSS visibility ───────────────────────────── */
body[data-capunit="ah"] .cap-unit-wh-only         { display: none !important; }
body:not([data-capunit="ah"]) .cap-unit-ah-only   { display: none !important; }

/* ── Site intro (collapsible above-the-fold copy) ───────────── */
.site-intro {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.35rem 1.25rem;
}
.site-intro > summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.site-intro > summary::before {
  content: "▶";
  font-size: 0.6rem;
  transition: transform 0.15s;
}
.site-intro[open] > summary::before {
  transform: rotate(90deg);
}
.site-intro p {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  line-height: 1.55;
}

/* ── Display mode bar (Easy / Hard toggle) ──────────────────── */
.display-mode-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: transform 0.2s ease;
}
.display-mode-bar.toggle-hidden {
  transform: translateY(calc(-100% - 1.25rem));
}
/* On mobile, the bar sticks above the Inputs/Results tab bar */
@media (max-width: 860px) {
  .display-mode-bar {
    position: sticky;
    top: 0;
    z-index: 101;
    transform: none !important;
    padding: 0.4rem 1rem;
  }
}

.display-mode-row {
  display: flex;
  gap: 0;
}
.display-mode-btn {
  padding: 0.35rem 1rem;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.display-mode-btn:first-child { border-radius: 4px 0 0 4px; }
.display-mode-btn:not(:first-child):not(:last-child) { border-radius: 0; border-left: none; }
.display-mode-btn:last-child  { border-radius: 0 4px 4px 0; border-left: none; }
.display-mode-btn.display-mode-active { background: var(--primary); color: #fff; }

.whats-this-btn {
  font-size: 0.8rem;
  flex-shrink: 0;
}

.whats-this-panel {
  background: #eaf4fb;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.5;
  margin-top: -0.5rem;
}

/* ── First-run Easy mode hint banner ────────────────────────── */
.easy-hint-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: #f0f7ff;
  border: 1px solid #b8d4f0;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  font-size: 0.83rem;
  color: var(--text);
}
.easy-hint-banner.hidden { display: none; }
.hint-dismiss-btn {
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.2rem;
  margin-left: auto;
  flex-shrink: 0;
}
.hint-dismiss-btn:hover { color: var(--text); }

/* ── Easy tilt flag (shown after auto-fetch in Easy mode) ───── */
.easy-tilt-flag {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.2rem;
  padding: 0.25rem 0.5rem;
  background: #f4f7fa;
  border-radius: var(--radius);
}
.easy-tilt-flag.hidden { display: none; }

/* ── Easy / Hard mode visibility ────────────────────────────── */
/* Fields marked hide-in-easy are hidden when body has .mode-easy */
body.mode-easy .hide-in-easy { display: none; }

/* When a card's fieldset is expanded via the "+ Add detail" chip,
   reveal all hide-in-easy elements within it.
   Block fallback first, then more-specific flex overrides win. */
body.mode-easy fieldset.easy-expanded .hide-in-easy              { display: block; }
body.mode-easy fieldset.easy-expanded .hide-in-easy.field-row    { display: flex; }
body.mode-easy fieldset.easy-expanded .hide-in-easy.coord-format-row { display: flex; }
body.mode-easy fieldset.easy-expanded .hide-in-easy.fetch-row    { display: flex; }
body.mode-easy fieldset.easy-expanded .hide-in-easy.mode-toggle-row  { display: flex; }
body.mode-easy fieldset.easy-expanded .hide-in-easy.capacity-unit-row { display: flex; }

/* Adequacy summary hidden in Easy mode */
body.mode-easy #adequacy-summary { display: none !important; }

/* ── Easy-mode detail chip ──────────────────────────────────── */
.easy-chip-row {
  display: none;           /* hidden in Hard mode */
  margin-top: 0.75rem;
}
body.mode-easy .easy-chip-row { display: block; }

.detail-chip {
  background: none;
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.detail-chip:hover { background: var(--border-light); }
.detail-chip.chip-expanded { border-style: solid; }

/* ── Per-load Easy-mode field hiding ────────────────────────── */
body.mode-easy .load-name-row  { display: none; }
body.mode-easy .load-days-row  { display: none; }

/* Reveal when individual chip clicked */
body.mode-easy .load-entry.show-load-desc  .load-name-row  { display: flex; }
body.mode-easy .load-entry.show-load-hours .load-hours-row { display: flex; }
body.mode-easy .load-entry.show-load-days  .load-days-row  { display: flex; }
body.mode-easy .load-entry.show-load-opwin .load-operating-window-row { display: flex; }

/* Per-load chip row */
.load-easy-chips {
  display: none;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
body.mode-easy .load-easy-chips { display: flex; }
.load-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
}

/* ── Column picker (all modes) ──────────────────────────────── */
.col-picker-row {
  display: block;
  position: relative;
  margin-bottom: 0.6rem;
}

.btn-col-picker {
  background: var(--bg-panel);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-col-picker:hover { background: var(--border-light); }

.col-picker-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 0.6rem 0.85rem;
  z-index: 200;
  min-width: 190px;
}
.col-picker-popover.hidden { display: none; }

.col-picker-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0;
  font-size: 0.83rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.col-picker-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ── Hidden table columns (all modes) ───────────────────────── */
.easy-col-hidden { display: none; }

/* ── Advanced feature chips (opt-in from Easy/Hard) ────────── */
.advanced-feature-chip { display: none; }
body.mode-easy .advanced-feature-chip,
body.mode-hard .advanced-feature-chip { display: inline-flex; }

/* Show advanced-only blocks when opt-in chip is activated */
body.show-advanced-tiltOptimization #tiltOptimization,
body.show-advanced-daynight-math-block #daynight-math-block { display: block !important; }

/* ── Advanced mode visibility ───────────────────────────────── */
/* Elements only shown in Advanced mode */
body.mode-easy  .advanced-only { display: none !important; }
body.mode-hard  .advanced-only { display: none !important; }
/* Advanced is a superset of Hard — hard-only / hide-in-easy fields stay visible */
body.mode-advanced .hide-in-easy { display: block; }
body.mode-advanced .hide-in-easy.field-row         { display: flex; }
body.mode-advanced .hide-in-easy.coord-format-row  { display: flex; }
body.mode-advanced .hide-in-easy.fetch-row         { display: flex; }
body.mode-advanced .hide-in-easy.mode-toggle-row   { display: flex; }
body.mode-advanced .hide-in-easy.capacity-unit-row { display: flex; }

/* ── Tilt Optimization block ─────────────────────────────────── */
.tilt-opt-block {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
}
.tilt-opt-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  margin-top: 0.6rem;
}
.tilt-opt-block > .section-label,
.tilt-opt-details > summary.section-label { margin-top: 0; }

.tilt-opt-details {
  list-style: none;
}
.tilt-opt-details > summary.tilt-opt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.tilt-opt-details > summary.tilt-opt-summary::after {
  content: '▲';
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}
.tilt-opt-details:not([open]) > summary.tilt-opt-summary::after {
  content: '▼';
}
/* Remove default marker in all browsers */
.tilt-opt-details > summary::-webkit-details-marker { display: none; }
.tilt-opt-details > summary::marker { display: none; }
.tilt-opt-fixed { margin-bottom: 0.6rem; }
.tilt-opt-fixed-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.tilt-opt-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  min-width: 80px;
}
.tilt-opt-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

/* Clickable tilt value buttons */
.tilt-button {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  min-width: 54px;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.tilt-button:hover { background: var(--border-light); border-color: var(--primary); }
.tilt-button:disabled { color: var(--text-muted); cursor: default; background: var(--bg-page); }

/* Flash animation when tilt button applies a value */
@keyframes tilt-flash {
  0%   { background: #cce5ff; }
  100% { background: var(--bg-page); }
}
.tilt-button.tilt-applied {
  animation: tilt-flash 0.4s ease-out forwards;
}

/* Monthly tilt grid */
.tilt-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin-top: 0.4rem;
}
@media (max-width: 860px) {
  .tilt-grid { grid-template-columns: repeat(3, 1fr); }
}
.tilt-month-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.tilt-month-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}
.tilt-month-cell .tilt-button {
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  min-width: 44px;
  width: 100%;
}

/* Solar noon line */
.solar-noon-line {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-light);
}
.solar-noon-line:empty { display: none; }

/* Show math details inside tilt block */
.tilt-show-math {
  margin-top: 0.5rem;
  padding: 0;
  border: none;
  background: none;
}
.tilt-show-math summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--primary);
  user-select: none;
  padding: 0.2rem 0;
}
.tilt-show-math > div { margin-top: 0.4rem; }

/* ── Per-load operating window ──────────────────────────────── */
/* Hidden in Easy (hide-in-easy already handles Easy)
   Hidden in Hard by default (revealed by Hard chip)
   Always visible in Advanced */
body.mode-easy   .load-operating-window-row { display: none; }
body.mode-hard   .load-operating-window-row { display: none; }
body.mode-hard   .load-entry.show-load-opwin .load-operating-window-row { display: flex; }
body.mode-advanced .load-operating-window-row { display: flex !important; }

/* Hard-mode operating window chip: visible only in Hard mode */
.load-hard-chips { display: none; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
body.mode-hard   .load-hard-chips { display: flex; }

/* Custom window visibility mirrors the operating-window-row rules */
body.mode-easy     .load-custom-window { display: none !important; }
body.mode-hard     .load-custom-window { display: none !important; }
body.mode-easy     .load-entry.show-load-opwin .load-custom-window:not(.hidden) { display: flex !important; }
body.mode-hard     .load-entry.show-load-opwin .load-custom-window:not(.hidden) { display: flex !important; }
body.mode-advanced .load-custom-window:not(.hidden) { display: flex !important; }

/* ── Custom operating window fields ─────────────────────────── */
.load-custom-window {
  margin: 0.5rem 0 0.25rem;
  padding: 0.5rem 0.7rem;
  background: var(--surface-2, #f5f5f5);
  border-left: 3px solid var(--accent, #4a90d9);
  border-radius: 0 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.load-custom-window.hidden { display: none; }

.load-custom-mode-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.load-custom-mode-label { font-size: 0.82rem; color: var(--text-muted, #666); }

.load-custom-mode-btn {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 3px;
  background: var(--surface, #fff);
  cursor: pointer;
  color: inherit;
}
.load-custom-mode-btn.active {
  background: var(--accent, #4a90d9);
  color: #fff;
  border-color: var(--accent, #4a90d9);
}

.load-custom-derived {
  font-size: 0.8rem;
  color: var(--text-muted, #666);
  font-style: italic;
  min-height: 1.1em;
}

/* Subtle visual hint that hours field is auto-managed */
.load-hours-auto .load-hours { opacity: 0.6; }

/* ── Feedback footer button ──────────────────────────────────── */
.footer-feedback { margin-top: 0.5rem; }

.btn-feedback-open {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  opacity: 0.7;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-feedback-open:hover { opacity: 1; }

/* ── Feedback modal ──────────────────────────────────────────── */
.feedback-modal {
  border: none;
  border-radius: 8px;
  padding: 1.5rem;
  width: min(90vw, 420px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  background: var(--surface, #fff);
  color: var(--text, #222);
}
.feedback-modal::backdrop { background: rgba(0,0,0,0.4); }

.feedback-modal h2 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.feedback-intro    { margin: 0 0 0.9rem; font-size: 0.88rem; color: var(--text-muted, #666); }

.feedback-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
}
.feedback-email {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
}

.feedback-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.9rem;
}
.feedback-status {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
}
.feedback-status.feedback-ok    { background: #e8f5e9; color: #2e7d32; }
.feedback-status.feedback-error { background: #fdecea; color: #c62828; }
.feedback-status.hidden         { display: none; }

/* ── Scope 1: Hourly TMY simulation (Advanced-mode only) ─────────────────── */
.hourly-mode-block {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  background: #f6fafc;
}
.hourly-mode-summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  list-style: none;
  padding-bottom: 0.1rem;
}
.hourly-mode-summary::-webkit-details-marker { display: none; }
.hourly-mode-summary::marker { display: none; }
.hourly-mode-summary::after {
  content: ' ▼';
  font-size: 0.7em;
  opacity: 0.6;
}
.hourly-mode-block[open] > .hourly-mode-summary::after { content: ' ▲'; }
.hourly-mode-block[open] .hourly-toggle-row { margin-top: 0.5rem; }
.hourly-toggle-row { margin: 0; }
.hourly-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}
.hourly-toggle-label input[type="checkbox"] { transform: scale(1.1); }
.hourly-explanation { font-size: 0.85rem; margin: 0.4rem 0 0; color: #555; }
.hourly-panel { margin-top: 0.75rem; }
.hourly-panel.hidden { display: none; }
.hourly-status {
  font-size: 0.85rem;
  font-style: italic;
  color: #455a64;
  margin-bottom: 0.5rem;
}
.hourly-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.hourly-metric {
  padding: 0.5rem 0.6rem;
  background: #fff;
  border: 1px solid #e0e7ec;
  border-radius: 4px;
}
.hourly-metric > summary {
  list-style: none;
  cursor: pointer;
  display: block;
}
.hourly-metric > summary::-webkit-details-marker { display: none; }
.hourly-metric[open] {
  border-color: #b0bec5;
  background: #f7fafc;
}
.hourly-metric-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 0.35em;
  border-radius: 50%;
  background: #cfd8dc;
  color: #fff;
  font-size: 0.62rem;
  font-style: italic;
  font-weight: 700;
  font-family: serif;
  line-height: 1;
  vertical-align: 1px;
}
.hourly-metric[open] .hourly-metric-info {
  background: var(--primary, #1976d2);
}
.hourly-metric-glossary {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid #e0e7ec;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #455a64;
  text-transform: none;
  letter-spacing: normal;
}
.hourly-metric-label {
  font-size: 0.72rem;
  color: #607d8b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hourly-metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #263238;
  margin-top: 0.15rem;
}
.hourly-metric-value .metric-unit {
  font-size: 0.85rem;
  font-weight: 400;
  color: #607d8b;
}
.hourly-metric-value .metric-sub {
  font-size: 0.8rem;
  font-weight: 400;
  color: #607d8b;
}
.hourly-soc-bars { margin-top: 0.6rem; }
.hourly-soc-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  align-items: end;
}
.hourly-soc-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hourly-soc-bar-track {
  width: 100%;
  height: 60px;
  background: #eceff1;
  border-radius: 2px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.hourly-soc-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, #4caf50 0%, #81c784 100%);
  transition: height 0.3s ease;
}
.hourly-soc-month {
  font-size: 0.7rem;
  color: #455a64;
  margin-top: 2px;
}
.hourly-soc-pct {
  font-size: 0.65rem;
  color: #607d8b;
}
.hourly-load-split { margin-top: 0.8rem; }
.hourly-load-split-details {
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  background: #fafbfc;
}
.hourly-load-split-summary {
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: #37474f;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.hourly-load-split-summary::-webkit-details-marker { display: none; }
.hourly-load-split-glossary {
  padding: 0 0.7rem 0.5rem;
  font-size: 0.78rem;
  color: #546e7a;
  line-height: 1.4;
}
.load-split-row {
  padding: 0.4rem 0.7rem 0.6rem;
  border-top: 1px solid #eceff1;
}
.load-split-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #455a64;
  margin-bottom: 3px;
}
.load-split-title { font-weight: 600; }
.load-split-total { color: #607d8b; }
.load-split-bar {
  display: flex;
  height: 14px;
  border-radius: 3px;
  overflow: hidden;
  background: #eceff1;
}
.load-split-seg { display: block; height: 100%; }
.load-split-direct  { background: #fbc02d; }
.load-split-battery { background: #4caf50; }
.load-split-charger { background: #29b6f6; }
.load-split-unmet   { background: #e53935; }
.load-split-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  margin-top: 4px;
  font-size: 0.72rem;
  color: #546e7a;
}
.load-split-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.load-split-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.hourly-sizing-reco { margin-top: 0.8rem; }
.hourly-sizing-reco-details {
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  background: #fafbfc;
}
.hourly-sizing-reco-summary {
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: #37474f;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.hourly-sizing-reco-summary::-webkit-details-marker { display: none; }
.sizing-reco-body {
  padding: 0.4rem 0.7rem 0.6rem;
  border-top: 1px solid #eceff1;
}
.sizing-reco-message {
  font-size: 0.82rem;
  margin: 0 0 0.35rem;
  color: #37474f;
  font-weight: 600;
}
.sizing-reco-hint {
  font-size: 0.82rem;
  margin: 0 0 0.35rem;
  color: #263238;
}
.sizing-reco-caveat {
  font-size: 0.73rem;
  color: #78909c;
  margin: 0.3rem 0 0;
  font-style: italic;
}
.sizing-reco-oversize {
  font-size: 0.79rem;
  color: #b71c1c;
  background: #fff3e0;
  border-left: 3px solid #f57c00;
  padding: 0.3rem 0.5rem;
  margin: 0.3rem 0 0.25rem;
  border-radius: 3px;
  line-height: 1.4;
}
.sizing-ok      { border-left: 3px solid #43a047; }
.sizing-battery { border-left: 3px solid #00897b; }
.sizing-solar   { border-left: 3px solid #fb8c00; }
.sizing-mixed   { border-left: 3px solid #8e24aa; }
.hourly-tmy-caveat {
  margin-top: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: #fff8e1;
  border-left: 3px solid #ffb300;
  font-size: 0.8rem;
  color: #5d4037;
}

/* ── Scenario Planner ────────────────────────────────────────── */
.scenario-card {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-page);
  border: 1px solid var(--border-light);
  border-left: 3px solid #5c6bc0;
  border-radius: var(--radius);
}
.scenario-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.scenario-card > summary::after {
  content: '▲';
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}
.scenario-card:not([open]) > summary::after { content: '▼'; }

/* Mobile: open Scenario Planner becomes a full-screen sheet/modal.
   Closed state shows as a prominent "Run scenario" button row. */
@media (max-width: 720px) {
  .scenario-card:not([open]) {
    background: #fff;
    border: 1px solid var(--border-light);
    border-left: 3px solid #5c6bc0;
    padding: 0.7rem 0.9rem;
  }
  .scenario-card:not([open]) > summary::before {
    content: '▶ ';
    color: #5c6bc0;
    margin-right: 0.35rem;
  }
  .scenario-card:not([open]) > summary::after { content: ''; }

  .scenario-card[open] {
    position: fixed;
    inset: 0;
    z-index: 1000;
    margin: 0;
    padding: 0 0 1.5rem;
    border: 0;
    border-radius: 0;
    background: var(--bg-page);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .scenario-card[open] > summary {
    position: sticky;
    top: 0;
    padding: 0.85rem 1rem;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-light);
    z-index: 1;
  }
  .scenario-card[open] > summary::after {
    content: '✕';
    font-size: 1.05rem;
    color: var(--text);
  }
  .scenario-card[open] > :not(summary) {
    margin-left: 1rem;
    margin-right: 1rem;
  }
  body:has(.scenario-card[open]) { overflow: hidden; }
  .scenario-card[open] { padding-bottom: max(2.5rem, env(safe-area-inset-bottom, 2.5rem)); }
}
.scenario-card > summary::-webkit-details-marker { display: none; }
.scenario-card > summary::marker { display: none; }
.scenario-summary-title { flex: 1; }
.scenario-verdict-chip {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-right: 0.5rem;
  white-space: nowrap;
}
.scenario-verdict-chip.hidden { display: none; }
.scenario-verdict-good     { background: #e8f5e9; color: #2e7d32; }
.scenario-verdict-marginal { background: #fff8e1; color: #ef6c00; }
.scenario-verdict-fail     { background: #ffebee; color: #c62828; }
.scenario-card .explanation {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.4rem 0 0.7rem;
}
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.scenario-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.scenario-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.scenario-field input,
.scenario-field select {
  font-size: 0.88rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
/* Loads chip section — custom toggle (not <details>, won't collapse on outside clicks) */
.scenario-loads-wrap {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  background: #fafbfd;
  overflow: hidden;
}
.scenario-loads-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  user-select: none;
}
.scenario-loads-toggle:hover { background: rgba(0,0,0,0.03); }
.scenario-loads-count {
  font-size: 0.72rem;
  font-weight: normal;
  color: var(--text-muted);
  margin-left: auto;
}
.scenario-loads-arrow {
  font-size: 0.6rem;
  margin-left: 0.25rem;
}
.scenario-loads-body {
  padding: 0 0.65rem 0.55rem;
}
.scenario-loads-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.2rem;
}
/* Individual chip */
.scenario-load-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.74rem;
  padding: 0.2rem 1.4rem 0.2rem 0.55rem; /* right pad for × button */
  border: 1px solid #a5d6a7;
  border-radius: 1rem;
  background: #e8f5e9;
  color: #2e7d32;
  cursor: pointer;
  user-select: none;
  line-height: 1.4;
}
.scenario-load-chip.off {
  padding: 0.2rem 0.55rem;
  background: #f5f5f5;
  color: var(--text-muted);
  text-decoration: line-through;
  border-color: var(--border-light);
  cursor: pointer;
}
.scenario-load-chip.editing {
  border-color: var(--primary);
  background: #e3f2fd;
  color: #1565c0;
}
.chip-label { pointer-events: none; }
/* × exclude button inside chip */
.chip-x {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.12);
  color: #2e7d32;
  cursor: pointer;
  font-family: inherit;
}
.chip-x:hover { background: rgba(0,0,0,0.22); }
/* Inline editor */
.scenario-chip-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
  padding: 0.45rem 0.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
}
.chip-edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}
.chip-edit-field input {
  font-size: 0.82rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 7rem;
  font-family: inherit;
}
.chip-edit-field input[type="number"] { width: 4.5rem; }
.chip-edit-done {
  align-self: flex-end;
  padding: 0.22rem 0.7rem;
  font-size: 0.78rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
.scenario-loads-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-style: italic;
}
.scenario-extra-load {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem 0.6rem;
  margin: 0.3rem 0 0.7rem;
}
.scenario-extra-load > summary {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 0;
}
.scenario-extra-load > summary::marker,
.scenario-extra-load > summary::-webkit-details-marker { display: none; }
.scenario-extra-load > summary::before { content: '+ '; }
.scenario-extra-load[open] > summary::before { content: '− '; }
.scenario-extra-load > .scenario-extra-fields { margin-top: 0.55rem; }
/* ── Scenario calc-mode segmented control ─────────────────────────────── */
.scenario-calc-mode {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.3rem 0 0.7rem;
}
.calc-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.calc-mode-option:has(input:checked) {
  border-color: var(--accent, #1a73e8);
  background: #eef4ff;
}
.calc-mode-option input[type='radio'] {
  margin-top: 0.18rem;
  flex-shrink: 0;
  accent-color: var(--accent, #1a73e8);
}
.calc-mode-content {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.calc-mode-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.calc-mode-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.calc-mode-option-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
/* TMY empty-state CTA */
.scenario-tmy-empty {
  padding: 0.7rem 0.9rem;
  background: #fff8e1;
  border: 1px dashed #e8c200;
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text);
}
.scenario-tmy-cta {
  display: block;
  margin-top: 0.3rem;
  font-weight: 600;
  color: var(--accent, #1a73e8);
  font-size: 0.8rem;
}
/* TMY section in Show Math card */
.scenario-math-tmy {
  margin-top: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: #eef4ff;
  border-left: 3px solid var(--accent, #1a73e8);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.8rem;
  color: var(--text);
}
.scenario-math-tmy strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.82rem;
}
.scenario-sky {
  margin: 0.3rem 0 0.6rem;
  padding: 0.5rem 0.7rem;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
.scenario-sky-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.scenario-sky input[type='range'] {
  width: 100%;
  margin: 0.2rem 0;
}
.scenario-sky-readout {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.scenario-sky-readout .scenario-sky-detail {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 0.4rem;
}
.scenario-sky-readout .scenario-sky-desc {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.scenario-sky-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--text-muted);
  text-align: center;
}
.scenario-result {
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.82rem;
}
.scenario-result.empty { color: var(--text-muted); font-style: italic; }
.scenario-result-headline {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.scenario-result-headline.good     { color: #2e7d32; }
.scenario-result-headline.marginal { color: #ef6c00; }
.scenario-result-headline.fail     { color: #c62828; }
.scenario-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.4rem 0.8rem;
  margin: 0.4rem 0;
}
.scenario-result-grid div {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.scenario-result-grid div strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}
.scenario-soc-track {
  margin-top: 0.6rem;
  display: grid;
  gap: 2px;
}
.scenario-soc-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.2rem;
  align-items: center;
  font-size: 0.72rem;
  gap: 0.4rem;
}
.scenario-soc-row .soc-label  { color: var(--text-muted); }
.scenario-soc-row .soc-bar    {
  position: relative;
  height: 10px;
  background: #eceff1;
  border-radius: 5px;
  overflow: hidden;
}
.scenario-soc-row .soc-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: #66bb6a;
  border-radius: 5px;
}
.scenario-soc-row .soc-fill.warn { background: #ffb300; }
.scenario-soc-row .soc-fill.fail { background: #ef5350; }
.scenario-soc-row .soc-cutoff {
  position: absolute;
  top: -1px; bottom: -1px;
  width: 2px;
  background: #c62828;
  opacity: 0.7;
}
.scenario-soc-row .soc-pct { color: var(--text); font-weight: 600; text-align: right; }
.scenario-soc-row .soc-pct-empty { color: #c62828; }
.scenario-soc-row { cursor: pointer; border-radius: 3px; }
.scenario-soc-row:hover { background: rgba(0, 0, 0, 0.04); }
.scenario-soc-row:focus-visible { outline: 2px solid #1976d2; outline-offset: 1px; }
.soc-row-expand { font-size: 0.65em; color: var(--text-muted); margin-left: 2px; }

/* Day-timeline panel (24-hour SoC arc drill-down) */
.scenario-day-detail {
  background: #f9f9f9;
  border: 1px solid #cfd8dc;
  border-radius: 5px;
  padding: 0.5rem 0.6rem 0.4rem;
  margin: 4px 0 2px;
  overflow-x: auto;
}
.scenario-day-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.scenario-day-detail-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.scenario-day-detail-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 0 0.2rem;
  line-height: 1;
}
.scenario-day-detail-close:hover { color: var(--text); }
.scenario-day-detail-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.2rem 0 0;
}
.scenario-timeline-svg {
  width: 100%;
  max-width: 720px;
  display: block;
  overflow: visible;
}
.scenario-timeline-svg .grid-y {
  stroke: #000;
  stroke-width: 0.8;
  stroke-dasharray: 1 4;
  stroke-linecap: round;
  opacity: 0.3;
}
.scenario-timeline-svg .soc-chart-area {
  fill: rgba(66, 165, 245, 0.25);
  stroke: none;
}
.scenario-timeline-svg .soc-chart-line {
  fill: none;
  stroke: #42a5f5;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.timeline-daylight {
  fill: #fff9c4;
  opacity: 0.7;
}
.timeline-evt-tick {
  stroke-width: 1;
  stroke-dasharray: 3,3;
  opacity: 0.8;
}
.timeline-evt-tick.evt-solar   { stroke: #ff8f00; }
.timeline-evt-tick.evt-charger { stroke: #6a1b9a; }
.timeline-evt-tick.evt-load    { stroke: #0277bd; }
.timeline-evt-tick.evt-off     { opacity: 0.4; }
.timeline-evt-icon {
  font-size: 10px;
  dominant-baseline: auto;
}
.timeline-evt-icon.evt-off { opacity: 0.45; }
.grid-x-tick {
  stroke: #b0bec5;
  stroke-width: 1;
}
.grid-x-label {
  font-size: 9px;
  fill: #78909c;
}
.scenario-timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.tl-legend-item { display: flex; align-items: center; gap: 4px; }
.tl-legend-swatch {
  display: inline-block;
  width: 14px; height: 8px;
  border-radius: 2px;
}
.tl-legend-daylight { background: #fff9c4; border: 1px solid #f9a825; }
.tl-legend-soc      { background: #42a5f5; opacity: 0.7; }
.tl-legend-cutoff   { border-top: 2px dashed #c62828; height: 0; width: 14px; }

.scenario-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.45rem;
}
.scenario-topoff-note {
  font-style: normal;
  color: var(--text);
  background: #e8f5e9;
  border-left: 3px solid #43a047;
  padding: 0.25rem 0.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.scenario-passthrough-note {
  font-style: normal;
  color: var(--text);
  background: #fff3e0;
  border-left: 3px solid #fb8c00;
  padding: 0.25rem 0.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
/* Scenario Show Math card */
.scenario-show-math {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  background: var(--surface, #fff);
  font-size: 0.82rem;
}
.scenario-show-math > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.15rem 0;
  list-style: none;
}
.scenario-show-math > summary::before { content: '▶ '; font-size: 0.65rem; }
.scenario-show-math[open] > summary::before { content: '▼ '; }
.scenario-math-section {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.scenario-math-section:first-of-type { border-top: none; margin-top: 0.5rem; }
.scenario-math-section h4 {
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--text);
}
.scenario-math-section p { margin: 0.2rem 0; line-height: 1.45; color: var(--text); }
.scenario-math-section .formula-eq {
  font-family: monospace;
  font-size: 0.78rem;
  background: var(--surface-muted, #f5f7fa);
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
  margin: 0.3rem 0;
  display: block;
}
.scenario-math-list {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
  line-height: 1.6;
}
.scenario-math-example {
  background: var(--example-bg, #e3f2fd);
  border-left: 3px solid var(--accent, #1976d2);
  padding: 0.4rem 0.6rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.scenario-verdict-unknown {
  background: var(--surface-muted, #eceff1);
  color: var(--text-muted);
}
.scenario-annual-intro {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}
.scenario-annual-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.scenario-annual-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface, #fff);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.scenario-annual-row:hover,
.scenario-annual-row:focus-visible {
  background: var(--surface-hover, #f5f7fa);
  border-color: var(--border-strong, #b0bec5);
  outline: none;
}
.scenario-annual-row-disabled {
  cursor: default;
  opacity: 0.65;
}
.scenario-annual-row-disabled:hover { background: var(--surface, #fff); border-color: var(--border); }
.scenario-annual-row .annual-month {
  font-weight: 600;
  color: var(--text);
}
.scenario-back-row { margin-bottom: 0.5rem; }
.scenario-back-annual {
  font-size: 0.82rem;
  color: var(--accent, #1976d2);
  text-decoration: none;
}
.scenario-back-annual:hover { text-decoration: underline; }

/* Annual summary header */
.scenario-annual-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: var(--surface-muted, #f5f7fa);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
}
.scenario-annual-low {
  margin-left: auto;
  color: var(--text);
}
.scenario-annual-row .annual-stats {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  margin-right: 0.5rem;
  white-space: nowrap;
}

/* SoC chart */
.scenario-soc-chart-wrap {
  margin: 0.5rem 0 0.4rem;
  width: 100%;
  overflow-x: auto;
  position: relative;
}
.scenario-soc-chart {
  display: block;
  width: 100%;
  min-width: 480px;
  height: auto;
}
.scenario-soc-chart .grid-y {
  stroke: #000;
  stroke-width: 0.8;
  stroke-dasharray: 1 4;
  stroke-linecap: round;
  opacity: 0.3;
}
.scenario-soc-chart .grid-y-label {
  font-size: 9px;
  fill: var(--text-muted, #607d8b);
}
.scenario-soc-chart .grid-month {
  stroke: var(--border, #cfd8dc);
  stroke-width: 1;
  opacity: 0.45;
}
.scenario-soc-chart .grid-month-label {
  font-size: 9px;
  fill: var(--text-muted, #607d8b);
}
.scenario-soc-chart .soc-chart-area {
  fill: rgba(33, 150, 243, 0.14);
  stroke: none;
}
.scenario-soc-chart .soc-chart-line {
  fill: none;
  stroke: #1976d2;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.scenario-soc-chart .soc-chart-cutoff {
  stroke: #c62828;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  opacity: 0.85;
}
.scenario-soc-chart .soc-chart-cutoff-label {
  font-size: 9px;
  fill: #c62828;
}
.scenario-soc-chart .soc-chart-dot {
  fill: #1976d2;
  stroke: #fff;
  stroke-width: 0.5;
  pointer-events: none;
  transition: r 80ms ease-out;
}
.scenario-soc-chart .soc-chart-dot-active {
  r: 3.5;
  fill: #0d47a1;
  stroke-width: 1;
}
.scenario-soc-chart .soc-chart-dot-floor {
  fill: #c62828;
}
.scenario-soc-chart .soc-chart-dot-floor.soc-chart-dot-active {
  fill: #b71c1c;
}
.scenario-soc-chart .soc-chart-hit {
  fill: transparent;
  cursor: pointer;
  outline: none;
}
.scenario-soc-chart .soc-chart-hit:focus {
  fill: rgba(33, 150, 243, 0.10);
}
.scenario-soc-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: #263238;
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 4px 7px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.scenario-soc-tooltip.pinned {
  pointer-events: auto;
  background: #0d47a1;
  box-shadow: 0 2px 8px rgba(13, 71, 161, 0.35);
}
.scenario-soc-tooltip.pinned .soc-tip-text { display: block; margin-bottom: 3px; }
.scenario-drill-month {
  display: block;
  color: #90caf9;
  font-size: 0.72rem;
  text-decoration: none;
  white-space: nowrap;
}
.scenario-drill-month:hover { color: #fff; text-decoration: underline; }
.scenario-soc-tooltip.at-floor {
  background: #c62828;
}
.scenario-soc-tooltip.at-floor.pinned {
  background: #b71c1c;
  box-shadow: 0 2px 8px rgba(183, 28, 28, 0.4);
}
.scenario-soc-tooltip[hidden] {
  display: none;
}
