/* ============================================================
   Flex Simulator mockup — visual language lifted from the existing
   Next.js app (src/app/globals.css + components.css).
   Bootstrap 5.3 is used for grid/offcanvas/modal mechanics only;
   we override the defaults heavily so the look matches Flex.
   ============================================================ */

:root {
  /* lifted verbatim from src/app/globals.css */
  --background: #FAFAFA;
  --foreground: #ffffff;
  --primary: #262626;
  --secondary: #616366;
  --tertiary: #303233;
  --heading: #222222;
  --neutral-500: #737373;
  --surface-invert: #181919;
  --blue: #1690d0;
  --text-blue: #1273a6;
  --blue-secondary: #a2d3ec;
  --blue-light: #e8f4fa;
  --grid-gray: #E5E7EB;
  --light-gray: #bdbec0;
  --light-gray-bg: #f6f6f7;
  --button-secondary: #EAEAEB;
  --button-hover-minimal: rgba(0, 0, 0, 0.10);

  /* Bootstrap variable overrides so default Bootstrap components inherit the look */
  --bs-body-bg: var(--background);
  --bs-body-color: var(--primary);
  --bs-body-font-family: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --bs-border-radius: 0;
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: 0;
  --bs-border-radius-xl: 0;
  --bs-border-radius-pill: 9999px;
  --bs-primary: var(--blue);
  --bs-primary-rgb: 22, 144, 208;
  --bs-link-color: var(--text-blue);
  --bs-link-hover-color: var(--blue);
  --bs-border-color: var(--light-gray);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Source Sans 3", system-ui, -apple-system, sans-serif;
  background: var(--background);
  color: var(--primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Sharp corners everywhere */
.btn, .card, .form-control, .form-select, .input-group-text,
.dropdown-menu, .modal-content, .offcanvas, .alert, .badge,
.list-group-item, .progress, .toast, .tooltip-inner, .popover {
  border-radius: 0 !important;
}

/* Typography */
h1, .h1 { font-size: 2.25rem; font-weight: 600; color: var(--heading); letter-spacing: -0.01em; }
h2, .h2 { font-size: 1.5rem; font-weight: 600; color: var(--heading); }
h3, .h3 { font-size: 1.25rem; font-weight: 600; color: var(--heading); }
h4, .h4 { font-size: 1rem;    font-weight: 600; color: var(--heading); }
.text-secondary { color: var(--secondary) !important; }
.text-tertiary  { color: var(--tertiary); }
.text-primary-fx { color: var(--primary); }
.text-blue { color: var(--blue) !important; }
.text-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--secondary);
}

/* Buttons — flat, sharp, single accent */
.btn {
  font-weight: 600;
  border-radius: 0;
  padding: 0.625rem 1.25rem;
  border-width: 1px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.btn-blue {
  background: var(--blue);
  color: var(--foreground);
  border: 1px solid var(--blue);
}
.btn-blue:hover, .btn-blue:focus {
  background: var(--text-blue);
  border-color: var(--text-blue);
  color: var(--foreground);
}
.btn-outline-dark {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline-dark:hover {
  background: var(--primary);
  color: var(--foreground);
}
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--button-hover-minimal); }

/* Outlined card pattern (matches the existing onboarding cards) */
.fx-card {
  background: var(--foreground);
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  padding: 1.5rem;
  transition: outline-color 200ms ease;
}
.fx-card.focusable:hover,
.fx-card.focusable.active {
  outline-color: var(--blue);
  cursor: pointer;
}

/* Form fields — line input pattern from components.css (.big-line-input) */
.fx-input-line {
  border: none;
  border-bottom: 1px solid var(--light-gray);
  background: transparent;
  padding: 0.5rem 0;
  width: 100%;
  font-size: 1rem;
  color: var(--primary);
  outline: none;
}
.fx-input-line:hover  { border-bottom-color: var(--blue); }
.fx-input-line:focus  { border-bottom: 2px solid var(--blue); padding-bottom: calc(0.5rem - 1px); }
.fx-input-line::placeholder { color: var(--light-gray); }
/* A line-styled select: native menu, our chevron, placeholder-grey until a choice is made */
select.fx-select {
  appearance: none; -webkit-appearance: none;
  padding-right: 1.75rem; cursor: pointer; border-radius: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23555' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 0.25rem center;
}
select.fx-select:has(option:checked[value=""]) { color: var(--light-gray); }
select.fx-select option { color: var(--primary); }

