/* ════════════════════════════════════════════════════════════════════════════
   HDRSAM tool page.

   Light dashboard: a warm off-white canvas with white surfaces floating on it,
   large corner radii, hairline borders and one saturated accent (Argonne blue)
   used sparingly. The landing page (landing.css) is deliberately dark -- the
   marketing page and the workspace are different rooms.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --nav-w:        236px;
  --header-h:      52px;
  --status-h:      32px;
  --shell-pad:     10px;

  --canvas:       #f3f7fb;   /* cool technical canvas                         */
  --card-bg:      #ffffff;   /* every floating surface                       */
  --surface-2:    #edf3f8;   /* table heads, inert pills, icon squares       */
  --ink:          #10243a;   /* primary text                                 */
  --muted:        #607286;
  --hairline:     #dce6ef;
  --ink-card:     #0b2b45;   /* the one high-contrast dark card              */

  --accent:       #0065a8;   /* Argonne blue                                 */
  --accent2:      #004b7a;
  --accent-soft:  #e2f2fb;   /* tinted fill behind the active nav item       */

  --danger:       #b91c1c;
  --warn:         #b35c00;
  --success:      #14805e;

  --radius:        14px;
  --radius-lg:     22px;
  --radius-pill:  999px;
  --shadow:       0 1px 2px rgba(16,36,58,0.04), 0 10px 28px rgba(16,36,58,0.07);

  /* Kept because a few older rules and inline styles still name them. */
  --border:       #e7e3de;
  --body-bg:      #f6f4f1;
  --sidebar-bg:   #ffffff;
  --sidebar-fg:   #14181f;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

/* ── App shell ────────────────────────────────────────────────────────────── */
/* Grid, not nested flex: the content column is minmax(0, 1fr) so a very wide
   detail table scrolls inside itself instead of squeezing the nav rail. */
.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: var(--shell-pad);
  height: 100dvh;
  padding: var(--shell-pad);
  background: var(--canvas);
  overflow: hidden;
}

