:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #545d68;
  --accent: #58a6ff;
  --accent-hover: #4493e0;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --orange: #d29922;
  --purple: #bc8cff;
  --vnav-width: 220px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  position: relative;
}

header h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 2px;
  color: var(--accent);
  white-space: nowrap;
  -webkit-text-fill-color: var(--accent);
  background: none;
  -webkit-background-clip: unset;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

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

/* ── Config Buttons ── */
.btn-config {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border); transition: all 0.15s;
}
.btn-config:hover { background: var(--border); color: var(--text); }
.btn-config-primary { background: rgba(88,166,255,0.12); color: var(--accent); border-color: rgba(88,166,255,0.3); }
.btn-config-primary:hover { background: rgba(88,166,255,0.22); }
.btn-config svg { flex-shrink: 0; }

/* ── App Layout: sidebar + main ── */
.app-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ── Left Vertical Nav ── */
.vnav {
  width: var(--vnav-width);
  min-width: var(--vnav-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
  overflow-y: auto;
}

.vnav-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.vnav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  white-space: nowrap;
}

.vnav-tab:hover { background: var(--surface2); }

/* Locked nav tab (future step not yet unlocked) */
.vnav-tab.locked,
.vnav-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.vnav-tab.locked:hover { background: transparent; }

.vnav-tab.active {
  background: rgba(88, 166, 255, 0.08);
  border-color: rgba(88, 166, 255, 0.25);
  color: var(--text);
  font-weight: 600;
}

.vnav-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.2s;
}

.vnav-tab.active .vnav-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.vnav-info { flex: 1; }
.vnav-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.vnav-tab.active .vnav-label { color: var(--text); }
.vnav-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ── Main Content Area ── */
.main-content {
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

/* ── Pages ── */
.page { display: none; height: 100%; overflow-y: auto; padding: 14px 20px; flex-direction: column; }
.page.active { display: flex; }
#dispatchPage { display: none; flex-direction: column; overflow: hidden; padding: 10px 20px; }
#dispatchPage.active { display: flex; }
#dispatchPage .ctx-banner { margin-bottom: 6px; padding: 5px 14px; flex-wrap: nowrap; overflow: hidden; }
#dispatchPage .tab-content { display: none; }
#dispatchPage .tab-content.active { display: flex; flex-direction: column; }
#dispatchPage .chart-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; }
#dispatchPage .tabs { flex-shrink: 0; margin-bottom: 8px; }
#dispatchPage .chart-box { padding: 8px 10px 2px 10px; }
#dispatchPage .chart-box h3 { margin-bottom: 4px; }

/* ── Weekly Schedule table ── */
.weekly-schedule {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 10px;
  width: max-content;   /* allow table to be as wide as needed; container scrolls */
}
.weekly-schedule .ws-day-hdr {
  text-align: left;
  white-space: nowrap;
  padding: 4px 10px 4px 0;
  min-width: 82px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  vertical-align: middle;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
}
.weekly-schedule .ws-date {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
}
.weekly-schedule thead .ws-hour-hdr {
  text-align: center;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  padding: 3px 0;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  vertical-align: bottom;
}
.weekly-schedule .ws-cell {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  height: 32px;
  border-radius: 4px;
  cursor: default;
  transition: filter 0.1s;
  padding: 2px 1px;
}
.weekly-schedule .ws-cell-inner {
  display: flex;
  flex-direction: row;
  gap: 1px;
  height: 100%;
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
}
.weekly-schedule .ws-cell-inner .ws-bar {
  flex: 1;
  border-radius: 2px;
  min-width: 0;
}
.weekly-schedule .ws-cell:hover {
  filter: brightness(1.25);
  outline: 1px solid rgba(255,255,255,0.35);
}
/* Weekly schedule in Dispatch Overview widget — scoped overrides */
#weeklyScheduleOverview .weekly-schedule {
  width: 100%;
  table-layout: fixed;  /* force columns to share 100% width equally */
}
#weeklyScheduleOverview .weekly-schedule .ws-day-hdr {
  width: 80px;          /* wider to prevent text overflow */
  min-width: 80px;
  max-width: 80px;
  font-size: 10px;      /* day name (now below date) → small grey */
  font-weight: 400;
  color: var(--text-muted);
}
#weeklyScheduleOverview .weekly-schedule .ws-day-hdr .ws-date {
  font-size: 12.5px;    /* date (now on top) → big white; 11px × 1.15 */
  font-weight: 600;
  color: var(--text);
}
#weeklyScheduleOverview .weekly-schedule .ws-hour-hdr {
  font-size: 17px;      /* 10px × 1.7 */
  width: auto;          /* let table-layout:fixed distribute remaining width */
  min-width: unset;
  max-width: unset;
}
#weeklyScheduleOverview .weekly-schedule .ws-cell {
  width: auto;          /* grow to fill distributed column width */
  min-width: unset;
  max-width: unset;
}
/* Card 1: Monthly savings table — compact, sits at top */
#dispatchCompareTable {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  flex-direction: column;
  margin-bottom: 10px;
}
/* Card 2: Daily dispatch — fills all remaining vertical space */
#dispatchDailyCard {
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}

