:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #607086;
  --line: #d9e1ea;
  --line-strong: #b9c5d1;
  --primary: #1b5f8f;
  --primary-dark: #0f476e;
  --teal: #16806f;
  --gold: #b36a13;
  --brick: #b54435;
  --plum: #7653a5;
  --success: #0f766e;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(245, 247, 250, 0.96)),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: 0;
  margin-bottom: 12px;
  max-width: 1050px;
}

.subhead {
  color: var(--muted);
  font-size: 1.04rem;
  max-width: 760px;
  margin-bottom: 0;
}

.version-pill {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
  padding: 8px 12px;
  white-space: nowrap;
  background: var(--surface);
}

.workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0 24px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  min-width: 0;
}

.step-number {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  flex: 0 0 28px;
  height: 28px;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
}

.step.is-complete {
  border-color: rgba(22, 128, 111, 0.35);
  color: var(--ink);
}

.step.is-complete .step-number {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.step-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.72fr);
  gap: 24px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 22px;
}

.panel-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-title {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.panel-title h2,
.panel-title h3 {
  font-size: 1.13rem;
  line-height: 1.2;
  margin: 0;
}

.icon {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 34px;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.icon svg {
  display: block;
  height: 18px;
  width: 18px;
}

.icon-blue {
  background: #e8f2fb;
  color: var(--primary);
}

.icon-teal {
  background: #e4f5f2;
  color: var(--teal);
}

.icon-gold {
  background: #fff3df;
  color: var(--gold);
}

.icon-plum {
  background: #f0ebf9;
  color: var(--plum);
}

.icon-neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.location-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field-label {
  color: #2f3b4d;
  font-size: 0.86rem;
  font-weight: 800;
}

.input,
.select {
  appearance: none;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

.select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.input:focus,
.select:focus,
.tier-button:focus,
.action:focus,
.calculate-button:focus,
.assumptions-toggle:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 95, 143, 0.16);
  outline: none;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.select:disabled {
  background-color: #eef2f6;
  color: #8390a2;
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
}

.error {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
}

.location-summary {
  align-items: center;
  background: #e8f7f3;
  border: 1px solid #c8e9e1;
  border-radius: var(--radius);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 16px;
  padding: 12px 14px;
}

.location-summary span {
  color: #15695e;
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
}

.location-summary strong {
  color: #064d45;
  display: block;
  font-size: 1.2rem;
  text-align: right;
}

.section-block {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.section-block:first-child {
  border-top: 0;
  padding-top: 0;
}

.section-head {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h3 {
  font-size: 1rem;
  margin: 0;
}

.section-head span {
  color: var(--muted);
  font-size: 0.8rem;
}

.tier-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tier-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-soft);
  min-width: 0;
}

.tier-options {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 8px;
}

.tier-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  min-height: 74px;
  overflow: hidden;
  padding: 8px 6px;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.tier-button strong {
  color: inherit;
  display: block;
  font-size: 0.79rem;
  margin-bottom: 4px;
  text-transform: capitalize;
}

.tier-button span {
  display: block;
  font-size: 0.69rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tier-button.is-active {
  background: #e8f2fb;
  border-color: #8ebfe4;
  color: var(--primary-dark);
}

.override-row {
  margin-top: 9px;
}

.override-row .input {
  font-size: 0.82rem;
  min-height: 34px;
  padding: 7px 9px;
}

.assumptions-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: inherit;
  display: flex;
  justify-content: space-between;
  padding: 0;
  text-align: left;
  width: 100%;
}

.assumptions-body {
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  gap: 14px;
  font-size: 0.9rem;
  margin-top: 16px;
  padding-top: 16px;
}

.assumptions-body h4 {
  color: var(--ink);
  margin: 0 0 6px;
}

.assumptions-body ul {
  margin: 0;
  padding-left: 20px;
}

.estimate-column {
  min-width: 0;
  position: sticky;
  top: 18px;
}

.left-column {
  min-width: 0;
}

.calculate-button {
  align-items: center;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  color: #fff;
  display: flex;
  font-size: 1rem;
  font-weight: 900;
  gap: 10px;
  justify-content: center;
  min-height: 54px;
  width: 100%;
}

.calculate-button svg {
  height: 20px;
  width: 20px;
}

.calculate-button:hover {
  background: var(--primary-dark);
}

.calculate-button:disabled {
  background: #cbd5e1;
  border-color: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}

.validation-note {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 10px 0 0;
  text-align: center;
}

.results-empty {
  align-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  min-height: 260px;
  padding: 28px;
  text-align: center;
}

.results-empty div {
  margin: 0 auto;
  max-width: 420px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.action {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  gap: 7px;
  min-height: 36px;
  padding: 7px 10px;
  text-decoration: none;
}

.action svg {
  height: 16px;
  width: 16px;
}

.action-primary {
  background: #e8f2fb;
  border-color: #c7dff2;
  color: var(--primary-dark);
}

.total-band {
  background:
    linear-gradient(135deg, rgba(27, 95, 143, 0.11), rgba(22, 128, 111, 0.1)),
    var(--surface-soft);
  border: 1px solid #d8e7ef;
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 22px;
}

.total-band span {
  color: var(--muted);
  display: block;
  font-weight: 800;
  margin-bottom: 5px;
}

.total-band strong {
  color: var(--ink);
  display: block;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 1;
}

.stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.section-stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.stat strong {
  display: block;
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.stat small {
  color: var(--muted);
}

.stat-materials {
  background: #fff7e9;
  border-color: #f4ddb9;
}

.stat-labor {
  background: #fff0ee;
  border-color: #f1cbc5;
}

.stat-shell {
  background: #edf6fd;
  border-color: #c9e1f3;
}

.stat-interior {
  background: #eaf8f5;
  border-color: #cce8e3;
}

.stat-trim {
  background: #f2eef9;
  border-color: #ded2ef;
}

.chart-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.chart-card h3 {
  font-size: 0.92rem;
  margin-bottom: 10px;
}

.donut-wrap {
  display: grid;
  gap: 12px;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
}

.donut {
  height: 140px;
  transform: rotate(-90deg);
  width: 140px;
}

.donut-bg {
  fill: none;
  stroke: #e7edf4;
  stroke-width: 16;
}

.donut-segment {
  fill: none;
  stroke-linecap: butt;
  stroke-width: 16;
}

.legend {
  display: grid;
  gap: 7px;
}

.legend-row {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  font-size: 0.8rem;
}

.legend-swatch {
  border-radius: 999px;
  height: 10px;
  width: 10px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  overflow: auto;
  max-height: 520px;
}

table {
  border-collapse: collapse;
  min-width: 860px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: #334155;
  font-size: 0.77rem;
  letter-spacing: 0.02em;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

td {
  font-size: 0.86rem;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  text-transform: capitalize;
}

.badge-materials {
  background: #fff0d1;
  color: #8a4c08;
}

.badge-labor {
  background: #ffe2de;
  color: #982d22;
}

.toast {
  background: #152033;
  border-radius: var(--radius);
  bottom: 20px;
  box-shadow: var(--shadow);
  color: #fff;
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 10;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .estimate-column {
    position: static;
  }
}

@media (max-width: 840px) {
  .app-shell {
    padding: 18px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .version-pill {
    justify-self: start;
  }

  .workflow,
  .form-grid,
  .location-grid,
  .tier-grid,
  .chart-grid,
  .stat-grid,
  .section-stat-grid {
    grid-template-columns: 1fr;
  }

  .workflow {
    gap: 8px;
  }

  .donut-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .legend {
    justify-self: stretch;
    width: 100%;
  }

  .actions {
    justify-content: stretch;
  }

  .action {
    flex: 1 1 120px;
    justify-content: center;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    max-width: none;
    padding: 0;
  }

  .left-column,
  .workflow,
  .calculate-panel,
  .actions,
  .version-pill,
  .toast {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .topbar {
    display: block;
    margin-bottom: 16px;
  }

  h1 {
    font-size: 26px;
  }

  .table-wrap {
    max-height: none;
  }
}