.fx-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 0.25rem;
}

/* Chip / popover-chip pattern from components.css */
.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--button-secondary);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: background 120ms ease, color 120ms ease;
}
.fx-chip:hover  { background: #dfdfe0; }
.fx-chip.active { background: var(--blue); color: var(--foreground); }

/* ============================================================
   App header — left logo, centered step indicator, right utilities
   Modeled on the existing sidebar+toolbar layout but flattened
   into a single top bar for the wizard flow.
   ============================================================ */
.fx-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* the stepper sits dead centre whatever flanks it */
  align-items: center;
  padding: 0 1.5rem;
  background: var(--foreground);
  border-bottom: 1px solid var(--light-gray);
  height: 60px;
}
.fx-header__logo { display: flex; align-items: center; justify-self: start; }
.fx-header__logo img { height: 28px; display: block; }
.fx-header__right { display: flex; align-items: center; gap: 0.5rem; justify-self: end; }

/* Step indicator — three steps Info → Build → Sim */
.fx-stepper {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.fx-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--secondary);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  position: relative;
}
.fx-step__num {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--light-gray);
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 700;
}
.fx-step.active { color: var(--primary); }
.fx-step.active .fx-step__num {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--foreground);
}
.fx-step.done .fx-step__num {
  background: var(--foreground);
  border-color: var(--blue);
  color: var(--blue);
}
.fx-step.done { color: var(--primary); cursor: pointer; }
.fx-step.upcoming { opacity: 0.55; pointer-events: none; }
.fx-step__divider {
  width: 24px;
  height: 1px;
  background: var(--light-gray);
}

/* Busy feedback — a control that has started something slow says so in place, and the
   page shows a thin progress bar under the header from the moment a navigation begins */
.fx-spinner {
  display: inline-block; width: 1em; height: 1em; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -0.15em;
  animation: fx-spin 0.7s linear infinite;
}
@keyframes fx-spin { to { transform: rotate(360deg); } }
[aria-busy="true"] { cursor: progress; }
body.fx-navigating::before {
  content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 100;
  background: linear-gradient(90deg, transparent, var(--blue) 40%, var(--blue) 60%, transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: fx-progress 1.1s ease-in-out infinite;
}
@keyframes fx-progress { from { background-position: -40% 0; } to { background-position: 140% 0; } }
/* A file input whose chosen file is uploading says so over the control itself */
.fx-upload { position: relative; }
.fx-upload__busy {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: rgba(255, 255, 255, 0.85); color: var(--secondary); font-size: 0.875rem;
}
.fx-upload__busy[hidden] { display: none; }
/* A canvas that is still loading its sprites says so over the empty ground */
.fx-canvas-loading {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--foreground); color: var(--secondary); font-size: 0.875rem;
}

/* Page-level shell */
.fx-page {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}
.fx-page__body { flex: 1; }
.fx-page__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--light-gray);
  background: var(--foreground);
}

/* ============================================================
   Info page — one dynamic screen. The two-image Fleet-vs-Public hero is the page: the
   chosen use case's image stays lit, the other image and the choice cards collapse, and
   the form takes the space they give up (fx-hero--fleet / fx-hero--public on the grid).
   ============================================================ */
.fx-info { background: var(--foreground); }
.fx-hero {
  display: grid;
  /* The choice hugs its cards (the images come right up to them at any width). Every state
     keeps the same track shapes — fr tracks at the sides, minmax(<length>, <length-percentage>)
     in the middle — so grid-template-columns tweens between them instead of snapping. */
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px) minmax(0, 1fr);
  height: calc(100vh - 60px);
  background: var(--foreground);
  transition: grid-template-columns 500ms ease;
}
/* Chosen: the kept image holds its width (50% - 230px, the same as in the choice state) while
   the other image tweens to nothing and the form takes over its space plus the middle. */
