/* Idea 90 stage 5 — estimate wizard & sheet (variant D) */

.estimate-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.estimate-stepper {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.estimate-stepper span,
.estimate-stepper button {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--d-muted);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.estimate-stepper button:disabled {
  cursor: default;
  opacity: 0.6;
}

.estimate-stepper span i,
.estimate-stepper button i {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 600 12px var(--font-mono);
  font-style: normal;
  background: var(--d-soft);
  flex: none;
}

.estimate-stepper span.done,
.estimate-stepper button.done {
  color: var(--d-ink-2);
}

.estimate-stepper span.done i,
.estimate-stepper button.done i {
  background: var(--d-ok);
  color: #fff;
}

.estimate-stepper span.on,
.estimate-stepper button.on {
  color: var(--d-ink);
  font-weight: 600;
}

.estimate-stepper span.on i,
.estimate-stepper button.on i {
  background: var(--d-primary);
  color: #fff;
  box-shadow: 0 0 0 4px #e2eaf3;
}

.estimate-stepper .ln {
  width: 40px;
  height: 2px;
  background: var(--d-line);
  border-radius: 1px;
}

.wiz-d {
  container-type: inline-size;
  container-name: estimate-wiz;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* Две колонки по ширине main, не viewport — иначе при ~1100px окна итог уезжает вниз */
@container estimate-wiz (min-width: 680px) {
  .wiz-d {
    grid-template-columns: minmax(0, 1fr) min(320px, 36%);
  }
}

/* По умолчанию — столбик (узкая карточка при сайдбаре). Сетка только когда ширина самой card-d достаточна. */
.wiz-top-d {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.wiz-top-d > .field {
  min-width: 0;
  max-width: 100%;
}

.wiz-top-d__region {
  width: min(100%, 280px);
}

.estimate-wizard-field--type .seg-d--wrap {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.estimate-wizard-field--type .seg-d--wrap button {
  flex: 1 1 auto;
  min-width: 0;
}

@container estimate-card (min-width: 560px) {
  .wiz-top-d {
    display: grid;
    grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
    gap: 12px 16px;
    align-items: end;
  }

  .wiz-top-d__region {
    grid-column: 1;
    grid-row: 1;
    width: auto;
  }

  .estimate-wizard-field--type {
    grid-column: 2;
    grid-row: 1;
  }

  .estimate-wizard-field--materials {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .estimate-wizard-field--type .seg-d--wrap button {
    flex: 0 1 auto;
  }
}

.estimate-page .p-head-d {
  align-items: flex-start;
}

@media (min-width: 841px) {
  .estimate-page .p-head-d {
    flex-wrap: nowrap;
  }

  .estimate-page .estimate-stepper {
    flex-shrink: 0;
    margin-top: 4px;
  }
}

.estimate-wizard-card {
  container-type: inline-size;
  container-name: estimate-card;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.estimate-wizard-field--seg {
  min-width: 0;
}

.estimate-wizard-field--seg > label,
.estimate-wizard-field--seg > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--d-ink-2);
  margin-bottom: 7px;
}

.seg-d--wrap {
  flex-wrap: wrap;
  max-width: 100%;
}

.seg-d--wrap button {
  padding: 9px 12px;
  font-size: 13px;
}

.estimate-wizard-details {
  width: 100%;
  margin: 4px 0 8px;
  font-size: 14px;
}

.estimate-wizard-details summary {
  cursor: pointer;
  color: var(--d-primary);
  font-weight: 600;
  list-style: none;
  padding: 4px 0;
}

.estimate-wizard-details summary::-webkit-details-marker {
  display: none;
}

.estimate-wizard-details-body {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 0 4px;
}

.estimate-wizard-field--area {
  width: min(100%, 140px);
}

.estimate-wizard-field--area .field-hint {
  max-width: 28ch;
  margin: 6px 0 0;
}

.estimate-wizard-field--condition {
  flex: 1 1 200px;
}

.estimate-page input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.estimate-page input[type="number"]::-webkit-outer-spin-button,
.estimate-page input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rp-d .mk {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.estimate-wizard-rooms-head {
  margin: 12px 0 10px;
}

.estimate-wizard-rooms-head h3 {
  margin: 0;
  font: var(--w-display2) 18px var(--font-display);
  letter-spacing: -0.02em;
}

.estimate-wizard-rooms-head a {
  font-size: 14px;
  font-weight: 600;
  color: var(--d-primary);
  text-decoration: none;
  white-space: nowrap;
}

.estimate-wizard-rooms-head a:hover {
  text-decoration: underline;
}

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

/* Legacy class .input → D (selects were native gray) */
.estimate-page .field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--d-ink-2);
  margin-bottom: 7px;
}

.estimate-page .input,
.estimate-page select.input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: 500 16px var(--font-body);
  border: var(--input-border);
  background-color: var(--input-bg);
  border-radius: var(--r-input);
  padding: 13px 14px;
  color: var(--d-ink);
  margin: 0;
}

.estimate-page select.input {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235B6B7C' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.estimate-page .input:focus,
.estimate-page select.input:focus {
  outline: 0;
  border-color: var(--d-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--d-primary) 14%, transparent);
}

@media (max-width: 720px) {
  .estimate-wizard-finishes {
    grid-template-columns: 1fr;
  }

}

.estimate-room-area-input {
  border: 0;
  padding: 0;
  background: transparent;
  width: 4.5rem;
  text-align: right;
  font: inherit;
  box-shadow: none;
}

.estimate-room-area-input:focus {
  outline: none;
}

.estimate-total-label {
  font-size: 14px;
}

.estimate-total-cta {
  width: 100%;
  margin-top: 4px;
}

.estimate-total-foot {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.estimate-plan-rooms-hint {
  margin: 0 0 10px;
}

.estimate-plan-room {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.estimate-plan-room__type {
  font-size: 12px;
  font-weight: 500;
  color: var(--d-muted);
}

.rooms-pick-d {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rp-d {
  display: grid;
  grid-template-columns: auto 1fr 120px;
  gap: 14px;
  align-items: center;
  background: var(--d-soft);
  border-radius: var(--r-input);
  padding: 10px 12px;
}

.rp-d .tg {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--d-line);
  position: relative;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.rp-d .tg::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: left 160ms ease;
}

.rp-d.on .tg {
  background: var(--d-primary);
}

.rp-d.on .tg::after {
  left: 21px;
}

.rp-d .nm {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  min-width: 0;
}

.rp-d .area {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--d-card);
  border-radius: calc(var(--r-input) - 4px);
  padding: 8px 10px;
  font: 500 15px var(--font-mono);
  justify-content: flex-end;
}

.rp-d .area small {
  color: var(--d-muted);
  font-size: 12px;
}

.rp-d.off {
  opacity: 0.55;
}

.rp-d.off .area {
  background: transparent;
}

.estimate-total-d {
  position: sticky;
  top: 20px;
}

.estimate-total-d .big {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 8px 0 4px;
}

.estimate-total-d .big .estimate-total-amount {
  font: 800 42px/1 var(--font-display);
  letter-spacing: -0.04em;
  color: var(--d-ink);
}

.estimate-total-d .big .estimate-total-amount.is-empty {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--d-muted);
}

.estimate-total-d .big small {
  font: 500 15px var(--font-body);
  color: var(--d-muted);
  letter-spacing: 0;
}

.split-d {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin: 14px 0 10px;
}

.split-d i {
  display: block;
}

.kv-d {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  font-size: 14px;
}

.kv-d li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px solid var(--d-line-soft);
}

.kv-d li:first-child {
  border-top: 0;
}

.kv-d b {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 13px;
}

.sheet-top-d {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.sheet-top-d .big {
  font: var(--w-display) 40px/1 var(--font-display);
  letter-spacing: -0.04em;
  margin: 0;
}

.sheet-top-d .big small {
  font: 500 15px var(--font-body);
  color: var(--d-muted);
  letter-spacing: 0;
  margin-left: 6px;
}

.disclaim-d {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: color-mix(in srgb, var(--d-accent) 14%, white);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.45;
}

.tbl-d {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tbl-d th {
  text-align: left;
  font: 500 11px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--d-muted);
  padding: 10px;
  border-bottom: 1px solid var(--d-line);
}

.tbl-d td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--d-line-soft);
  vertical-align: middle;
}

