/* ============================================================
   Rack Builder — visual configurator styles
   ============================================================ */
:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --ink:       #0f172a;
  --ink-soft:  #475569;
  --ink-dim:   #94a3b8;
  --line:      #e2e8f0;
  --brand:     #ea7a2e;
  --brand-dk:  #b8551c;
  --accent:    #2563eb;
  --ok:        #16a34a;
  --warn:      #d97706;
  --bad:       #dc2626;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 6px 16px rgba(15,23,42,.08);
  --radius:    10px;
}

/* Page-level layout locks live in the inline <style> at the top of
   index.html so they're impossible to cache-defeat. This file only
   handles the visible UI styling. */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Hide scrollbars inside the panel sections — content can still scroll
   functionally (mouse wheel inside the section) but no visible bars. */
.panel-section { scrollbar-width: none; -ms-overflow-style: none; }
.panel-section::-webkit-scrollbar { width: 0; height: 0; background: transparent; }

/* ── Top bar ────────────────────────────────────────────── */
/* ── Switchboard (proper 3-row control bar at top of canvas) ── */
.switchboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 2;
  box-shadow: 0 2px 6px rgba(15,23,42,.06);
  flex: 0 0 auto;
}
.sb-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sb-row-materials { border-top: 1px solid var(--line); padding-top: 4px; }
.sb-row-summary   { border-top: 1px solid var(--line); padding-top: 4px; }

.sb-tabs    { display: flex; gap: 4px; }
.sb-actions { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.sb-btn { padding: 5px 11px; font-size: 12px; }

.sb-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
}
.sb-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
  font-weight: 700;
  white-space: nowrap;
}
.sb-field select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}
.sb-capacity { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.sb-cap {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 78px;
}
.sb-cap span {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
  font-weight: 700;
}
.sb-cap strong { font-size: 13px; font-weight: 800; color: var(--ink); }
.sb-cap-total { background: #fff7ed; border-color: var(--brand); }
.sb-cap-total strong { color: var(--brand-dk); }

/* The summary row inside the switchboard */
.sb-row-summary #summary { flex: 1; }

.tab {
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.tab:hover  { background: var(--bg); color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-field { display: flex; flex-direction: column; gap: 2px; }
.topbar-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-soft);
  font-weight: 600;
}
.topbar-field select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  min-width: 160px;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:hover { background: #1e293b; }
.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); }
.btn-small {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}
.btn-small:hover { color: var(--brand-dk); border-color: var(--brand); }
.btn-icon {
  width: 22px; height: 22px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
}
.btn-icon:hover { background: var(--bg); color: var(--bad); }
.btn-icon.close { margin-left: auto; }

/* ── Main layout ───────────────────────────────────────── */
/* .layout / .app-main / .app-stage / .app-panel sizing is handled by the
   inline grid rules in index.html (.app, .app-main, .app-stage, .app-panel).
   Keeping styling here minimal so the inline locks always win. */

/* ── Stage (canvas) ────────────────────────────────────── */
.stage {
  display: flex;
  flex-direction: column;
  /* Background lives in the inline .app .stage rule and matches the SVG's
     outside-room fill (#dde4ec) so nothing peeks through if canvas-frame
     doesn't cover an edge pixel for some reason. */
  border-right: 1px solid var(--line);
  overflow: hidden;
  position: relative;
  min-width: 0;
  max-width: 100%;
}
.canvas-frame {
  flex: 1;
  position: relative;
  overflow: hidden;           /* no scrolling; SVG scales to fit */
  /* Background lives in the inline .app .canvas-frame rule so it matches
     the SVG's outside-room fill exactly; do not set it here. */
}
#rackSvg {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
}

/* Floating hint text in the top-right of the canvas */
.canvas-hint {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 2;
  font-size: 11px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  pointer-events: none;
}
.stage-foot {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px 14px;
}
.summary-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.summary-row .stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.summary-row .stat span {
  font-size: 9px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.summary-row .stat strong {
  font-size: 13px;
  font-weight: 700;
}

/* ── Panel (right) ─────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}
.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.panel-space    { flex: 0 0 auto; }
.panel-unit     { flex: 0 0 auto; }
.panel-sections { flex: 2 1 auto; min-height: 30%; }
.panel-bom      { flex: 1 1 auto; min-height: 90px; }

/* ── Unit configurator card ─────────────────────────────── */
.uc-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}
.uc-tabs .tab {
  text-align: center;
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 700;
}
.uc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.uc-actions .btn-cta[hidden] { display: none; }
.uc-actions .btn-cta:only-child,
.uc-actions .btn-cta:nth-child(3) { grid-column: span 2; }
.btn-cta {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .08s ease, box-shadow .12s ease;
}
.btn-cta:active { transform: translateY(1px); }
.btn-cta-primary {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  box-shadow: 0 1px 0 rgba(15,23,42,.12);
}
.btn-cta-primary:hover { background: #1e293b; box-shadow: 0 2px 8px rgba(15,23,42,.18); }
.btn-cta-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-cta-ghost:hover { border-color: var(--ink-soft); }

.unit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.unit-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
}
.unit-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
  font-weight: 700;
}
.unit-field select {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  width: 100%;
}
.hint {
  font-size: 10px;
  color: var(--ink-soft);
  font-style: italic;
}