.fx-hero--fleet  { grid-template-columns: minmax(0, 1fr) minmax(0, calc(50% + 230px)) minmax(0, 0fr); }
.fx-hero--public { grid-template-columns: minmax(0, 0fr) minmax(0, calc(50% + 230px)) minmax(0, 1fr); }
.fx-hero__panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
.fx-hero__panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  transition: opacity 600ms ease;
}
.fx-hero__panel.focused::after,
.fx-hero--fleet #hero-fleet::after,
.fx-hero--public #hero-public::after { opacity: 0; }
.fx-hero__panel-label {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  color: var(--foreground);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap;
}
.fx-hero--fleet #hero-public .fx-hero__panel-label,
.fx-hero--public #hero-fleet .fx-hero__panel-label { display: none; }

/* The middle column: the choice, then the chosen use case's form (scrolls on its own).
   Horizontal overflow is clipped, never scrolled: the choice cards' connectors reach 40px
   past the cards to meet the images, and on Windows even a pixel of sideways overflow
   would draw a horizontal scrollbar under the column. */
.fx-hero__middle {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  background: var(--foreground);
}
.fx-hero--fleet .fx-hero__middle,
.fx-hero--public .fx-hero__middle { justify-content: flex-start; padding: 0; gap: 0; }
.fx-hero__choice-block { display: flex; flex-direction: column; gap: 1.5rem; width: 100%; max-width: 460px; margin: 0 auto; }
.fx-hero--fleet .fx-hero__choice-block,
.fx-hero--public .fx-hero__choice-block { display: none; }
.fx-hero__form { display: none; }
.fx-hero--fleet .fx-hero__form,
.fx-hero--public .fx-hero__form { display: block; animation: fx-fade-in 400ms ease 180ms both; }
@keyframes fx-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
/* Sections group by proximity: the space above a title is well over the space between the
   title and its own fields, so each header reads with what follows it, not what precedes. */
.fx-hero__form .fx-section { max-width: 880px; margin: 0 auto; padding: 3.25rem 2.5rem 0; }
/* Outranks the page-level `.fx-section + .fx-section { padding-top: 0 }` that follows below. */
.fx-hero__form .fx-section + .fx-section { padding-top: 3.25rem; }
.fx-hero__form .fx-section:first-child { padding-top: 2.5rem; }
.fx-hero__form .fx-section:first-child + .fx-section { padding-top: 2.25rem; }
.fx-hero__form .fx-section__title { margin-bottom: 0.125rem; }
.fx-hero__form .fx-grid-2 { row-gap: 2.25rem; }   /* a label sits with its own field, not the one above */
.fx-required::after { content: " *"; color: #c0392b; font-weight: 700; }
.fx-continue-hint { text-align: center; margin-top: 0.75rem; font-size: 0.8125rem; }
.fx-hero__form .fx-section__hint { margin-bottom: 1.125rem; }
.fx-hero__form .fx-section--actions { padding-top: 3rem; padding-bottom: 3rem; }
.fx-continue {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.fx-hero__title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.15;
}
.fx-hero__subtitle {
  color: var(--secondary);
  font-size: 0.95rem;
}
.fx-hero__choice {
  position: relative;
  padding: 1.5rem;
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: outline-color 200ms ease;
}
.fx-hero__choice:hover, .fx-hero__choice.active { outline-color: var(--blue); }
.fx-hero__choice-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--tertiary);
}
.fx-hero__choice-desc {
  font-size: 0.875rem;
  color: var(--secondary);
}
.fx-hero__bolt {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #31beef;
  border-radius: 9999px;
  opacity: 0;
  transition: opacity 200ms ease;
}
.fx-hero__choice:hover .fx-hero__bolt,
.fx-hero__choice.active .fx-hero__bolt { opacity: 1; }
.fx-hero__connector {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 1px;
  background: var(--light-gray);
  transition: background 200ms ease;
}
.fx-hero__choice:hover .fx-hero__connector,
.fx-hero__choice.active .fx-hero__connector { background: var(--blue); }
.fx-hero__connector.left  { left: -40px; }
.fx-hero__connector.right { right: -40px; }

