:root {
  --bg: #080706;
  --surface: #12100d;
  --surface-2: #19140f;
  --surface-3: #231b13;
  --ink: #fff8ef;
  --muted: #b8aa9b;
  --soft: rgba(255, 248, 239, .08);
  --line: rgba(255, 248, 239, .13);
  --line-hot: rgba(245, 124, 32, .45);
  --hot: #f47b20;
  --hot-2: #ffb15f;
  --champagne: #e5d2ba;
  --shadow: 0 26px 70px rgba(0, 0, 0, .38);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(125deg, rgba(244, 123, 32, .12), transparent 34%),
    linear-gradient(180deg, #15110d 0%, #080706 46%, #050504 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 248, 239, .045);
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
button:hover {
  border-color: var(--line-hot);
  background: rgba(244, 123, 32, .12);
}
button:active { transform: translateY(1px); }
button.active {
  color: #170f08;
  border-color: rgba(255, 177, 95, .9);
  background: linear-gradient(180deg, var(--hot-2), var(--hot));
  box-shadow: 0 12px 28px rgba(244, 123, 32, .24);
  font-weight: 950;
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(0, 0, 0, .24);
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(244, 123, 32, .85);
  box-shadow: 0 0 0 3px rgba(244, 123, 32, .12);
}
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.hidden { display: none !important; }
.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(244, 123, 32, .22);
  background: rgba(8, 7, 6, .9);
  backdrop-filter: blur(18px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.brand span {
  width: 78px;
  height: 43px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #140d07;
  background: var(--hot);
  font-size: 21px;
  font-weight: 1000;
}
.brand b {
  color: var(--champagne);
  font-size: 13px;
  line-height: 1.1;
  text-transform: uppercase;
}
.nav {
  justify-self: center;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 248, 239, .04);
}
.nav button {
  min-height: 38px;
  padding: 0 16px;
  border-color: transparent;
  background: transparent;
  font-weight: 850;
}
.top-total {
  justify-self: end;
  min-width: 170px;
  padding: 9px 12px;
  border: 1px solid rgba(244, 123, 32, .36);
  border-radius: 8px;
  background: #120c07;
}
.top-total small, .top-total strong { display: block; }
.top-total small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}
.top-total strong {
  color: var(--hot-2);
  font-size: 22px;
  line-height: 1.02;
}

main { padding: 14px; }
.page { display: none; }
.page.active { display: block; }

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 405px);
  gap: 14px;
  align-items: start;
}
.center-stage {
  grid-column: 1;
  grid-row: 1 / span 2;
}
.left-rail,
.right-rail {
  grid-column: 2;
  display: grid;
  gap: 10px;
}
.left-rail {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding-right: 2px;
}
.right-rail {
  grid-row: 2;
}
.left-rail::-webkit-scrollbar,
.right-rail::-webkit-scrollbar,
.material-grid::-webkit-scrollbar {
  width: 7px;
}
.left-rail::-webkit-scrollbar-thumb,
.right-rail::-webkit-scrollbar-thumb,
.material-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 177, 95, .28);
  border-radius: 20px;
}

.panel, .center-stage, .price-panel, .page-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 248, 239, .055), rgba(255, 248, 239, .018)),
    var(--surface);
  box-shadow: var(--shadow);
}
.panel, .page-card { padding: 14px; }
.intro {
  min-height: 164px;
  display: grid;
  align-content: end;
  gap: 8px;
  border-color: rgba(244, 123, 32, .3);
  background:
    linear-gradient(140deg, rgba(244, 123, 32, .26), transparent 45%),
    linear-gradient(180deg, #21140b, #110d09);
}
.intro small, .panel-title small, .stage-head small, .page-title small {
  color: var(--hot-2);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}
.intro h1, .intro p, .panel-title h2, .stage-head h2, .page-title h1 { margin: 0; }
.intro h1 {
  max-width: 12ch;
  font-size: 27px;
  line-height: 1.02;
}
.intro p {
  color: rgba(255, 248, 239, .74);
  font-size: 13px;
  line-height: 1.42;
}
.panel-title, .page-title {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.panel-title h2, .stage-head h2 {
  font-size: 18px;
  line-height: 1.12;
}
.page-title h1 {
  font-size: 30px;
  line-height: 1.05;
}

.center-stage {
  min-width: 0;
  overflow: hidden;
  background: #0d0b09;
}
.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(244, 123, 32, .11), rgba(255, 248, 239, .03));
}
.density {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(270px, 100%);
}
.preview {
  position: relative;
  height: calc(100vh - 218px);
  min-height: 570px;
  overflow: hidden;
  background: #d5c8b6;
}
#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
}
.module-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, .2);
}
.module-chip {
  padding: 9px 10px;
  border: 1px solid rgba(255, 248, 239, .1);
  border-radius: 8px;
  background: rgba(255, 248, 239, .04);
}
.module-chip b, .module-chip span { display: block; }
.module-chip b { font-size: 13px; }
.module-chip span {
  color: var(--muted);
  font-size: 12px;
}

