:root {
  color-scheme: light;
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-soft: #eef6f5;
  --text: #17201f;
  --muted: #64716f;
  --line: #d9e2e0;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff4f1;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(17, 32, 31, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.door-estimate-tool {
  min-height: 100vh;
  padding: 32px 16px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0) 320px), var(--bg);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

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

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

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

.subheading {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.quote-card {
  min-width: 230px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quote-card span,
.quote-card small,
.summary-card span,
.field small {
  color: var(--muted);
}

.quote-card span,
.quote-card small {
  display: block;
  font-size: 0.82rem;
}

.quote-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1.1rem;
}

.estimate-form,
.table-panel {
  display: grid;
  gap: 18px;
}

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.step-label {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.locked {
  background: #f0f2f2;
  color: var(--muted);
}

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

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

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

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  color: var(--text);
  font-size: 0.91rem;
  font-weight: 700;
}

.field strong {
  color: var(--danger);
}

input,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffafa;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset:disabled {
  opacity: 0.58;
}

.product-panel.is-disabled {
  background: linear-gradient(180deg, #ffffff, #f8fbfb);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.22);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-soft);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(180, 35, 24, 0.15);
}

.table-panel {
  margin-top: 18px;
}

.table-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.estimate-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

.estimate-table th,
.estimate-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.estimate-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf6f5;
  color: #20302e;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.estimate-table tr:last-child td {
  border-bottom: 0;
}

.estimate-table td {
  color: #263432;
  font-size: 0.92rem;
}

.empty-row td {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.table-action {
  min-height: 38px;
  padding: 9px 12px;
  font-size: 0.84rem;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.filename {
  display: inline-block;
  max-width: 170px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  vertical-align: middle;
}

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

.summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.summary-card span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.84rem;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  font-size: 1.4rem;
}

.summary-total {
  background: var(--accent);
  color: #ffffff;
}

.summary-total span {
  color: rgba(255, 255, 255, 0.82);
}

.danger-zone {
  display: flex;
  justify-content: flex-end;
  margin: 18px 0 0;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 700;
  animation: slideIn 180ms ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 32, 31, 0.48);
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: min(460px, 100%);
  padding: 22px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(17, 32, 31, 0.22);
}

.modal p {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-actions,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.modal-header {
  justify-content: space-between;
  margin-bottom: 16px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.design-modal {
  width: min(720px, 100%);
}

.design-preview {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #f9fbfb;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.design-preview img {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  border-radius: var(--radius);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .quote-card {
    min-width: 0;
  }

  .product-grid,
  .form-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .door-estimate-tool {
    padding: 20px 12px;
  }

  .panel {
    padding: 18px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .action-row,
  .danger-zone,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .estimate-table th,
  .estimate-table td {
    padding: 12px;
  }
}