/* The per-use-case answers (the legacy onboarding questions) */
.fx-choice-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.fx-choice-card {
  padding: 1rem;
  background: var(--foreground);
  outline: 2px solid var(--button-secondary);
  outline-offset: -2px;
  cursor: pointer;
  transition: outline-color 150ms ease, background 150ms ease;
}
.fx-choice-card:hover { background: rgba(0, 0, 0, 0.04); }
.fx-choice-card.active { outline-color: var(--blue); }
.fx-choice-card__title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tertiary);
  margin-bottom: 0.25rem;
}
.fx-choice-card__desc { font-size: 0.75rem; color: var(--primary); line-height: 1.35; }
.fx-schedule-detail { margin-top: 1.25rem; }
.fx-note {
  padding: 0.75rem;
  background: var(--light-gray-bg);
  color: var(--tertiary);
  font-size: 0.75rem;
  margin-bottom: 1rem;
}
.fx-field-hint { font-size: 0.75rem; color: var(--secondary); margin-top: 0.375rem; }
.fx-fleet-rows { max-width: 460px; }
.fx-fleet-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  align-items: end;
  gap: 1rem;
  padding: 0.375rem 0;
}
.fx-fleet-row__label { font-size: 1rem; color: var(--primary); margin: 0; padding-bottom: 0.5rem; }
.fx-fleet-row__class { font-size: 0.75rem; color: var(--secondary); margin-left: 0.375rem; }
.fx-fleet-row--total { border-top: 1px solid var(--button-secondary); margin-top: 0.5rem; padding-top: 0.75rem; }
.fx-fleet-row--total .fx-fleet-row__label,
.fx-fleet-row--total .fx-fleet-row__count { font-weight: 600; padding-bottom: 0; }
.fx-check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; color: var(--primary); cursor: pointer; }
.fx-check .form-check-input { margin: 0; border-radius: 0; }

@media (max-width: 900px) {
  .fx-hero, .fx-hero--fleet, .fx-hero--public { grid-template-columns: 1fr; height: auto; }
  .fx-hero__panel { height: 220px; }
  .fx-hero--fleet #hero-public, .fx-hero--public #hero-fleet { display: none; }
  .fx-hero__middle { overflow: visible; }
  .fx-choice-cards { grid-template-columns: 1fr; }
}

/* Form sections (Step 1 body when a choice has been made) */
.fx-section {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}
.fx-section + .fx-section { padding-top: 0; }
.fx-section__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 0.25rem;
}
.fx-section__hint {
  color: var(--secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}
.fx-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2rem;
}
@media (max-width: 720px) {
  .fx-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   Build screen — the canvas fills the viewport under a docked top bar laid out like the
   shared fx-header (logo · Info → Build → Sim stepper · Run Simulation and the actions);
   the panel selector and the canvas tools sit in a floating sidebar at the top left, the
   338px panel slides in beside it, CountInput +/− steppers in the Configuration panel.
   ============================================================ */

/* The whole build area is positioned relative to the viewport; the top bar's height and the
   tool sidebar's width are the two numbers the canvas, the panel and the sidebar key off. */
.fx-build-shell {
  --fx-bheader-h: 60px;   /* the shared fx-header's height */
  --fx-btoolbar-w: 72px;   /* 60px buttons + the section padding */
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--foreground);
}

/* Docked top bar — full width, the canvas starts underneath it. Same metrics as fx-header
   (60px, 28px logo, 1.5rem side padding); a 1fr · auto · 1fr grid keeps the stepper dead
   centre however wide the action group on the right is. */