/* ── Space card ─────────────────────────────────────────── */
.space-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 0;
}
.space-field {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
}
.space-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
  font-weight: 700;
}
.space-field input {
  width: 36px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  text-align: center;
  background: var(--surface);
}
.space-field .suffix {
  font-size: 10px;
  color: var(--ink-soft);
  margin-right: 2px;
}
.fire-warning {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 6px;
  font-size: 11px;
  color: #7f1d1d;
}
.fire-warning .fire-icon {
  font-size: 16px;
  line-height: 1;
}
.fire-warning strong { display: block; margin-bottom: 2px; font-size: 12px; }
.fire-warning p      { margin: 0; line-height: 1.4; }
.space-alert {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
  padding: 8px 10px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
  line-height: 1.4;
}
.space-alert[hidden] { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 6px;
  flex-wrap: wrap;
}
.panel-header-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.panel-header h3 {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--ink-soft);
}
/* ── Section controls (search + jump-to dropdown) ─────── */
.section-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-bottom: 10px;
}
.section-controls input[type="search"] {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  background: var(--surface);
  outline: none;
}
.section-controls input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(234, 122, 46, 0.18);
}
.section-controls select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  background: var(--surface);
  max-width: 140px;
}
.search-empty {
  padding: 14px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 12px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px dashed var(--line);
  font-style: italic;
}

/* ── Section card ──────────────────────────────────────── */
.section-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.section-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(234, 122, 46, 0.25), var(--shadow);
}
.section-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.section-num {
  font-weight: 700;
  font-size: 13px;
}
.adj-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.adj-tag.adj-touching { background: rgba(22,163,74,.12); color: var(--ok); }
.adj-tag.adj-gap      { background: rgba(217,119,6,.12); color: var(--warn); }
.adj-tag.adj-addon    { background: rgba(37,99,235,.12); color: var(--accent); }
.adj-tag:not(.adj-touching):not(.adj-gap):not(.adj-addon) {
  background: rgba(71,85,105,.12); color: var(--ink-soft);
}

.section-field-conn { grid-column: span 2; }

.section-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.section-field {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}
.section-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
  font-weight: 600;
  min-width: 24px;
  white-space: nowrap;
}
.section-field select,
.section-field input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  width: 100%;
  padding: 2px 0;
  outline: none;
}
.section-field .suffix {
  font-size: 11px;
  color: var(--ink-soft);
}
.section-fields .btn-small { grid-column: span 2; justify-self: start; }

/* ── Levels list inside a section card ──────────────────── */
.section-levels {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}
.levels-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.levels-cap {
  flex: 1;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  color: var(--brand-dk);
  letter-spacing: .2px;
}
.level-row {
  display: grid;
  grid-template-columns: auto 60px auto auto;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.level-row:last-child { border-bottom: none; }
.level-row label { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.level-row .level-num {
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  min-width: 26px;
  text-align: center;
}
.level-row input[type="number"] {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
}
.level-row .level-unit { color: var(--ink-soft); font-size: 11px; }
.level-row .level-deck {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  font-size: 11px;
}
.level-empty {
  font-size: 12px;
  color: var(--ink-dim);
  padding: 6px;
  text-align: center;
  font-style: italic;
}

/* ── BOM panel ─────────────────────────────────────────── */
.empty-bom {
  padding: 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px dashed var(--line);
}
.bom-line {
  display: grid;
  grid-template-columns: 30px 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.bom-qty {
  font-weight: 700;
  text-align: right;
}
.bom-name { font-weight: 500; }
.bom-sku  { font-size: 10px; color: var(--ink-soft); letter-spacing: .2px; }
.bom-total {
  font-weight: 600;
  min-width: 56px;
  text-align: right;
}
.bom-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  margin-top: 6px;
  font-size: 14px;
  border-top: 2px solid var(--ink);
}
.bom-total-row strong { font-size: 18px; color: var(--brand-dk); }

/* ── Right configurator bar: every font +8 points over its base size ──
   Scoped to .app-panel so the center stage and top switchboard are untouched. */
.app-panel .uc-tabs .tab { font-size: 42px; }
.app-panel .btn-cta { font-size: 45px; }
.app-panel .btn-small { font-size: 19px; }
.app-panel .btn-icon { font-size: 24px; }
.app-panel .unit-field label { font-size: 41px; }
.app-panel .unit-field select { font-size: 20px; }
.app-panel .hint { font-size: 18px; }
.app-panel .panel-header h3 { font-size: 18px; }
.app-panel .section-controls input[type="search"],
.app-panel .section-controls select { font-size: 20px; }
.app-panel .search-empty { font-size: 20px; }
.app-panel .section-num { font-size: 21px; }
.app-panel .adj-tag { font-size: 18px; }
.app-panel .space-field label { font-size: 18px; }
.app-panel .space-field input { font-size: 20px; }
.app-panel .space-field .suffix { font-size: 18px; }
.app-panel .space-alert { font-size: 20px; }
.app-panel .section-field label { font-size: 18px; }
.app-panel .section-field select,
.app-panel .section-field input { font-size: 20px; }
.app-panel .section-field .suffix { font-size: 19px; }
.app-panel .levels-head { font-size: 20px; }
.app-panel .levels-cap { font-size: 18px; }
.app-panel .level-row { font-size: 20px; }
.app-panel .level-row label { font-size: 19px; }
.app-panel .level-row .level-num { font-size: 19px; }
.app-panel .level-row input[type="number"] { font-size: 20px; }
.app-panel .level-row .level-unit,
.app-panel .level-row .level-deck { font-size: 19px; }
.app-panel .level-empty { font-size: 20px; }
.app-panel .empty-bom { font-size: 21px; }
.app-panel .bom-line { font-size: 19px; }
.app-panel .bom-sku { font-size: 18px; }
.app-panel .bom-total-row { font-size: 22px; }
.app-panel .bom-total-row strong { font-size: 26px; }