/* ── Onboarding: 2-column top ── */
.onboarding-top {
  display: grid;
  grid-template-columns: 380px 380px;
  gap: 14px;
  min-height: 0;
  align-items: start;
}
.onboarding-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.onboarding-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  align-self: stretch;
}

/* ── Photo Upload ── */
.photo-upload {
  height: 180px;
  border-radius: 10px;
  border: 1.5px dashed var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-upload:hover { border-color: var(--accent); background: rgba(88, 166, 255, 0.04); }
.photo-upload.has-image { border-style: solid; border-color: var(--border); }
.photo-upload img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 9px;
  opacity: 0.95;
}
.upload-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
.photo-upload.has-image .upload-overlay {
  display: none;
}
.photo-upload.has-image:hover .upload-overlay { }

/* Photo action buttons (visible on hover when image is present) */
.photo-actions {
  position: absolute; bottom: 8px; right: 8px; z-index: 2;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.photo-upload.has-image:hover .photo-actions { opacity: 1; pointer-events: auto; }
.photo-action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 5px; font-size: 11px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  background: rgba(13, 17, 23, 0.85); color: var(--text-muted);
  border: 1px solid var(--border); transition: all 0.15s;
  backdrop-filter: blur(4px);
}
.photo-action-btn:hover { background: var(--surface2); color: var(--text); }
.photo-action-btn svg { flex-shrink: 0; }
.photo-action-delete:hover { color: var(--red); border-color: rgba(248,81,73,0.4); background: rgba(248,81,73,0.12); }

.field-hint { font-size: 11px; color: var(--text-dim); margin-top: 5px; line-height: 1.4; }

/* ── Map Card ── */
.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 180px;
}
.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.map-header h2 { margin-bottom: 0; }
.map-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 3px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.map-status.located {
  color: var(--green);
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.2);
}
#mapContainer {
  flex: 1;
  min-height: 0;
  background: var(--bg);
}
.map-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.map-addr {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-source { font-size: 10px; color: var(--text-dim); }

/* MapLibre dark overrides */
.maplibregl-ctrl-attrib { background: rgba(0,0,0,0.7) !important; color: var(--text-dim) !important; font-size: 10px !important; }
.maplibregl-ctrl-attrib a { color: var(--accent) !important; }
.maplibregl-ctrl-group { background: var(--surface) !important; border: 1px solid var(--border) !important; box-shadow: none !important; }
.maplibregl-ctrl-group button { background: transparent !important; color: var(--text) !important; }
.maplibregl-ctrl-group button:hover { background: var(--surface2) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--border) !important; }

/* Pulsing map marker */
.pulse-marker { width: 20px; height: 20px; position: relative; }
.pulse-dot {
  position: absolute; top: 4px; left: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.7);
  animation: pulse-ring 2.2s ease-out infinite;
}
.pulse-halo {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(88, 166, 255, 0.18);
  animation: pulse-halo 2.2s ease-out infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(88, 166, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0); }
}
@keyframes pulse-halo {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(3.5); opacity: 0; }
}

/* ── Others tab: 2-column layout ── */
.others-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  align-content: start;
}

/* ── Required indicator ── */
.required { color: var(--red); font-weight: 700; margin-left: 2px; }

.input-col { display: flex; flex-direction: column; gap: 12px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.card.compact { padding: 8px 12px; }

.card h2 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin: 10px 0 6px;
  color: var(--text-dim);
}

/* ── Forms ── */
.form-group { margin-bottom: 8px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', -apple-system, sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-color: var(--bg);
}

.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }

.cost-total {
  background: var(--bg) !important;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--green) !important;
  text-align: center;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Bills table (compact) ── */
.bills-table { display: flex; flex-direction: column; gap: 2px; }
.bills-header {
  display: grid; grid-template-columns: 30px 1fr 1fr; gap: 6px;
  font-size: 10px; font-weight: 600; color: var(--text-dim); padding: 0 2px;
}
.bills-row {
  display: grid; grid-template-columns: 30px 1fr 1fr; gap: 6px; align-items: center;
}
.bills-row label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.bills-row input {
  padding: 3px 5px; font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; color: var(--text); outline: none;
  text-align: right;
}
.bills-row input:focus { border-color: var(--accent); }

/* ── Schedule description ── */
.schedule-desc {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 4px 0 8px 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  max-height: 80px;
  overflow-y: auto;
}
.schedule-desc .desc-source { margin-top: 4px; font-size: 0.85em; }
.schedule-desc .desc-source a { color: var(--accent); }