.fx-bheader {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--fx-bheader-h);
  z-index: 10;
}
.fx-bheader__inner {
  background: var(--foreground);
  border-bottom: 1px solid var(--light-gray);
  height: 100%;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.fx-bheader__logo { display: flex; align-items: center; justify-self: start; }
.fx-bheader__logo img { height: 28px; width: auto; display: block; }
.fx-bheader__right {
  display: flex; align-items: center; gap: 1.5rem; justify-self: end;
}

/* Panel selector (Requirements / Configuration / Insights) — the sidebar's first section,
   styled like the tool buttons below it */
.fx-bnav {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.125rem;
}
.fx-bnav__item {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 2px;
  width: 60px;
  padding: 0.3125rem 0.25rem;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.625rem;
  font-weight: 600;
  text-decoration: none;
  background: transparent;
  border: 0;
}
.fx-bnav__item .material-symbols-outlined { font-size: 22px; }
.fx-bnav__item:hover { color: var(--blue); }
.fx-bnav__item.active { color: var(--blue); }
.fx-bnav__item.active::after {
  content: ""; display: block; width: 24px; height: 2px; background: var(--blue); margin-top: 2px;
}

/* Floating sidebar (panel selector · Undo/Redo · Zoom · Show/Hide toggles · Branding) — a
   vertical palette hung at the top left under the bar; the slide-in panel opens to its
   right, sliding out from BEHIND the sidebar (its z-index sits above the panel's 15). */
.fx-btoolbar {
  position: fixed;
  left: 1.5rem;
  top: calc(var(--fx-bheader-h) + 1.5rem);
  width: var(--fx-btoolbar-w);
  z-index: 16;
  display: flex; flex-direction: column; align-items: stretch;
  background: var(--foreground);
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  box-shadow: 0 2px 4px -1px rgba(0,0,0,0.06), 0 4px 6px 1px rgba(0,0,0,0.10);
  max-height: calc(100vh - var(--fx-bheader-h) - 3rem);
  overflow-y: auto;
  scrollbar-width: thin;
}
.fx-btoolbar__section {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.125rem;
  padding: 0.375rem;
}
.fx-btoolbar__section + .fx-btoolbar__section {
  border-top: 1px solid var(--grid-gray);
}
.fx-btoolbar__btn {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 2px;
  width: 60px;
  padding: 0.3125rem 0.25rem;
  background: transparent; border: 0;
  color: var(--primary); cursor: pointer;
  font-size: 0.625rem; font-weight: 600;
}
.fx-btoolbar__btn .material-symbols-outlined { font-size: 22px; }
.fx-btoolbar__btn span:last-child { text-align: center; line-height: 1.15; }   /* "Show labels" wraps to two lines */
.fx-btoolbar__btn.active { color: var(--blue); }
.fx-btoolbar__btn:hover { color: var(--blue); }
.fx-btoolbar__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fx-btoolbar__btn:disabled:hover { color: var(--primary); }

/* Big "Run Simulation" pill (top-right) */
.fx-run-sim {
  background: var(--blue);
  color: var(--foreground);
  border: 0;
  padding: 0.5rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 0.5rem;
  cursor: pointer;
  height: 40px;
}
.fx-run-sim:hover { background: var(--text-blue); }
.fx-run-sim .material-symbols-outlined { font-size: 18px; }

/* Action icon buttons (Save / Share / Download / Speak to an expert) — the Build bar's, and
   the Sim page's header actions reuse them */
.fx-bactions { display: flex; align-items: center; gap: 0.25rem; }
.fx-baction {
  width: 40px; height: 40px;
  border-radius: 9999px;
  border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary); cursor: pointer;
  text-decoration: none;
}
.fx-baction:hover { background: var(--button-hover-minimal); }
.fx-baction .material-symbols-outlined { font-size: 22px; }

/* Left slide-in panel — mirrors src/modules/layout/left-panel, hung under the top bar and
   opening beside the tool sidebar so the tools stay reachable while it is open. */
.fx-bpanel {
  position: fixed;
  top: calc(var(--fx-bheader-h) + 1.5rem);
  bottom: 1.5rem;  /* bottom-6 */
  width: 338px;
  z-index: 15;
  background: var(--foreground);
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  box-shadow: 0 2px 4px -1px rgba(0,0,0,0.06), 0 4px 6px 1px rgba(0,0,0,0.10);
  display: flex; flex-direction: column;
  transition: left 300ms ease-in-out;
  left: -338px;
}
.fx-bpanel.open { left: calc(1.5rem + var(--fx-btoolbar-w) + 1rem); }

.fx-bpanel__head {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--button-secondary);
  display: flex; align-items: center; gap: 1rem;
}
.fx-bpanel__title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--heading);
  line-height: 1.3;
}
.fx-bpanel__close {
  width: 28px; height: 28px;
  border-radius: 9999px;
  background: var(--button-secondary);
  border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.fx-bpanel__close:hover { background: var(--light-gray); }
.fx-bpanel__close .material-symbols-outlined { font-size: 16px; }
.fx-bpanel__body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Configuration / Requirements section blocks inside the panel */
.fx-bsection {
  padding: 1.5rem;
  background: var(--foreground);
  border-bottom: 1px solid #d4d4d4; /* neutral-300 in the original */
}
.fx-bsection:last-child { border-bottom: 0; }
.fx-bsection__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.fx-bsection__title {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--heading);
  line-height: 1.4;
}
.fx-bsection__hint {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9999px;
  background: var(--button-secondary);
  color: var(--secondary);
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: help;
}