.choice-grid, .field-grid, .segmented, .option-list, .material-tools, .catalog-tools {
  display: grid;
  gap: 8px;
}
.choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-grid button {
  min-height: 82px;
  display: grid;
  align-content: end;
  gap: 4px;
  padding: 10px;
  text-align: left;
}
.choice-grid b, .choice-grid span { display: block; }
.choice-grid span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.wide {
  display: block;
  margin-top: 10px;
}
.option-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 9px;
  border: 1px solid rgba(255, 248, 239, .08);
  border-radius: 8px;
  background: rgba(0, 0, 0, .16);
}
.option-list input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--hot);
}
.option-list span {
  margin: 0;
  color: var(--ink);
}

.price-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-color: rgba(244, 123, 32, .42);
  background:
    linear-gradient(160deg, rgba(244, 123, 32, .2), rgba(0, 0, 0, .04) 48%),
    #150d07;
}
.price-panel small, .price-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.price-panel strong {
  color: var(--hot-2);
  font-size: clamp(38px, 4vw, 56px);
  line-height: .94;
}
.primary {
  min-height: 50px;
  color: #170f08;
  border-color: rgba(255, 177, 95, .9);
  background: linear-gradient(180deg, var(--hot-2), var(--hot));
  box-shadow: 0 16px 34px rgba(244, 123, 32, .24);
  font-weight: 950;
}

.segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 10px;
}
.segmented button { padding-inline: 8px; }
.palette {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.palette-row, .break-row, .summary-row, .price-row, .assignment-row, .order-card {
  border: 1px solid rgba(255, 248, 239, .1);
  border-radius: 8px;
  background: rgba(0, 0, 0, .16);
}
.palette-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
}
.swatch {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 7px;
  background: var(--swatch);
}
.palette-row b, .palette-row span, .material-card b, .material-card span, .material-card small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-row b, .material-card b { font-size: 12px; }
.palette-row span, .material-card span {
  color: var(--muted);
  font-size: 11px;
}
.material-tools, .catalog-tools {
  grid-template-columns: minmax(120px, .6fr) minmax(160px, 1fr);
  margin-bottom: 10px;
}
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 8px;
  max-height: 342px;
  overflow: auto;
  padding-right: 4px;
}
.material-grid.catalog { max-height: none; }
.material-card {
  position: relative;
  min-height: 92px;
  display: grid;
  align-content: end;
  overflow: hidden;
  padding: 8px;
  text-align: left;
}
.material-card .swatch {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  opacity: .9;
}
.material-card > span {
  position: relative;
  z-index: 1;
  padding: 7px;
  border-radius: 7px;
  background: rgba(5, 4, 3, .72);
  backdrop-filter: blur(8px);
}
.material-card.active {
  border-color: rgba(244, 123, 32, .96);
  box-shadow: inset 0 0 0 1px rgba(244, 123, 32, .55);
}
.material-card small {
  color: rgba(255, 248, 239, .58);
  font-size: 10px;
}

.breakdown, .summary, .price-editor, .assignment-list, .orders-list {
  display: grid;
  gap: 8px;
}
.break-row, .summary-row, .price-row, .assignment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}
.break-row span, .summary-row span, .price-row small, .assignment-row small, .order-card span, .order-card p {
  color: var(--muted);
  font-size: 12px;
}
.break-row b, .summary-row b, .price-row b, .assignment-row b, .order-card b {
  display: block;
}

.page-card {
  max-width: 1240px;
  margin: 0 auto;
}
.request-layout, .admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: 14px;
}
.admin-layout {
  grid-template-columns: 320px minmax(0, 1fr) minmax(0, 1fr);
}
.price-row, .assignment-row { grid-template-columns: minmax(0, 1fr) 130px; }
.order-card { padding: 10px; }
.message {
  min-height: 24px;
  margin-top: 10px;
  color: var(--hot-2);
  font-size: 13px;
  font-weight: 850;
}

@media (max-width: 1260px) {
  .topbar {
    grid-template-columns: 190px minmax(0, 1fr) 160px;
  }
  .calculator-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
  .preview { min-height: 510px; }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }
  .nav {
    grid-column: 1 / -1;
    width: 100%;
    justify-self: stretch;
    overflow-x: auto;
  }
  .nav button {
    flex: 1;
    min-width: 96px;
  }
  .calculator-layout,
  .request-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .center-stage,
  .left-rail,
  .right-rail {
    grid-column: auto;
    grid-row: auto;
  }
  .left-rail,
  .right-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .preview {
    height: 58vh;
    min-height: 430px;
  }
  .material-tools, .catalog-tools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 8px;
    gap: 8px;
  }
  .brand { gap: 8px; }
  .brand span {
    width: 58px;
    height: 38px;
    font-size: 17px;
  }
  .brand b, .top-total small { display: none; }
  .top-total {
    min-width: 108px;
    padding: 8px 10px;
  }
  .top-total strong { font-size: 18px; }
  main { padding: 7px; }
  .stage-head {
    display: grid;
  }
  .density { width: 100%; }
  .preview {
    height: 52vh;
    min-height: 390px;
  }
  .intro { min-height: 154px; }
  .intro h1 { font-size: 23px; }
  .choice-grid,
  .field-grid,
  .segmented,
  .density {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .segmented button {
    min-height: 40px;
    font-size: 12px;
  }
  .material-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