.main-body {
  display: grid;
  grid-template-columns: clamp(200px, 16vw, var(--nav-w)) minmax(0, 1fr);
  gap: var(--shell-pad);
  min-height: 0;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  min-height: var(--header-h);
  background: linear-gradient(105deg, #061a2b 0%, #082f49 58%, #075985 100%);
  border: 1px solid #0b3552;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 15px;
  flex-shrink: 0;
  z-index: 20;
}

.header-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.header-logo { height: 27px; width: auto; display: block; }
.header-titles { display: flex; flex-direction: column; line-height: 1.15; }
.header-title {
  color: #fff; font-size: 14px; font-weight: 750; letter-spacing: 0.02em;
}
.header-sub {
  color: rgba(255,255,255,0.62); font-size: 11px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 320px;
}

/* Breadcrumb pill in the slot a search bar would occupy. Not an input -- it
   reports where you are; searching 22 fixed pages is not a feature this app
   has, and a decorative search box that does nothing is worse than none. */
.header-crumb {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  max-width: 420px;
  margin: 0 auto;
  padding: 7px 16px;
  background: rgba(255,255,255,0.10);
  border-radius: var(--radius-pill);
  color: rgba(255,255,255,0.72); font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-crumb svg { flex: none; opacity: 0.7; }
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }

.header-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 6px 11px; font-size: 11.5px; font-weight: 650; font-family: inherit;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.header-btn:hover { background: var(--accent2); }
.header-btn:disabled { opacity: 0.5; cursor: default; }
.header-btn.secondary {
  background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.20);
}
.header-btn.secondary:hover { background: rgba(255,255,255,0.16); }
.header-btn.quiet {
  background: transparent; color: rgba(255,255,255,0.72); border-color: transparent;
  padding: 8px 10px;
}
.header-btn.quiet:hover { color: #fff; background: rgba(255,255,255,0.10); }
.header-btn.danger { background: var(--danger); color: #fff; }
.header-btn.danger:hover { background: #991b1b; }

/* Signed-in chip. Lived in landing.css until the header went light -- it was
   white-on-translucent there, which is invisible on a white surface. */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 3px 9px 3px 3px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
}
.user-chip-avatar {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(140deg, #2b8cff, #24c8f0);
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.user-chip-name {
  color: #fff; font-size: 12.5px; font-weight: 600;
  max-width: 150px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── Status bar ───────────────────────────────────────────────────────────── */
.statusbar {
  height: var(--status-h);
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; gap: 9px;
  padding: 0 18px;
  font-size: 12px; color: var(--muted);
  flex-shrink: 0;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); flex: none;
}
.status-dot.running { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.dirty   { background: #f6a623; }
@keyframes pulse { 50% { opacity: 0.3; } }
.statusbar .dirty { color: var(--warn); font-weight: 600; }

/* ── Navigation rail ──────────────────────────────────────────────────────── */
.sidebar {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--ink);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px;
}
.nav-group { margin-bottom: 2px; }

/* Density is deliberate. There are now 21 items across 6 groups, which will not
   fit the ~805px rail all at once -- so "Detailed Calculations" (10 items) is
   closed by default and the rail scrolls if a user opens everything. */
.nav-group-label {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  background: transparent; border: none;
  border-radius: var(--radius);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
  font-family: inherit; text-align: left; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-group-label:hover { background: var(--surface-2); color: var(--ink); }
.nav-group-icon {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-2); color: var(--accent);
}
.nav-group-label:hover .nav-group-icon { background: var(--accent-soft); }
.nav-group-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-group-count {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0;
  color: var(--muted); opacity: 0.7;
}
.nav-chevron { flex: none; transition: transform 0.18s ease; color: var(--muted); }
.nav-group.open .nav-chevron { transform: rotate(90deg); }

/* 0fr -> 1fr animates the collapse without having to measure item heights. */
.nav-group-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.18s ease;
}
.nav-group.open .nav-group-body { grid-template-rows: 1fr; }
.nav-group-inner { overflow: hidden; min-height: 0; }

.nav-item {
  position: relative;
  display: block; width: 100%;
  padding: 4px 12px 4px 20px;
  margin-bottom: 1px;
  font-size: 12.5px; line-height: 17px;
  font-family: inherit; color: #3f4756;
  background: transparent; border: none;
  border-radius: var(--radius-pill);
  text-align: left; cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item:hover  { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, #dff3fb, #edf7ff); color: var(--accent); font-weight: 650;
}
.nav-item.active::before {
  content: ""; position: absolute; left: 8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 14px; border-radius: 2px; background: var(--accent);
}

/* ── Content area ─────────────────────────────────────────────────────────── */
.content-area {
  min-width: 0;
  overflow-y: auto; overflow-x: auto;
  padding: 2px 4px 24px;
  background: transparent;
}

/* ── Page title ───────────────────────────────────────────────────────────── */
.page-title {
  font-size: 21px; font-weight: 700; letter-spacing: -0.02em;
  margin: 2px 0 12px; color: var(--ink);
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
}
/* The original desktop menu string, kept as a quiet second line so a user who
   knows the Tkinter app can still find the page they mean. */
.page-sub {
  font-size: 12.5px; font-weight: 400; letter-spacing: 0;
  color: var(--muted);
}

/* ── Dirty banner ─────────────────────────────────────────────────────────── */
.dirty-banner {
  background: #fff8ec;
  border: 1px solid #f4e2c4;
  border-left: 3px solid #f6a623;
  border-radius: var(--radius);
  padding: 9px 14px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--warn);
  display: flex; align-items: center; gap: 8px;
}

/* ── Cards & panels ───────────────────────────────────────────────────────── */
.card, .panel {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  background-image: linear-gradient(180deg, rgba(255,255,255,1), rgba(251,253,255,0.96));
}
.panel { display: flex; flex-direction: column; min-width: 0; }

/* One rule serves every existing `<div className="card-title">` call site, so
   all ~30 of them restyle without touching any JSX. */
.card-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink); margin-bottom: 12px;
  min-height: 26px;
}
.card-title::before {
  content: ""; flex: none;
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--surface-2);
  background-image: radial-gradient(circle at 50% 50%, var(--accent) 3px, transparent 3.5px);
}
/* Opt out when a title already carries its own icon element. */
.card-title.plain::before { display: none; }
.card-title .spacer { flex: 1; }

.panel-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  background: var(--surface-2); border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 0; text-transform: none; white-space: nowrap;
}

/* ── Chart / View Data toggle ─────────────────────────────────────────────── */
/* Sits in a panel header and swaps the panel body in place, so a figure and its
   table occupy one box instead of two stacked ones. */