/* CountInput row — label + 120x48 stepper */
.fx-count-row {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0;
}
.fx-count-row__label {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tertiary);
  line-height: 1.4;
}
.fx-count {
  width: 120px; height: 48px;
  border-bottom: 1px solid var(--light-gray);
  display: flex; align-items: center; gap: 0.25rem;
  transition: border-color 120ms ease;
}
.fx-count:hover { border-bottom-color: var(--blue); }
.fx-count__btn {
  width: 28px; height: 28px;
  background: var(--button-secondary);
  border: 0;
  border-radius: 9999px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
}
.fx-count__btn:hover:not(:disabled) { background: var(--blue); color: var(--foreground); }
.fx-count__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fx-count__value {
  flex: 1;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--tertiary);
  line-height: 1.3;
}

.fx-revert-btn {
  width: 100%;
  padding: 0.5rem 1rem;
  background: var(--button-secondary);
  border: 0;
  color: var(--tertiary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.fx-revert-btn:hover { background: var(--light-gray); }

/* Canvas takes everything under the top bar */
.fx-bcanvas-wrap {
  position: absolute;
  inset: var(--fx-bheader-h) 0 0 0;
}
.fx-bcanvas-wrap canvas { display: block; }
.fx-bcanvas-grid {
  position: absolute;
  inset: 0;
  /* Isometric ground tiles: the lines run along the scene's two ground axes (±30° from
     horizontal — the projection the canvas sprites use; the parking-row step (-77, 45)
     and back-row step (280, 160) are both ~30° slopes). The pattern is drawn as one
     seamless tile (step / sin 30° wide, step / cos 30° tall) so build.js can move it with
     the canvas: it sets --fx-grid-step to 40px × the zoom and background-position to the
     viewport's pan, and the ground travels with the objects instead of sliding under them. */
  --fx-grid-step: 40px;
  background-image:
    repeating-linear-gradient(30deg, var(--grid-gray) 0, var(--grid-gray) 1px, transparent 1px, transparent var(--fx-grid-step)),
    repeating-linear-gradient(-30deg, var(--grid-gray) 0, var(--grid-gray) 1px, transparent 1px, transparent var(--fx-grid-step));
  background-size: calc(var(--fx-grid-step) / 0.5) calc(var(--fx-grid-step) / 0.8660254);
  background-position: 0 0;
  pointer-events: none;
  opacity: 0.6;
}

/* Insights cards inside the left panel */
.fx-insight-card {
  padding: 1rem;
  border: 1px solid var(--light-gray);
  margin-bottom: 0.75rem;
}
.fx-insight-card__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--heading);
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.fx-insight-card__body { font-size: 0.8125rem; color: var(--secondary); }

/* ============================================================
   Sim page — stat cards, chart, insights
   ============================================================ */
.fx-sim {
  /* Full-bleed: the rail starts 1.5rem in, level with the header logo and the Build sidebar. */
  padding: 1rem 1.5rem 1.5rem;
  display: grid;
  /* An explicit minmax(0, 1fr) column, not the implicit `auto` one: an `auto` grid track
     sizes to its item's max-content, and the site canvas contributes its inline pixel width
     (Fabric stamps one) to that max-content even though overflow:hidden clips it. That let
     the stage's column grow past the viewport, whereupon fitCanvasToWrap measured the wider
     wrap and stamped a still-larger canvas — a resize loop that ratcheted a horizontal
     scrollbar in on every down-then-up width change. Capping the column at 1fr (min 0) keeps
     the row bound to the viewport so the canvas fills its box without dictating the width. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}
.fx-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 900px) { .fx-stat-grid { grid-template-columns: repeat(2, 1fr); } }
.fx-stat {
  background: var(--foreground);
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  padding: 1.25rem;
}
.fx-stat__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 0.5rem;
}
.fx-stat__value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.1;
}
.fx-stat__unit {
  font-size: 0.875rem;
  color: var(--secondary);
  font-weight: 400;
  margin-left: 0.25rem;
}
.fx-stat__sub {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--secondary);
}
.fx-stat__sub.up { color: #1c8a3d; }
.fx-stat__sub.down { color: #b21f2d; }

.fx-chart-card {
  background: var(--foreground);
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  padding: 1.5rem;
}
.fx-chart-card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.fx-chart-card__title { font-size: 1.125rem; font-weight: 600; color: var(--heading); }
.fx-chart-card__legend { display: flex; gap: 1rem; font-size: 0.8125rem; color: var(--secondary); }
.fx-legend-dot {
  display: inline-block; width: 10px; height: 10px; margin-right: 0.375rem;
  vertical-align: middle;
}

/* Playhead on the 24-hour demand profile: hover-scrub tracking + click-to-pin. */
.fx-demand-chart {
  position: relative;
  height: 320px;
}
.fx-demand-chart canvas { display: block; }
.fx-demand-cursor {
  position: absolute;
  width: 1.5px;
  background: var(--blue);
  pointer-events: none;
  z-index: 1;
  transform: translateX(-50%);
}
#sim-resume {
  font-size: 0.8125rem;
  color: var(--secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
}

.fx-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 900px) { .fx-insights { grid-template-columns: 1fr; } }
.fx-insight {
  background: var(--foreground);
  outline: 1px solid var(--light-gray);
  outline-offset: -1px;
  padding: 1.25rem;
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
}
.fx-insight__icon {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue-light);
  color: var(--blue);
  flex-shrink: 0;
}
.fx-insight__icon .material-symbols-outlined { font-size: 22px; }
.fx-insight__title { font-weight: 600; color: var(--heading); margin-bottom: 0.25rem; }
.fx-insight__body { font-size: 0.875rem; color: var(--secondary); }

