/* ==========================================================================
   System2 Layout Planner - stylesheet
   "Classic Railway Poster" brand (2026-06-12): the estate design language
   carried from the shop landing + Documents/system2-explained.html.
   Brunswick green, BR maroon, cream paper, brass lines.
   All design tokens live in :root; components consume them only.
   ========================================================================== */

:root {
  --bg: #fbf5e6;            /* card / ticket face */
  --fg: #241a10;            /* warm near-black ink */
  --accent: #0f4a39;        /* Brunswick green */
  --accent-light: #dfe8e0;  /* pale green wash */
  --accent-dark: #0c3d2f;   /* green ink */
  --border: #ddcca4;        /* brass-tinted keyline */
  --section-bg: #f1e7cf;    /* aged cream paper */
  --success: #2f8a5b;       /* signal green */
  --success-light: #e2efe7;
  --success-border: #bcd9c8;
  --warning: #c2611d;       /* North-Eastern tangerine */
  --danger: #bb2331;        /* signal red */
  --muted: #897654;         /* faded ink */
  --fade-speed: 1.2s;
  --toast-duration: 4s;

  /* derived helpers (kept here so components stay token-only) */
  --warning-light: #f6e7d3;
  --warning-border: #e8c9a8;
  --danger-light: #f4dcdc;
  --danger-border: #e4b6b6;
  --radius-card: 14px;
  --radius-btn: 10px;
  --shadow-sm: 0 1px 2px rgba(40, 24, 8, 0.08);
  --shadow-md: 0 4px 14px rgba(40, 24, 8, 0.12);
  --font-stack: 'Hanken Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', 'Iowan Old Style', Palatino, Georgia, serif;
  --font-mono: 'DM Mono', 'Cascadia Code', Consolas, monospace;
}

/* ---------- reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--section-bg);
  color: var(--fg);
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1.25;
  font-family: var(--font-display); /* poster display face */
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ---------- sticky header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 3px double #b0863a; /* brass double rule - poster chrome */
  box-shadow: var(--shadow-sm);
}

/* enamel-totem brand mark (matches the shop landing + brochure header) */
.app-header .brand-totem {
  --t: var(--accent);
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  background: var(--t);
  color: #fff;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.5em 1.1em;
  border-radius: 999px;
  box-shadow: inset 0 0 0 3px var(--t), inset 0 0 0 5px #f6efdd;
}
.app-header .brand-totem small {
  font-weight: 600;
  letter-spacing: 0.3em;
  margin-left: 0.55em;
  opacity: 0.85;
  font-size: 0.62em;
}

.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-header .brand-home {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  line-height: 0;
}
.app-header .brand-logo {
  height: 36px;
  width: auto;
  max-width: min(58vw, 340px);
  flex: 0 0 auto;
  display: block;
}
.btn-back-shop {
  text-decoration: none;
}

/* keep the brand block (logo + title) from being squeezed by the actions */
.app-header .brand-text {
  flex: 0 1 auto;
  min-width: 0;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.app-header .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 1px;
}

.app-header .header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- page layout ---------- */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}

.wizard-col {
  min-width: 0;
}

.bom-col {
  position: sticky;
  top: 76px;
  min-width: 0;
}

/* ---------- generic card ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card + .card {
  margin-top: 16px;
}

/* ---------- buttons ---------- */
.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-btn);
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}
.btn-primary:disabled {
  background: var(--accent-light);
  color: #fff;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--section-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 6px 10px;
}
.btn-ghost:hover {
  background: var(--accent-light);
}

.btn-small {
  padding: 5px 12px;
  font-size: 13px;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease;
}
.btn-danger-ghost:hover {
  background: var(--danger-light);
}

/* ==========================================================================
   WIZARD
   ========================================================================== */

/* step rail / progress */
.step-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.step-pip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.step-pip:hover {
  background: var(--section-bg);
}
.step-pip .pip-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--section-bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.step-pip.is-active {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-color: var(--accent-light);
}
.step-pip.is-active .pip-num {
  background: var(--accent);
  color: #fff;
}
.step-pip.is-complete .pip-num {
  background: var(--success);
  color: #fff;
}

/* step panel + crossfade */
.step-host {
  position: relative;
}

.step-panel {
  animation: stepFadeIn 0.28s ease both;
}

@keyframes stepFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .step-panel,
  .toast,
  .step-fade {
    animation: none !important;
    transition: none !important;
  }
}

.step-head {
  margin-bottom: 14px;
}
.step-head h2 {
  font-size: 18px;
  font-weight: 700;
}
.step-head .step-desc {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 4px;
}

/* labels + fields */
.field {
  margin-bottom: 14px;
}
.field:last-child {
  margin-bottom: 0;
}