.count-badge { font-weight: normal; color: var(--text-dim); font-size: 0.9em; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 24px;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.18s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  justify-content: center;
  padding: 11px 24px;
  font-size: 14px;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.btn-sm {
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ── KPI row ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
}

.kpi-card .kpi-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 2px;
}

.kpi-card .kpi-value { font-size: 1.05em; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.kpi-card .kpi-unit { font-size: 10px; color: var(--text-dim); }
.kpi-green .kpi-value { color: var(--green); }
.kpi-blue .kpi-value { color: var(--accent); }
.kpi-yellow .kpi-value { color: var(--yellow); }
.kpi-orange .kpi-value { color: var(--orange); }

/* ── Dispatch monthly comparison table ── */
.dispatch-compare {
  width: 100%;
  table-layout: fixed;       /* equal column widths */
  border-collapse: collapse;
  font-size: 11px;
  background: rgba(15,23,42,0.7);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.dispatch-compare th {
  padding: 5px 6px;
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  white-space: normal;       /* wrap header text in equal-width columns */
  word-break: break-word;
  background: rgba(30,41,59,0.6);
}
.dispatch-compare th:first-child { text-align: center; padding-left: 6px; }
.dispatch-compare td {
  padding: 7px 6px;
  text-align: center;
  color: #cbd5e1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.dispatch-compare td.row-hdr {
  text-align: center;
  padding-left: 6px;
  font-family: var(--font-ui), sans-serif;
  font-weight: 700;
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
}
.dispatch-compare tr.batt-on td { background: rgba(34,197,94,0.06); }
.dispatch-compare tr.batt-on td.row-hdr { color: #4ade80; }
.dispatch-compare tr.no-batt:last-child td { border-bottom: none; }
.dispatch-compare tr.batt-on:last-child td { border-bottom: none; }
.dispatch-compare .savings-cell { color: #4ade80; font-weight: 700; font-size: 110%; }
.dispatch-compare .peak-reduced { color: #4ade80; }

/* ── Charts ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 2px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chart-box h3 { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; flex-shrink: 0; }
.chart-box canvas { width: 100% !important; flex: 1; min-height: 0; }

/* ── Day picker pills ── */
.day-pill {
  font-size: 10px; font-weight: 600; font-family: 'Inter', system-ui, sans-serif;
  padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  white-space: nowrap; transition: all 0.15s;
}
.day-pill:hover { border-color: var(--accent); color: var(--text); }
.day-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-pill.weekend { font-style: italic; opacity: 0.75; }
.day-pill.weekend.active { opacity: 1; }

/* ── Scenario table ── */
.scenario-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.scenario-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
}

.scenario-table td { padding: 7px 10px; border-bottom: 1px solid rgba(48, 54, 61, 0.4); font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.scenario-table tr:hover { background: var(--surface2); }
.scenario-table tr.optimal { background: rgba(63, 185, 80, 0.08); }
.scenario-table .positive { color: var(--green); }
.scenario-table .negative { color: var(--red); }

/* ── Rate summary ── */
.rate-summary {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  margin-top: 6px;
}

.rate-summary .rate-line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.rate-summary .rate-line:last-child { border-bottom: none; }
.rate-summary .rate-label { color: var(--text-muted); }
.rate-summary .rate-value { font-weight: 700; font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* ── Result sub-tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }

.tab {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}

.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Loading overlay ── */
.loading {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading.active { display: flex; }

.loading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text); font-size: 13px; font-weight: 500; }

/* ── Solver animation overlay ── */
.solver-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.80);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.solver-overlay.active { opacity: 1; pointer-events: auto; }

.solver-panel {
  width: 42vw;
  height: 38vh;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.15);
}
.solver-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}
.solver-header h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #94a3b8;
  margin: 0;
}
.solver-header h1 span { color: #22d3ee; }
.solver-metrics { display: flex; gap: 22px; }
.solver-metric { text-align: center; }
.sm-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; }
.sm-value { font-size: 17px; font-weight: 700; font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.sm-value.cyan { color: #22d3ee; }
.sm-value.green { color: #22c55e; }
.sm-value.yellow { color: #facc15; }
.sm-value.red { color: #f87171; }
.solver-chart-area { flex: 1; padding: 8px 14px; min-height: 0; position: relative; }
.solver-chart-area canvas { width: 100% !important; height: 100% !important; }

.solver-converged-banner {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  justify-content: center;
  align-items: center;
}
.solver-converged-banner.active { display: flex; }
.scb-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #22c55e;
  animation: scb-blink 1.2s ease-in-out infinite;
}
@keyframes scb-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.solver-footer {
  padding: 6px 20px;
  background: #1e293b;
  border-top: 1px solid #334155;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.sf-phase { font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.sf-bar { flex: 1; height: 4px; background: #334155; border-radius: 2px; margin: 0 16px; overflow: hidden; }
.sf-fill { height: 100%; background: linear-gradient(90deg, #22d3ee, #22c55e); border-radius: 2px; width: 0%; transition: width 0.3s ease; }
.sf-status { font-size: 11px; color: #22d3ee; font-weight: 600; white-space: nowrap; }

@keyframes solver-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(34, 197, 94, 0.3); }
  50% { box-shadow: 0 0 24px rgba(34, 197, 94, 0.6); }
}
.solver-overlay.converged .solver-header { animation: solver-glow 2s ease-in-out infinite; border-color: #22c55e; }

/* ── Welcome state ── */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
  color: var(--text-dim);
}

.welcome-state h2 { color: var(--text); font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.welcome-state p { max-width: 400px; font-size: 13px; color: var(--text-muted); }

/* ── Collapsible (kept for backward compat) ── */
.section-toggle {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.section-toggle::after { content: '▼'; font-size: 0.65em; transition: transform 0.2s; }
.section-toggle.collapsed::after { transform: rotate(-90deg); }
.collapsible.collapsed { display: none; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .others-layout { grid-template-columns: 1fr; }
  .onboarding-top { grid-template-columns: 380px 380px; }
}
@media (max-width: 800px) {
  :root { --vnav-width: 60px; }
  .vnav-label, .vnav-sub, .vnav-title { display: none; }
  .vnav-tab { padding: 10px 0; justify-content: center; }
  .vnav-circle { width: 32px; height: 32px; }
  .vnav-info { display: none; }
  .onboarding-top { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ── Config Modal ── */
.config-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.config-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: 420px; max-height: 70vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}
.config-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.config-modal-header h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.config-modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 20px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.config-modal-close:hover { color: var(--text); }
.config-modal-list { overflow-y: auto; padding: 8px; }
.config-modal-item {
  padding: 10px 14px; border-radius: 8px; cursor: pointer; transition: background 0.12s;
}
.config-modal-item:hover { background: var(--surface2); }
.config-item-name { font-size: 13px; font-weight: 600; color: var(--text); }
.config-item-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ── Toast ── */
.config-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--green); color: #fff; padding: 8px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 600; opacity: 0; transition: all 0.3s; pointer-events: none;
  z-index: 10000;
}
.config-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Rate Matrix Tables ── */

.matrix-btns { display: flex; align-items: center; gap: 8px; }

.matrix-legend {
  font-size: 0.7em;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}
.matrix-legend .swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 2px;
  vertical-align: middle;
}

.matrix-scroll { overflow-x: auto; }

.rate-matrix {
  border-collapse: collapse;
  font-size: 0.75em;
  font-family: 'Inter', sans-serif;
  width: 100%;
  white-space: nowrap;
  line-height: 1.25;
}

.rate-matrix th {
  padding: 2px 3px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.rate-matrix th.row-label {
  text-align: right;
  padding-right: 5px;
  min-width: 30px;
}

.rate-matrix td {
  padding: 2px 3px;
  text-align: center;
  border: 1px solid var(--border);
  cursor: default;
}

.rate-matrix td[contenteditable="true"] {
  cursor: text;
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.rate-matrix td.row-label {
  text-align: right;
  padding-right: 4px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface) !important;
  border: none;
  min-width: 28px;
}

.rate-matrix td.month-label {
  font-size: 0.85em;
  vertical-align: middle;
  border-right: 1px solid var(--border);
}

/* ── Autosave indicator ── */
.autosave-indicator {
  color: #3fb950;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
  margin-right: 8px;
}
.autosave-indicator.visible {
  opacity: 1;
}

.rate-matrix td.type-label {
  font-size: 0.8em;
  letter-spacing: 0.3px;
  min-width: 32px;
  text-align: center;
  padding: 1px 2px;
  white-space: nowrap;
}

.rate-matrix td.energy-label { color: #86efac; }
.rate-matrix td.demand-label { color: #93c5fd; }

/* Spacer between monthly pairs */
.rate-matrix tr.month-spacer td {
  height: 0;
  padding: 0;
  background: transparent !important;
  border: none;
  display: none;
}

/* Split matrix subtitle */
.matrix-subtitle {
  color: var(--muted);
  font-size: 0.75em;
  margin: -2px 0 4px 0;
  letter-spacing: 0.3px;
}

/* Weekend strip within a card */
.matrix-weekend-strip {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.matrix-weekend-strip h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85em;
  margin-bottom: 3px;
  color: var(--muted);
}

/* Color accents for energy vs demand cards */
.energy-matrix th { background: rgba(134, 239, 172, 0.12); }
.demand-matrix th { background: rgba(147, 197, 253, 0.12); }

/* ── BATTERY SIZING STUDIO (Tab 3) ── */
.bs-layout {
  display: grid;
  grid-template-columns: 312px 1fr;
  flex: 1; min-height: 0; overflow: hidden; width: 100%;
}
.bs-side {
  background: var(--surface); overflow-y: auto;
  padding: 7px; display: flex; flex-direction: column; gap: 4px;
}
.bs-side.left  { border-right: 1px solid var(--border); }
.bs-side.right { border-left:  1px solid var(--border); }
.bs-center { display: flex; flex-direction: column; flex: 1; background: var(--bg); overflow: hidden; min-width: 0; }
/* Sub-tab bar inside center panel */
.bs-subtabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }
.bs-subtab {
  padding: 7px 18px; font-size: 11px; font-weight: 600; color: var(--text-muted);
  background: transparent; border: none; cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; font-family: 'Inter', sans-serif;
}
.bs-subtab:hover { color: var(--text); }
.bs-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.bs-pane { display: none; }
.bs-pane.active { display: flex; }
.p-title { font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 3px; }
.p-card  { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; flex-shrink: 0; }

/* "Passed onto next step" card in continue bars */
.passcard {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 16px 9px;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.passcard-title {
  font-size: 8.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-dim);
}
.passcard-body {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 4px 10px; font-size: 10px; color: var(--text-muted);
  line-height: 1.5;
}
.passcard-body strong { color: var(--text); font-weight: 600; }
.passcard-sep { color: var(--border); padding: 0 2px; }


.irow { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin-bottom: 3px; }
.irow:last-child { margin-bottom: 0; }
.ilabel { font-size: 10px; color: var(--text-muted); flex: 1; line-height: 1.3; }
.iunit  { font-size: 9px; color: var(--text-dim); white-space: nowrap; }
.ival {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; width: 72px; text-align: right; outline: none;
}
.ival:focus { border-color: var(--accent); }
.krow {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 2px 0; border-bottom: 1px solid rgba(48,54,61,.5);
}
.krow:last-child { border-bottom: none; }
.klbl { font-size: 10px; color: var(--text-muted); }
.kval { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--text); }
.kval.g { color: var(--green); }
.kval.r { color: var(--red); }
.kval.o { color: var(--orange); }
.kval.a { color: var(--accent); }
.kval.c { color: #67e8f9; }

/* ── Info button & popup ─────────────────────────────────────── */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-muted); font-size: 9px; font-style: normal;
  width: 13px; height: 13px; padding: 0; cursor: pointer; line-height: 1;
  vertical-align: middle; margin-left: 2px;
  transition: color .15s, border-color .15s;
}
.info-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Calculate button dirty-state pulse */
@keyframes dirtyPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(88,166,255,0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(88,166,255,0); }
}
.btn-dirty-pulse { animation: dirtyPulse 1.6s ease infinite; }

/* Results wrapper — flex row inside bs-layout */
.bs-results-wrapper { display: flex; flex-direction: row; flex: 1; min-height: 0; position: relative; overflow: hidden; }

/* Phase modal log entry colours */
.phase-log-ok   { color: #22c55e; }
.phase-log-info { color: var(--text-muted); }
.phase-log-head { color: var(--accent); font-weight: 600; }

/* Phase checklist items */
.phase-item { display:flex; align-items:center; gap:8px; font-size:11px; color:var(--text-muted); padding:4px 0; transition: color .2s; }
.phase-item.done   { color: #22c55e; }
.phase-item.active { color: var(--text); font-weight:600; }
.phase-icon { width:14px; text-align:center; flex-shrink:0; }

.info-popup {
  position: absolute; z-index: 9999;
  background: #1c2230; border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px;
  font-size: 10.5px; line-height: 1.65; color: var(--text);
  max-width: 340px; box-shadow: 0 6px 24px rgba(0,0,0,.55);
  cursor: pointer; white-space: pre-wrap;
}
.info-popup-arrow {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 10px; height: 6px;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  background: var(--border);
}
.bs-divider { height: 1px; background: var(--border); margin: 4px 0; }
.bs-slider-wrap {
  padding: 10px 14px 8px; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.bs-slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.bs-s-title  { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.bs-s-sub    { font-size: 9px; color: var(--text-dim); margin-top: 2px; }
.bs-s-readout { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 800; color: var(--accent); }
.tier-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 5px; border-radius: 3px; font-size: 10px; font-family: 'JetBrains Mono', monospace; }
.tier-row.active { background: rgba(88,166,255,.12); }
#bsBattSlider { width: 100%; accent-color: var(--accent); cursor: pointer; height: 6px; border-radius: 3px; display: block; margin: 0; padding: 0; }
.bs-tick-labels {
  position: relative;
  height: 16px;
  margin-top: 6px;
  font-size: 9px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.bs-tick-labels span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.alert-green  { background: rgba(63,185,80,.08);  border: 1px solid rgba(63,185,80,.28);  border-radius: 6px; padding: 7px 9px; font-size: 10px; color: var(--green);  line-height: 1.5; }
.alert-orange { background: rgba(210,153,34,.08); border: 1px solid rgba(210,153,34,.28); border-radius: 6px; padding: 7px 9px; font-size: 10px; color: var(--orange); line-height: 1.5; }

/* Dispatch scene controls */
.scene-controls {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px; background: #161b22; border-top: 1px solid #21262d;
  flex-shrink: 0;
}
.btn-play {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: #e6edf3; background: #238636; border: 1px solid #2ea043;
  border-radius: 4px; padding: 3px 12px; cursor: pointer;
  transition: background 0.15s;
}
.btn-play:hover:not(:disabled) { background: #2ea043; }
.btn-play:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-play.playing { background: #d29922; border-color: #e3b341; }
.scene-time-label {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: #8b949e;
}

/* Make investmentPage fill vertical space for bs-layout */
#investmentPage { display: none; flex-direction: column; overflow: hidden; padding: 0; }
#investmentPage.active { display: flex; }
#investmentPage > div:not(.ctx-banner):not(.continue-bar) { flex: 1; min-height: 0; }

/* ═══════════════ Validation badges on nav circles ═══════════════ */
.vnav-tab .vnav-circle { position: relative; }
.vnav-badge {
  position: absolute; top: -4px; right: -4px;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 9px; font-weight: 700; line-height: 14px;
  text-align: center; border: 1.5px solid var(--bg);
  pointer-events: none;
}
.vnav-badge.valid   { background: #238636; color: #fff; }
.vnav-badge.invalid { background: #d29922; color: #fff; }
.vnav-badge.locked  { background: #444; color: #aaa; }

/* ═══════════════ Context banner (carry-forward strip) ═══════════════ */
/* ── Dispatch run button pulse (stops after first run) ── */
@keyframes dispatch-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(88,166,255,0.7); background: #58a6ff; color: #000; }
  60%  { box-shadow: 0 0 0 8px rgba(88,166,255,0);  background: #1f6feb; color: #000; }
  100% { box-shadow: 0 0 0 0 rgba(88,166,255,0);    background: #58a6ff; color: #000; }
}
.dispatch-run-btn.pulsing {
  animation: dispatch-pulse 1.6s ease-out infinite;
  color: #000 !important;
}
/* Stale-state pulse — fast amber glow when dispatch results are outdated */
@keyframes dispatch-stale-pulse {
  0%   { box-shadow: 0 0 0 0  rgba(210,153,34,0.9); }
  40%  { box-shadow: 0 0 0 10px rgba(210,153,34,0); }
  100% { box-shadow: 0 0 0 0  rgba(210,153,34,0); }
}
.dispatch-run-btn.stale-pulse {
  animation: dispatch-stale-pulse 0.8s ease-out infinite;
  background: #d29922 !important;
  border-color: #e3b341 !important;
  color: #000 !important;
}
/* Stale notice banner below dispatch header */
.dispatch-stale-notice {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 6px;
  background: rgba(210,153,34,0.10);
  border: 1px solid rgba(210,153,34,0.35);
  border-radius: 6px;
  font-size: 11px;
  color: var(--orange);
  flex-shrink: 0;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
/* Override btn-primary full-width so dispatch button stays compact */
.dispatch-run-btn {
  width: auto !important;
}

.ctx-banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 14px; margin-bottom: 12px;
  background: rgba(88, 166, 255, 0.05);
  border: 1px solid rgba(88, 166, 255, 0.15);
  border-radius: 8px; font-size: 11px; color: var(--text-muted);
  flex-shrink: 0; flex-grow: 0;
}
.ctx-banner .ctx-item { display: flex; align-items: center; gap: 4px; }
.ctx-banner .ctx-val { color: var(--text); font-weight: 600; font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.ctx-banner .ctx-sep { width: 1px; height: 16px; background: var(--border); flex-shrink: 0; }
.ctx-banner .ctx-warn { color: var(--red); font-weight: 600; }

/* ═══════════════ Continue button (bottom of tab) ═══════════════ */
.continue-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 8px 14px; flex-shrink: 0;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; z-index: 20;
  background: var(--surface);
}
.btn-continue {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 22px; border-radius: 6px; border: 1px solid var(--accent);
  background: rgba(88, 166, 255, 0.10); color: var(--accent);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn-continue:hover:not(:disabled) { background: rgba(88, 166, 255, 0.20); }
.btn-continue:disabled { opacity: 0.35; cursor: not-allowed; border-color: var(--border); color: var(--text-dim); }
.btn-continue .arrow { font-size: 14px; }
.continue-hint { font-size: 10px; color: var(--text-dim); }

/* ═══════════════ Gated action buttons ═══════════════ */
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.5); }
.btn-primary:disabled:hover { transform: none; box-shadow: none; }

/* ═══════════════════════════════════════════════════════════════
   BUILDING MODELLING PAGE
═══════════════════════════════════════════════════════════════ */

/* ── Landing state ─────────────────────────────────────────── */
.bm-landing {
  display: flex; align-items: center; justify-content: center;
  height: 100%; width: 100%;
}
.bm-landing-inner {
  text-align: center; max-width: 560px; padding: 40px 20px;
}
.bm-landing-icon { font-size: 56px; margin-bottom: 18px; line-height: 1; }
.bm-landing-title {
  font-size: 24px; font-weight: 700; color: var(--text);
  margin-bottom: 12px; letter-spacing: 0.01em;
}
.bm-landing-sub {
  font-size: 13px; color: var(--text-muted); line-height: 1.7;
  margin-bottom: 28px;
}
.btn-bm-run {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 38px; font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
  background: linear-gradient(135deg, #58a6ff 0%, #3fb950 100%);
  color: #000; border: none; border-radius: 10px; cursor: pointer;
  box-shadow: 0 4px 24px rgba(88, 166, 255, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-bm-run:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(88,166,255,0.5); }
.btn-bm-run:active { transform: translateY(0); }
.bm-landing-hint { font-size: 11px; color: var(--text-dim); margin-top: 14px; }

/* ── Results layout ─────────────────────────────────────────── */
.bm-results {
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 20px; overflow-y: auto; height: 100%;
}
.bm-section { transition: opacity 0.5s ease; }
.bm-section-hdr {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 12px;
}

/* ── KPI tiles ──────────────────────────────────────────────── */
.bm-kpi-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.bm-kpi {
  flex: 1; min-width: 110px; padding: 16px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.bm-kpi:hover { border-color: var(--accent); box-shadow: 0 0 12px rgba(88,166,255,0.12); }
.bm-kpi-val {
  font-size: 22px; font-weight: 800; color: var(--accent);
  font-family: 'JetBrains Mono', monospace; margin-bottom: 4px;
}
.bm-kpi-lbl { font-size: 10px; color: var(--text-muted); letter-spacing: 0.04em; }
.bm-kpi-r2 .bm-kpi-val { color: var(--green); }

/* ── Two-column rows ────────────────────────────────────────── */
.bm-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.bm-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.bm-grid3 .span-2 { grid-column: span 2; }
.bm-grid3 .span-3 { grid-column: span 3; }
.bm-chart-3d-sm { height: 220px; width: 100%; }
.bm-eq-card { display: flex; flex-direction: column; overflow: hidden; }
.bm-eq-body { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 5px; padding: 4px 2px; overflow: hidden; }
.bm-eq-coefs { display: flex; gap: 6px; flex-wrap: wrap; font-size: 10.5px; color: #8b949e; font-family: monospace; padding: 3px 4px; background: rgba(255,255,255,.03); border-radius: 4px; border: 1px solid #21262d; }
.bm-eq-coefs span { white-space: nowrap; }
.bm-eq-coefs strong { color: #c9d1d9; margin-left: 2px; }
.bm-eq-step { display: flex; flex-direction: column; gap: 4px; }
.bm-eq-step-label { font-size: 10px; font-weight: 700; color: #58a6ff; text-transform: uppercase; letter-spacing: 0.06em; }
.bm-eq-formula { font-size: 12px; font-weight: 600; color: #c9d1d9; text-align: center; letter-spacing: 0.3px; font-family: monospace; background: rgba(255,255,255,.04); padding: 5px 8px; border-radius: 5px; border: 1px solid #21262d; }
.bm-eq-formula-sm { font-size: 10.5px; }
.bm-eq-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.bm-eq-table td { padding: 3px 6px; border-bottom: 1px solid #21262d; color: #8b949e; }
.bm-eq-table td:last-child { text-align: right; font-weight: 600; color: #c9d1d9; font-family: monospace; font-size: 12px; }
.bm-eq-interp { font-size: 10px; color: #6e7681; text-align: center; font-style: italic; line-height: 1.4; padding: 0 4px; }
.bm-info-btn { margin-left: auto; background: none; border: 1px solid #30363d; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; line-height: 16px; text-align: center; color: #8b949e; cursor: pointer; flex-shrink: 0; padding: 0; transition: border-color 0.15s, color 0.15s; }
.bm-info-btn:hover { border-color: #58a6ff; color: #58a6ff; }

/* ── Chart cards ────────────────────────────────────────────── */
.bm-chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
  overflow: hidden;
}
.bm-chart-card-full { grid-column: 1 / -1; }
.bm-chart-card-wide { grid-column: span 1; flex: 2; }
.bm-chart-card-narrow { grid-column: span 1; flex: 1; }
.bm-chart-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 10px; letter-spacing: 0.03em;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.bm-chart-tall { height: 220px; width: 100%; }
.bm-chart-heatmap { height: 200px; width: 100%; }
.bm-chart-3d { height: 460px; width: 100%; }
.bm-canvas { width: 100% !important; height: 220px !important; display: block; }

/* ── Gauge label ────────────────────────────────────────────── */
.bm-gauge-label {
  text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-top: -8px;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Month select in chart title ─────────────────────────────── */
.bm-month-select {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: 2px 6px;
  font-size: 10px; cursor: pointer; margin-left: auto;
}

/* .bm-continue replaced by .continue-bar */

/* ── Chart widget expand (popout) button ─────────────────────── */
.chart-box { position: relative; }
.chart-expand-btn {
  position: absolute;
  top: 7px;
  right: 8px;
  z-index: 5;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 5px;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chart-expand-btn:hover {
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.22);
  color: var(--text);
}

/* ── Chart popout modal ──────────────────────────────────────── */
#chartPopoutModal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.76);
  display: none;
  align-items: center;
  justify-content: center;
}
#chartPopoutModal.active { display: flex; }
#chartPopoutInner {
  position: relative;
  width: 75vw;
  height: 75vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 72px rgba(0,0,0,0.72);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chartPopoutClose {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 10;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 15px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
#chartPopoutClose:hover { background: rgba(255,255,255,0.15); color: var(--text); }
#chartPopoutContent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#chartPopoutContent > .chart-box {
  flex: 1;
  min-height: 0;
  border-radius: 12px;
  border: none;
  padding: 18px 20px 10px 20px;
}
#chartPopoutContent > .chart-box h3 { font-size: 13px; }
#chartPopoutContent > .chart-box .chart-expand-btn { display: none; }

/* ═══════════════════════════════════════════════════════════════
   Header dropdown menus (Open / Save / User) + Cloud Config Browser
   ═══════════════════════════════════════════════════════════════ */
.config-menu { position: relative; display: inline-flex; }
.config-menu-dropdown {
  display: none;
  position: absolute; top: calc(100% + 4px); right: 0;
  min-width: 240px; padding: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 9000;
}
.config-menu.open .config-menu-dropdown { display: block; }
.config-menu-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 6px 10px 4px;
}
.config-menu-dropdown button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: 6px; border: 0;
  background: transparent; color: var(--text);
  font-size: 13px; font-family: inherit; cursor: pointer; text-align: left;
}
.config-menu-dropdown button:hover { background: var(--border); }
.config-menu-dropdown .cm-icon { width: 18px; text-align: center; font-size: 14px; }

.user-menu { margin-left: 8px; }
.btn-user {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface2); color: var(--text);
  cursor: pointer;
}
.btn-user:hover { background: var(--border); }
.user-menu-dropdown { min-width: 200px; }
.user-menu-dropdown .config-menu-label {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}

.cloud-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.cloud-modal-backdrop[hidden] { display: none; }
.cloud-modal {
  width: min(720px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.cloud-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.cloud-modal-header h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.cloud-modal-close {
  background: transparent; border: 0; color: var(--text-muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.cloud-modal-close:hover { color: var(--text); }
.cloud-modal-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.cloud-tab {
  padding: 6px 12px; border-radius: 6px; border: 0;
  background: transparent; color: var(--text-muted);
  font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.cloud-tab:hover { color: var(--text); }
.cloud-tab.active {
  background: rgba(88, 166, 255, 0.16);
  color: var(--accent);
}
.cloud-user-pill {
  margin-left: auto; font-size: 11px; color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.cloud-modal-body { padding: 14px 18px; overflow-y: auto; flex: 1; }
.cloud-list { display: flex; flex-direction: column; gap: 6px; }
.cloud-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all 0.12s;
}
.cloud-row:hover { background: var(--surface2); border-color: var(--accent); }
.cloud-row .cr-meta { flex: 1; min-width: 0; }
.cloud-row .cr-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloud-row .cr-sub  { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloud-row .cr-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.cloud-row .cr-delete {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.12s;
}
.cloud-row .cr-delete:hover {
  color: #f87171; border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.10);
}
.cloud-empty, .cloud-status {
  padding: 12px; font-size: 12px; color: var(--text-muted); text-align: center;
}
.cloud-status.error { color: #f87171; }
.cloud-save-form { display: flex; flex-direction: column; gap: 12px; }
.cloud-save-form[hidden] { display: none; }
.cloud-field { display: flex; flex-direction: column; gap: 4px; }
.cloud-field span { font-size: 11px; color: var(--text-muted); }
.cloud-field input {
  padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  font-size: 13px; font-family: inherit;
}
.cloud-field input:focus { outline: none; border-color: var(--accent); }
.cloud-save-warning {
  padding: 8px 10px; border-radius: 6px;
  background: rgba(251, 191, 36, 0.10); color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3); font-size: 12px;
}
.cloud-save-actions { display: flex; justify-content: flex-end; gap: 8px; }