/* ============================================================
   Re-run modal — vehicle sliders + the session-distribution chart
   (the legacy RerunModal / SessionDistribution components)
   ============================================================ */
.fx-rerun-section {
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--button-secondary);
}
.fx-rerun-section__title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 1.125rem;
  color: var(--tertiary);
  margin-bottom: 0.75rem;
}

.fx-rerun-vehicle {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.375rem 0;
}
.fx-rerun-vehicle__label {
  width: 96px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tertiary);
  margin: 0;
}
.fx-rerun-vehicle__slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--blue);
}
.fx-rerun-vehicle__count {
  width: 80px;
  padding: 0.125rem 0.75rem;
  border: 1px solid var(--light-gray);
  background: var(--foreground);
  font-size: 0.875rem;
  color: var(--tertiary);
  outline: none;
}
.fx-rerun-vehicle__count:focus { border-color: var(--blue); }
.fx-rerun-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
}
.fx-rerun-total__label { font-size: 0.875rem; font-weight: 600; color: var(--tertiary); }
.fx-rerun-total__value {
  width: 80px;
  padding: 0.125rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tertiary);
}

.fx-dist { display: flex; gap: 0.25rem; }
.fx-dist__ylabel {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.75rem;
  color: var(--tertiary);
  text-align: center;
  padding-top: 3rem; /* rotated: keeps the label centered on the chart, above the axis rows */
}
.fx-dist__body { flex: 1; min-width: 0; }
.fx-dist__chart {
  display: flex;
  align-items: flex-end;
  height: 132px; /* 100px columns + headroom for the value bubbles */
}
.fx-dist__col {
  position: relative;
  flex-grow: 1; /* sim.js scales each column by its block's hours */
  flex-basis: 0;
  height: 100px;
}
.fx-dist__col svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.fx-dist__handle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 9px;
  outline: 2px solid var(--foreground);
  cursor: grab;
  touch-action: none;
  z-index: 2;
}
.fx-dist__handle.dragging { cursor: grabbing; }
.fx-dist__handle:focus-visible { outline: 2px solid var(--primary); }
.fx-dist__bubble {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 24px;
  height: 24px;
  padding: 0 0.25rem;
  border-radius: 9999px;
  background: var(--light-gray-bg);
  color: var(--tertiary);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.fx-dist__axis {
  position: relative;
  height: 28px;
  margin-top: 2px;
}
.fx-dist__tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 8px;
  background: var(--light-gray);
}
.fx-dist__tick--major { background: var(--tertiary); }
.fx-dist__tick span {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6875rem;
  color: var(--tertiary);
  white-space: nowrap;
}
.fx-dist__daynight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--tertiary);
  margin-top: 0.25rem;
}
.fx-dist__daynight .material-symbols-outlined { font-size: 16px; }
.fx-dist__daynight .material-symbols-outlined:nth-child(2) { font-size: 20px; }