.field-label,
label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.5;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 8px 11px;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

input.input-error {
  border-color: var(--danger);
}
input.input-error:focus {
  box-shadow: 0 0 0 3px var(--danger-light);
}

.input-narrow {
  max-width: 140px;
}

/* number stepper compound (label + input grid) */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* toggle / switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.switch-row + .switch-row {
  border-top: 1px solid var(--border);
}
.switch-text .switch-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.switch-text .switch-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.switch input:checked + .track {
  background: var(--accent);
}
.switch input:checked + .track + .thumb {
  transform: translateX(18px);
}
.switch input:focus-visible + .track {
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* segmented control (radio group) */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
  background: var(--bg);
}
.segmented label {
  position: relative;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented label + label {
  border-left: 1px solid var(--border);
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label:hover {
  background: var(--section-bg);
}
.segmented input:checked + span,
.segmented label.is-selected {
  color: var(--accent-dark);
}
.segmented label.is-selected {
  background: var(--accent-light);
}

/* checkbox chips */
.chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover {
  background: var(--section-bg);
}
.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.chip .chip-box {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip.is-checked {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.chip.is-checked .chip-box {
  background: var(--accent);
  border-color: var(--accent);
}
.chip .chip-box svg {
  width: 11px;
  height: 11px;
  stroke: #fff;
  stroke-width: 3;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.chip.is-checked .chip-box svg {
  opacity: 1;
}

/* sanity / inline status badges */
.inline-note {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-note.ok {
  background: var(--success-light);
  border: 1px solid var(--success-border);
  color: var(--success);
}
.inline-note.warn {
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}
.inline-note.bad {
  background: var(--danger-light);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

/* repeatable rows (panels, owned) */
.repeat-row {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--section-bg);
}
.repeat-row + .repeat-row {
  margin-top: 10px;
}
.repeat-row .repeat-fields {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 10px;
  align-items: end;
}
.repeat-row.owned-row .repeat-fields {
  grid-template-columns: 1fr 110px auto;
}

.add-row-btn {
  margin-top: 12px;
}

/* step nav footer */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.step-nav .spacer {
  flex: 1;
}

/* ==========================================================================
   BOM PANEL
   ========================================================================== */
.bom-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.bom-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bom-header h2 {
  font-size: 16px;
  font-weight: 700;
}
.bom-header .bom-sub {
  font-size: 12px;
  color: var(--muted);
}

/* always-visible price-scope toggles, under the header */
.bom-options {
  border-bottom: 1px solid var(--border);
  background: var(--section-bg);
}
.bom-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
}
.bom-opt + .bom-opt {
  border-top: 1px dashed var(--border);
}
.bom-opt input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: 0 0 auto;
  cursor: pointer;
}
.bom-opt .bom-opt-text b {
  display: block;
  font-size: 13px;
  color: var(--accent-dark);
}
.bom-opt .bom-opt-text small {
  color: var(--muted);
  font-size: 11.5px;
}

.bom-body {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

/* live re-solve pulse */
.bom-card.is-solving .bom-header {
  background: var(--section-bg);
}
.solve-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  flex: 0 0 auto;
  transition: background 0.15s ease;
}
.bom-card.is-solving .solve-dot {
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* empty state */
.bom-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.bom-empty .empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bom-empty h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}
.bom-empty p {
  font-size: 13px;
  margin: 0;
}

/* category group */
.bom-group {
  border-bottom: 1px solid var(--border);
}
.bom-group:last-child {
  border-bottom: none;
}
.bom-group-head {
  padding: 9px 16px;
  background: var(--section-bg);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* line item */
.bom-line {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  transition: background 0.15s ease;
}
.bom-group-head + .bom-line {
  border-top: none;
}
.bom-line:hover {
  background: var(--section-bg);
}
.bom-line-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.bom-line-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.bom-line-qty {
  color: var(--accent-dark);
  font-weight: 700;
}
.bom-line-prices {
  text-align: right;
  flex: 0 0 auto;
  white-space: nowrap;
}
.bom-line-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.bom-line-unit {
  font-size: 12px;
  color: var(--muted);
}
.bom-line-meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.bom-line-sku {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* tag chips on lines */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tag-new {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.tag-variable {
  background: var(--warning-light);
  color: var(--warning);
}
.tag-confirm {
  background: var(--warning-light);
  color: var(--warning);
}

/* explain (reason) disclosure */
.explain-toggle {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.explain-toggle:hover {
  text-decoration: underline;
}
.explain-toggle .chev {
  transition: transform 0.15s ease;
}
.bom-line.is-open .explain-toggle .chev {
  transform: rotate(90deg);
}
.explain-body {
  display: none;
  margin-top: 8px;
  padding: 9px 11px;
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 13px;
  color: var(--fg);
  line-height: 1.55;
}
.bom-line.is-open .explain-body {
  display: block;
  animation: stepFadeIn 0.2s ease both;
}
.explain-body .variation-note {
  margin-top: 6px;
  color: var(--warning);
  font-weight: 500;
}
.explain-body .doc-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-weight: 600;
}

/* totals */
.bom-totals {
  padding: 14px 16px;
  border-top: 2px solid var(--border);
  background: var(--bg);
}
.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 14px;
  padding: 3px 0;
}
.total-row .total-label {
  color: var(--muted);
}
.total-row .total-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.total-row.grand {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.total-row.grand .total-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}
.total-row.grand .total-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
}
.vat-basis-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* headroom meters */
.bom-section {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.bom-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}
.headroom-item {
  margin-bottom: 12px;
}
.headroom-item:last-child {
  margin-bottom: 0;
}
.headroom-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}
.headroom-name {
  font-weight: 600;
  color: var(--fg);
}
.headroom-spare {
  font-size: 12.5px;
  color: var(--muted);
}
.meter {
  height: 7px;
  border-radius: 999px;
  background: var(--section-bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.meter-fill.tight {
  background: var(--warning);
}
.meter-fill.full {
  background: var(--success);
}

/* kit saving banner */
.kit-banner {
  margin: 14px 16px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: var(--success-light);
  border: 1px solid var(--success-border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.kit-banner .kit-icon {
  color: var(--success);
  flex: 0 0 auto;
  margin-top: 1px;
}
.kit-banner .kit-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--success);
}
.kit-banner .kit-detail {
  font-size: 12.5px;
  color: var(--fg);
  margin-top: 2px;
}

/* warnings + notes lists */
.advice-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.advice-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 0;
  font-size: 13px;
  line-height: 1.5;
}
.advice-item + .advice-item {
  border-top: 1px solid var(--border);
}
.advice-item .advice-icon {
  flex: 0 0 auto;
  margin-top: 2px;
}
.advice-item.warn .advice-icon {
  color: var(--warning);
}
.advice-item.note .advice-icon {
  color: var(--accent);
}
.advice-item .advice-text {
  color: var(--fg);
}

/* toast */
.toast-host {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--fg);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease both, toastOut 0.4s ease forwards;
  animation-delay: 0s, var(--toast-duration);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* small util */
.muted {
  color: var(--muted);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   RESPONSIVE - stack BOM under the wizard below ~860px
   ========================================================================== */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .bom-col {
    position: static;
    top: auto;
  }
  .bom-body {
    max-height: none;
  }
  .repeat-row .repeat-fields,
  .repeat-row.owned-row .repeat-fields {
    grid-template-columns: 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 18px 14px;
  }
  .app-header-inner {
    padding: 12px 14px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .app-header .header-actions .btn-label {
    display: none;
  }
  /* give the logo + actions room on phones */
  .app-header .brand-logo {
    height: 30px;
  }
  .app-header .subtitle {
    display: none;
  }
}

/* ---------- footer brand strip ---------- */
.app-footer {
  margin-top: 44px;
  border-top: 3px double #b0863a;
  background: var(--card);
  padding: 26px 24px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.app-footer .brand-home { display: inline-block; line-height: 0; }
.app-footer .brand-logo-foot {
  height: 30px;
  width: auto;
  max-width: 80vw;
  display: inline-block;
}
.app-footer .app-footer-tag {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.app-footer .app-footer-tag a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

/* First-visit intro overlay -------------------------------------------------- */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(40, 24, 8, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.intro-overlay.is-open { opacity: 1; }
.intro-card {
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  padding: 28px 30px;
  transform: translateY(8px);
  transition: transform 0.25s ease;
}
.intro-overlay.is-open .intro-card { transform: none; }
.intro-eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.intro-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.15;
  color: var(--accent-dark);
}
.intro-lead { margin: 0 0 16px; font-size: 1rem; line-height: 1.5; }
.intro-steps { margin: 0 0 14px; padding: 0; list-style: none; counter-reset: introstep; }
.intro-steps li {
  position: relative;
  padding: 0 0 12px 42px;
  font-size: 0.96rem;
  line-height: 1.5;
}
.intro-steps li::before {
  counter-increment: introstep;
  content: counter(introstep);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.intro-foot { margin: 0 0 20px; color: var(--muted); font-size: 0.9rem; }
.intro-btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius-btn);
  cursor: pointer;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-stack);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7em 1em;
}
.intro-btn:hover { background: var(--accent-dark); }
.intro-btn:focus-visible { outline: 3px solid var(--success-border); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .intro-overlay, .intro-card { transition: none; }
}