.tbl-d td.n,
.tbl-d th.n {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
}

.tbl-d tr.room td {
  background: var(--d-soft);
  font-weight: 600;
  border-bottom: 0;
}

.tbl-d tr.room td:first-child {
  border-radius: 12px 0 0 12px;
}

.tbl-d tr.room td:last-child {
  border-radius: 0 12px 12px 0;
}

.tbl-d tr.off td {
  color: var(--d-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--d-muted) 50%, transparent);
}

.cb-d {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: var(--d-primary);
  color: #fff;
  font-size: 12px;
}

.cb-d.no {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--d-line);
}

.estimate-sheet {
  display: grid;
  gap: 0;
  font-size: 14px;
}

.estimate-sheet-head,
.estimate-sheet-row {
  display: grid;
  grid-template-columns: 36px 1fr 72px 88px 88px 88px 88px;
  gap: 8px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--d-line-soft);
}

@media (max-width: 900px) {
  .estimate-sheet-head {
    display: none;
  }

  .estimate-sheet-row {
    grid-template-columns: 1fr;
    padding: 14px;
    border: 1px solid var(--d-line-soft);
    border-radius: var(--r-input);
    margin-bottom: 8px;
  }
}

.estimate-sheet-head {
  font: 500 11px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--d-muted);
}

.estimate-sheet-row--out {
  opacity: 0.55;
  text-decoration: line-through;
}

.estimate-sheet-sum {
  font-family: var(--font-mono);
  text-align: right;
}

.estimate-sticky-mobile {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 12px 0 4px;
  background: linear-gradient(transparent, var(--d-surface) 24%);
}

@media (min-width: 901px) {
  .estimate-sticky-mobile {
    position: static;
    padding: 0;
    background: none;
  }
}