/* Read-only banner for /share */
.fx-share-banner {
  background: var(--blue-light);
  border-bottom: 1px solid var(--blue-secondary);
  color: var(--text-blue);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}
.fx-share-banner .material-symbols-outlined { font-size: 20px; }

/* Utility: hide elements completely (for read-only mode) */
.fx-hide { display: none !important; }

/* Toast / gnotify */
.fx-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  background: var(--surface-invert);
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1080;
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.fx-toast.show { opacity: 1; }
.fx-toast.success { border-left: 3px solid #31beef; }
.fx-toast.error   { border-left: 3px solid #c0392b; }

/* ============================================================
   Responsive first-pass — graceful degradation to narrow widths.
   The desktop layouts above are unchanged; each block only takes
   effect once the viewport narrows past its breakpoint, keeping the
   header, hero, panels and rails inside the viewport (no sideways
   scroll) down to phone widths.
   ============================================================ */

/* Header + stepper — shared by the layout's fx-header (Info, Sim) and the
   Build page's docked fx-bheader. As the bar narrows the stepper sheds its
   dividers, then its labels, so the logo and the page actions keep room. */
@media (max-width: 768px) {
  .fx-stepper { gap: 0.75rem; }
  .fx-step__divider { width: 12px; }
  .fx-bheader__right { gap: 1rem; }
}
@media (max-width: 560px) {
  /* Drop the symmetric side tracks so the action group is not boxed into an
     equal-width half; the stepper centres in the flexible middle instead. */
  .fx-header {
    grid-template-columns: auto 1fr auto;
    padding: 0 0.75rem;
    column-gap: 0.5rem;
  }
  .fx-header .fx-stepper { justify-self: center; }
  .fx-header__logo img,
  .fx-bheader__logo img { height: 24px; }
  .fx-stepper { gap: 0.5rem; }
  .fx-step__label { display: none; }
  .fx-step__divider { display: none; }
  .fx-bactions { gap: 0; }
  .fx-baction { width: 34px; height: 34px; }
  .fx-baction .material-symbols-outlined { font-size: 20px; }
}

/* The Build bar carries the most chrome (logo · stepper · Run · four actions).
   Drop its symmetric side tracks below full desktop so the wide action group is
   not boxed into an equal half and forced to spill over the centred stepper; the
   stepper then centres in the slack between the logo and the actions instead. */
@media (max-width: 1080px) {
  .fx-bheader__inner { grid-template-columns: auto 1fr auto; }
  .fx-bheader .fx-stepper { justify-self: center; }
}
/* Below 560 the stepper steps aside so the run control and actions stay usable,
   and the bar collapses to a logo | actions grid. */
@media (max-width: 560px) {
  .fx-bheader__inner { grid-template-columns: auto 1fr; padding: 0 0.75rem; }
  .fx-bheader .fx-stepper { display: none; }
  .fx-bheader__right { gap: 0.5rem; }
  .fx-run-sim { padding: 0.5rem 0.75rem; letter-spacing: 0.06em; }
}
@media (max-width: 440px) {
  /* Run collapses to its icon so the four actions keep room on the smallest bars. */
  .fx-run-sim { padding: 0.5rem; }
  .fx-run-sim span:not(.material-symbols-outlined) { display: none; }
}

/* Build slide-in panel — keep it inside the viewport beside the tool sidebar
   rather than the fixed 338px, which runs off a phone-width screen when open. */
@media (max-width: 560px) {
  .fx-bpanel { width: min(338px, calc(100vw - var(--fx-btoolbar-w) - 4rem)); }
}

/* Info hero — once the three-column hero stacks (≤900), the card→image
   connectors point at nothing and poke past the edges, so drop them; the
   middle column and its form tighten their side padding on small screens. */
@media (max-width: 900px) {
  .fx-hero__connector { display: none; }
}
@media (max-width: 560px) {
  .fx-hero__middle { padding: 2rem 1.25rem; }
  .fx-hero__form .fx-section,
  .fx-hero__form .fx-section--actions,
  .fx-section { padding-left: 1.25rem; padding-right: 1.25rem; }
}

/* Sim page — trim the rail's side padding on the narrowest phones. The stage
   itself already stacks to a single column at ≤900. */
@media (max-width: 480px) {
  .fx-sim { padding-left: 1rem; padding-right: 1rem; }
}