.seg {
  display: inline-flex; flex: none;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 2px;
}
.seg-btn {
  padding: 4px 12px;
  border: none; background: transparent;
  border-radius: var(--radius-pill);
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active {
  background: #fff; color: var(--accent);
  box-shadow: 0 1px 2px rgba(20,24,31,0.10);
}

/* ── In-page section tabs (Results Dashboard) ─────────────────────────────── */
.section-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  padding: 4px; margin-bottom: 12px;
}
.section-tab {
  padding: 7px 18px;
  border: none; background: transparent;
  border-radius: var(--radius-pill);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.section-tab:hover { background: var(--surface-2); color: var(--ink); }
.section-tab.active { background: var(--accent); color: #fff; }

/* ── Component tab pills (Loan Amortization) ──────────────────────────────── */
.tab-pills {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px;
}
.tab-pill {
  padding: 5px 13px;
  border: 1px solid var(--hairline); background: #fff;
  border-radius: var(--radius-pill);
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tab-pill:hover { background: var(--surface-2); color: var(--ink); }
.tab-pill.active {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}

.section-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }

.scenario-top-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.85fr) minmax(170px, 0.85fr)
                         minmax(145px, 0.7fr) minmax(300px, 1.6fr);
  align-items: stretch;
}
.scenario-top-grid > .card { margin-bottom: 0; min-width: 0 !important; }
.refueling-definition-card .field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.refueling-definition-card .field-row:last-child { margin-bottom: 0; }
.refueling-definition-card .field-label {
  min-width: 0; max-width: none;
  color: #000; font-weight: 600;
}
.refueling-definition-card .field-select { width: 100%; color: #000; }

.section-row.scenario-main-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.95fr) minmax(420px, 1.05fr);
  align-items: start;
}
.scenario-input-stack {
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.scenario-input-stack > .card { margin-bottom: 0; }
.scenario-input-stack .field-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 118px 32px;
  gap: 10px; align-items: center;
}
.scenario-input-stack .field-label { min-width: 0; max-width: none; }
.scenario-input-stack .field-select,
.scenario-input-stack .field-input { width: 118px; }
.hourly-profile-card { min-width: 0; margin-bottom: 0; }

/* Two-column panel grid, the reference's main content rhythm. */
.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.panel-grid > .panel, .panel-grid > .card { margin-bottom: 0; }
.panel-grid.narrow-first { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); }
/* Three short label/value panels side by side — the Station Design tab. */
.panel-grid.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1400px) {
  .panel-grid.thirds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1150px) {
  .panel-grid, .panel-grid.thirds { grid-template-columns: minmax(0, 1fr); }
}
/* narrow-first stacks earlier than the even split: its second column carries a
   7-column table, and 360px off the top of a 1366px window leaves that table
   too little room to lay out without scrolling. */
@media (max-width: 1500px) {
  .panel-grid.narrow-first { grid-template-columns: minmax(0, 1fr); }
  /* Stacked, the first panel spans the full width. Rein its chart back in so a
     doughnut is not a small circle adrift in a 1000px box. align-self, not auto
     margins: the frame's only child is an absolutely-positioned canvas, so it
     has no intrinsic width and auto margins would shrink it to zero. */
  .panel-grid.narrow-first > :first-child .chart-frame {
    width: 100%; max-width: 420px; align-self: center;
  }
}

/* ── KPI hero ─────────────────────────────────────────────────────────────── */
.kpi-hero {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(0, 1fr);
  gap: 22px; align-items: center;
}
.persistent-kpi {
  grid-template-columns: minmax(205px, 235px) minmax(640px, 1fr);
  gap: 14px;
  min-height: 116px;
  margin-bottom: 0;
  padding: 11px 14px 11px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  background: linear-gradient(120deg, #0a3d6b 0%, #0065a8 42%, #0099b8 100%);
  border-color: transparent;
  box-shadow: 0 4px 24px rgba(0, 80, 140, 0.28);
}
.persistent-kpi-primary { position: relative; min-width: 205px; }
.persistent-kpi .kpi-hero-label { margin-bottom: 3px; color: rgba(255,255,255,0.70); }
.persistent-kpi .kpi-hero-value { font-size: 38px; color: #ffffff; }
.persistent-kpi .kpi-frac { color: rgba(255,255,255,0.60); }
.persistent-kpi .kpi-hero-unit { margin-top: 3px; font-size: 11.5px; color: rgba(255,255,255,0.65); }
.persistent-kpi .kpi-strip {
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  min-width: 640px;
  gap: 8px;
}
.persistent-kpi .stat-card {
  padding: 9px 12px;
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
}
.persistent-kpi .stat-label { color: rgba(255,255,255,0.68); }
.persistent-kpi .stat-value { font-size: 17px; color: #ffffff; }
.persistent-kpi .stat-unit { font-size: 10.5px; color: rgba(255,255,255,0.55); }
.persistent-kpi .stat-card.dark {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.30);
}
.persistent-kpi.empty .kpi-hero-value { color: rgba(255,255,255,0.40); }
.persistent-kpi.empty .stat-value { color: rgba(255,255,255,0.40); }
.kpi-details-btn {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 5px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  font: 650 11px/1 'Segoe UI', Arial, sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.kpi-details-btn:hover { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.60); }
.persistent-kpi-status {
  display: inline-block;
  margin-left: 7px;
  color: #fde68a;
  font-size: 10.5px; font-weight: 650;
}
.kpi-hero-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); margin-bottom: 6px;
}
.kpi-hero-value {
  font-size: 42px; font-weight: 700;
  letter-spacing: -0.035em; line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
/* De-emphasized decimals, as in the reference's $528,976.82 */
.kpi-frac { color: var(--muted); font-weight: 600; }
.kpi-hero-unit { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 14px;
  min-width: 0;
}
.stat-card.dark {
  background: var(--ink-card); border-color: var(--ink-card); color: #fff;
}
.stat-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-card.dark .stat-label { color: rgba(255,255,255,0.62); }
.stat-value {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.stat-card.dark .stat-value { color: #fff; }
.stat-unit { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat-card.dark .stat-unit { color: rgba(255,255,255,0.55); }

@media (max-width: 1000px) {
  .kpi-hero { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .persistent-kpi {
    grid-template-columns: minmax(205px, 235px) minmax(640px, 1fr);
    gap: 14px;
  }
}

/* ── KPI tiles (legacy row, still used by the utilization page) ───────────── */
.kpi-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.kpi-tile {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 200px; flex: 1;
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 7px;
}
.kpi-value {
  font-size: 26px; font-weight: 700; letter-spacing: -0.025em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.kpi-unit { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Form controls ────────────────────────────────────────────────────────── */
.field-row {
  display: flex; align-items: center;
  margin-bottom: 9px; gap: 10px;
}
.field-label {
  min-width: 380px; max-width: 480px;
  font-size: 13px; color: #3f4756;
  flex-shrink: 0;
}
.field-label.narrow { min-width: 240px; }

/* ── Grouped input pages ──────────────────────────────────────────────────── */
/* Two columns of fields once there is room for them; the grid track, not a
   380px min-width on the label, is what reserves space for long label text. */
.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 2px;
  max-width: 980px;
}
.field-grid > .field-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(140px, 180px) 32px;
  gap: 12px; align-items: center;
  margin-bottom: 0;
  padding: 5px 0;
  min-width: 0;
}
.field-grid > .field-row .field-label {
  min-width: 0; max-width: none; flex: 1;
}
.field-grid > .field-row .field-input,
.field-grid > .field-row .field-select { width: 100%; flex: none; }
/* Radios carry long questions and, on the CAPEX pages, an inline override
   block, so they stay full width above the grid. */
.radio-stack { margin-bottom: 4px; }
.input-radio-block { margin-bottom: 12px; }
.input-radio-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(140px, 180px) 32px;
  gap: 12px; align-items: center;
  max-width: 980px;
}
.input-radio-row > span:first-child { max-width: none !important; }
.radio-stack + .field-grid { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.group-card:last-child { margin-bottom: 20px; }
.field-input {
  width: 118px; height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-size: 13px; font-family: inherit; color: var(--ink);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-input.readonly {
  background: var(--surface-2); color: var(--muted);
  border-color: var(--hairline); cursor: default;
}
.field-select {
  height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-size: 13px; font-family: inherit; color: var(--ink);
  background: #fff; cursor: pointer;
}
.field-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex: none;
}
.field-hint-trigger {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  cursor: help;
}
.field-hint-trigger:hover,
.field-hint-trigger:focus-visible { background: var(--surface-2); color: var(--ink); outline: none; }
.field-hint-trigger svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.field-hint-pop {
  position: absolute;
  left: 50%; bottom: calc(100% + 7px);
  z-index: 80;
  width: 240px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: 11.5px; font-weight: 400; line-height: 1.45;
  text-align: left;
  box-shadow: 0 10px 26px rgba(20,24,31,0.24);
  transform: translateX(-50%) translateY(3px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}
.field-hint:hover .field-hint-pop,
.field-hint:focus-within .field-hint-pop {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.radio-group { display: flex; gap: 14px; flex-wrap: wrap; }
.radio-label {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 13px;
}
.radio-label input { cursor: pointer; accent-color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary {
  background: var(--card-bg); color: var(--ink); border-color: var(--hairline);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #14532d; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn:disabled  { opacity: 0.45; cursor: default; }
.row-delete-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border: none; border-radius: 6px;
  background: transparent; color: #9ca3af;
  font-size: 12px; cursor: pointer; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.row-delete-btn:hover { background: #fee2e2; color: var(--danger); }
.btn-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.unsaved-badge {
  display: inline-flex; align-items: center;
  padding: 7px 12px;
  border: 1px solid #f2c978;
  border-radius: var(--radius-pill);
  background: #fff8e7;
  color: #945400;
  font-size: 12px; font-weight: 650;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table-wrap {
  overflow: auto;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: #fff;
}
table.data-table {
  width: max-content; min-width: 460px;
  border-collapse: separate; border-spacing: 0; font-size: 13px;
}
/* A floor under the label column. Without it a narrow panel squeezes a long
   row label ("Refueling Station Portion of the Real Levelized Delivered
   Hydrogen Cost") down to one word per line instead of letting the wrap scroll. */
table.data-table th:first-child,
table.data-table td:first-child { min-width: 190px; }
/* Sticky head: several detail tables run to 60+ rows inside a scrolling wrap. */
table.data-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--muted);
  padding: 10px 13px; text-align: left;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap; font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
}
.table-mode-label {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
}
table.data-table td {
  padding: 8px 13px;
  border-bottom: 1px solid #f2f0ed;
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #faf9f7; }
table.data-table td.bold-label { font-weight: 700; padding-left: 10px; }
table.data-table td.indent-label { padding-left: 28px; color: var(--muted); }
table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table th.year,
table.data-table td.year {
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Compact variant, for the wide grids: the DCF matrix, the cash-flow statement
   and the label/value detail tables. Same rules, tighter metrics. */
table.data-table.compact { font-size: 12.5px; }
table.data-table.compact th { padding: 7px 10px; font-size: 10.5px; }
table.data-table.compact td { padding: 6px 10px; }
table.data-table.compact td.indent-label { padding-left: 22px; }

/* Section header inside a label/value table -- buildRows already flags these
   with `bold`, and LabelValueTable turns them into a full-width row. */
table.data-table tr.group-row td {
  background: var(--surface-2);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
  padding-top: 7px; padding-bottom: 7px;
}
table.data-table tr.group-row:hover td { background: var(--surface-2); }

/* Closing row of a table -- a station total or a column sum. */
table.data-table tr.total-row td {
  font-weight: 700; color: var(--ink);
  border-top: 1px solid var(--hairline);
  background: #fbfaf9;
}
table.data-table td.neg { color: var(--danger); }
table.data-table tr.selected-row td { background: #eef5ff; }

/* A wide table stays readable when scrolled sideways if its first column
   travels with it. Needs an opaque background or the cells show through. */
.data-table-wrap.sticky-first table.data-table th:first-child,
.data-table-wrap.sticky-first table.data-table td:first-child {
  position: sticky; left: 0; z-index: 1;
  background: #fff;
  box-shadow: inset -1px 0 0 var(--hairline);
}
.data-table-wrap.sticky-first table.data-table th:first-child {
  z-index: 3; background: var(--surface-2);
}
.data-table-wrap.sticky-first table.data-table tr.group-row td:first-child { background: var(--surface-2); }
.data-table-wrap.sticky-first table.data-table tr.total-row td:first-child { background: #fbfaf9; }
.data-table-wrap.sticky-first table.data-table tr:hover td:first-child { background: #faf9f7; }
table.data-table td.editable {
  cursor: pointer;
  background: #f2faf3; box-shadow: inset 2px 0 0 #bfe5c6;
}
table.data-table td.editable:hover { background: #e4f6e7; }

/* Numeric pill, the reference's table treatment: quiet fill for a value, dark
   fill for the one that matters most in the row. */
.num-pill {
  display: inline-block; min-width: 62px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--ink);
  font-size: 12px; font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums;
}
.num-pill.dark { background: var(--ink-card); color: #fff; }

/* inline cell editor */
.inline-edit {
  width: 100%; padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 8px; font-size: 13px; font-family: inherit;
  outline: none; box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Chart containers ─────────────────────────────────────────────────────── */
/* Charts run with maintainAspectRatio:false, so this frame owns the height and
   nothing reflows when the nav rail collapses. Every chart must sit inside one
   -- a Chart.js canvas with no sized parent renders zero pixels tall. */
.chart-frame {
  position: relative; height: 250px; min-width: 0;
  padding: 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f5faff 100%);
}
.chart-frame.tall { height: 300px; }
.chart-frame canvas { position: absolute; inset: 0; }

/* ── Hourly demand table ──────────────────────────────────────────────────── */
.hourly-table-wrap { max-height: 420px; overflow-y: auto; width: 100%; }
.hourly-table-wrap .data-table { width: 100%; min-width: 0; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 14px; font-size: 13px;
  border: 1px solid transparent; border-left-width: 3px;
}
.alert-error   { background: #fef3f3; border-color: #f3d5d5; border-left-color: var(--danger);  color: var(--danger); }
.alert-success { background: #f1faf3; border-color: #cfe9d6; border-left-color: var(--success); color: var(--success); }
.alert-warn    { background: #fff8ec; border-color: #f4e2c4; border-left-color: #f6a623;        color: var(--warn); }
.alert-info    { background: #eef5fb; border-color: #d5e5f3; border-left-color: var(--accent);  color: #1d5183; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; top: 84px; right: 26px; z-index: 999;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; color: #fff;
  box-shadow: 0 10px 30px rgba(20,24,31,0.22);
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warn    { background: #b45309; }
.toast-info    { background: var(--accent); }

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d8d3cc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #c3bcb3; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .header-sub { display: none; }
  .header-crumb { max-width: 240px; }
  .scenario-top-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-row.scenario-main-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  :root { --nav-w: 210px; }
  .field-label { min-width: 200px; }
  .header-crumb { display: none; }
  .user-chip-name { display: none; }
  .field-grid > .field-row,
  .input-radio-row,
  .scenario-input-stack .field-row {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 160px) 32px;
  }
}

/* ── Run history ─────────────────────────────────────────────────────────── */
.run-history-panel { margin-bottom: 12px; }
.history-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted); font-size: 11.5px;
}
.history-table-wrap { width: 100%; max-height: 260px; }
table.history-table { width: 100%; min-width: 680px; }
table.history-table th:first-child,
table.history-table td:first-child { min-width: 42px; width: 42px; }
table.history-table .check-col { text-align: center; }
table.history-table input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
table.data-table .check-col { text-align: center; min-width: 38px; width: 38px; }
table.data-table .check-col input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.empty-history {
  color: var(--muted); font-size: 12.5px;
  padding: 9px 2px 3px;
}

/* Browser zoom changes the effective CSS viewport. These breakpoints keep the
   workspace proportional at high zoom instead of forcing fixed-width columns
   and controls to overlap. */
@media (max-width: 1200px) {
  .user-chip-name { display: none; }
  .header-btn { padding-inline: 9px; }
  .scenario-top-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-row.scenario-main-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 780px) {
  :root { --shell-pad: 7px; }
  .app-shell { overflow: hidden; }
  .header {
    align-content: center; flex-wrap: wrap;
    padding-block: 7px;
  }
  .header-actions {
    width: 100%; justify-content: flex-end; flex-wrap: wrap;
  }
  .main-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(110px, 155px) minmax(0, 1fr);
  }
  .sidebar { max-height: 155px; }
  .content-area { overflow-x: hidden; }
  .scenario-top-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card, .panel { padding: 12px 14px; }
}

@media (max-width: 560px) {
  .header-logo { height: 23px; }
  .header-btn { font-size: 10.5px; padding: 5px 8px; }
  .user-chip { padding-right: 3px; }
  .header-btn.quiet { padding-inline: 6px; }
  .scenario-input-stack .field-row,
  .field-grid > .field-row,
  .input-radio-row {
    grid-template-columns: minmax(0, 1fr) 32px;
  }
  .scenario-input-stack .field-label,
  .field-grid > .field-row .field-label,
  .input-radio-row > span:first-child { grid-column: 1 / -1; }
  .scenario-input-stack .field-input,
  .scenario-input-stack .field-select,
  .field-grid > .field-row .field-input,
  .field-grid > .field-row .field-select { width: 100%; }
  .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  table.data-table { min-width: 420px; }
  .statusbar { padding-inline: 12px; }
}
