:root {
    color-scheme: light;
    --ink: #18202a;
    --muted: #617081;
    --line: #dbe3ea;
    --paper: #f6f8f7;
    --panel: #ffffff;
    --brand: #126b5f;
    --brand-dark: #0d4d45;
    --accent: #e1a13b;
    --danger: #b42318;
    --shadow: 0 18px 48px rgba(20, 31, 43, 0.12);
}

* {
    box-sizing: border-box;
}

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

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 32px clamp(18px, 5vw, 72px);
    background: #102927;
    color: white;
}

.app-header h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4.5rem);
    line-height: 1;
    letter-spacing: 0;
}

.app-header p {
    max-width: 740px;
    color: #c8d9d5;
}

.eyebrow {
    margin: 0 0 10px;
    color: #f1c46d !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.ghost-link,
button {
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: white;
    font-weight: 750;
    padding: 12px 16px;
    min-height: 44px;
    text-decoration: none;
    cursor: pointer;
}

.ghost-link {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    white-space: nowrap;
}

button:hover,
.ghost-link:hover {
    background: var(--brand-dark);
}

.shell {
    width: min(1180px, calc(100% - 28px));
    margin: 28px auto 64px;
    display: grid;
    gap: 24px;
}

.step-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    gap: 0;
    padding: 18px 8px 8px;
    border: 1px solid #dbe8d3;
    border-radius: 8px;
    background: #edf5e8;
}

.step-tabs button {
    display: grid;
    justify-items: center;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
    background: transparent;
    color: #7b8378;
    border: 0;
    border-radius: 8px;
    min-height: 76px;
    padding: 0 8px;
    text-align: center;
}

.step-tabs button::after {
    content: "";
    position: absolute;
    left: 50%;
    right: -50%;
    top: 21px;
    height: 4px;
    background: white;
    z-index: -1;
}

.step-tabs button:last-child::after {
    display: none;
}

.step-tabs button.is-complete::after,
.step-tabs button.is-active::after {
    background: #8ccf3f;
}

.step-tabs button.is-active,
.step-tabs button.is-complete {
    color: var(--brand-dark);
}

.step-tabs button.is-active {
    box-shadow: none;
}

.step-tabs button.is-complete span {
    background: #8ccf3f;
    color: white;
}

.step-tabs span {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    color: #b5bdae;
    border: 3px solid #f4f8ef;
    box-shadow: 0 2px 8px rgba(20, 31, 43, 0.08);
    font-size: 0;
}

.step-tabs span::before {
    content: "✓";
    font-size: 1.45rem;
    line-height: 1;
}

.step-tabs button.is-active span {
    background: #8ccf3f;
    color: white;
    border-color: #b7e27e;
}

.step-panel {
    display: none;
}

.step-panel.is-active {
    display: block;
}

.tab-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.secondary-button {
    background: #eef5f3;
    color: var(--brand-dark);
    border: 1px solid var(--line);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(18px, 4vw, 30px);
    box-shadow: var(--shadow);
}

.section-title {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 22px;
}

.section-title span {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #d8ebe7;
    color: var(--brand-dark);
    font-weight: 850;
    flex: 0 0 auto;
}

.section-title h2,
.model-card h3 {
    margin: 0 0 4px;
}

.section-title p,
.muted {
    margin: 0;
    color: var(--muted);
}

.split {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 18px;
}

.stack,
.controls-grid {
    display: grid;
    gap: 14px;
}

.controls-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    align-items: end;
}

label {
    display: grid;
    gap: 7px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #334151;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font: inherit;
    color: var(--ink);
    background: white;
}

textarea {
    resize: vertical;
}

.compact-card {
    align-content: start;
    background: #f7fbfa;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.recommendations,
.estimate-result {
    margin-top: 22px;
    display: grid;
    gap: 18px;
}

.summary-grid,
.models-grid,
.totals-grid {
    display: grid;
    gap: 14px;
}

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

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

.totals-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat,
.model-card,
.list-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fbfcfc;
}

.stat strong {
    display: block;
    font-size: 1.35rem;
    color: var(--brand-dark);
}

.model-card {
    display: grid;
    gap: 14px;
}

.model-card.is-disabled {
    border-color: #f2b8a8;
    background: #fff7f5;
    filter: grayscale(0.35);
}

.model-card.is-top-match {
    border-color: var(--brand);
    box-shadow: 0 12px 34px rgba(18, 107, 95, 0.16);
}

.model-card.is-disabled.is-top-match {
    border-color: #f2b8a8;
    box-shadow: none;
}

.model-card.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(225, 161, 59, 0.28);
}

.model-step-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.model-step-head h3 {
    margin: 0 0 4px;
}

.top-match-badge {
    display: inline-flex;
    width: max-content;
    border-radius: 999px;
    background: #d8ebe7;
    color: var(--brand-dark);
    font-size: 0.76rem;
    font-weight: 850;
    padding: 5px 8px;
    margin-bottom: 8px;
}

.model-card button:disabled {
    cursor: not-allowed;
    background: #9aa5af;
}

.match-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 8px;
    color: var(--brand-dark);
    font-weight: 800;
}

.match-status strong {
    color: var(--ink);
    font-size: 0.86rem;
}

.is-disabled .match-status {
    color: var(--danger);
}

.match-reasons {
    display: grid;
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.match-reasons li {
    display: grid;
    gap: 3px;
    border-left: 4px solid var(--danger);
    background: #fff3ef;
    color: var(--danger);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.84rem;
}

.match-reasons strong {
    color: #8a1f14;
}

.match-reasons span {
    color: #9f2f22;
}

.model-card img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 6px;
    background: #dbe3ea;
}

.model-card dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0;
}

.model-card dt {
    color: var(--muted);
    font-size: 0.78rem;
}

.model-card dd {
    margin: 0;
    font-weight: 800;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

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

.full-width-panel {
    width: 100%;
}

.select-list {
    display: grid;
    gap: 10px;
}

.select-item {
    grid-template-columns: auto minmax(0, 1fr) 76px;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.room-item {
    grid-template-columns: auto minmax(180px, 1fr) 76px 104px 112px 100px;
}

.room-item.single-floor-room {
    grid-template-columns: auto minmax(180px, 1fr) 76px 120px 110px;
}

.professional-item {
    grid-template-columns: auto minmax(180px, 1fr) 76px 128px 112px 148px;
}

.select-item.is-invalid {
    border-color: var(--danger);
    background: #fff3ef;
    color: var(--danger);
}

.select-item.is-required {
    border-color: #b9d8d2;
    background: #f2faf8;
}

.select-item input[readonly] {
    background: #eef5f3;
    color: var(--muted);
}

.select-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.select-item input[type="number"] {
    padding: 8px;
}

.select-item strong {
    color: var(--brand-dark);
    font-size: 0.86rem;
    text-align: right;
}

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

.estimate-levels button {
    display: grid;
    gap: 4px;
    align-content: center;
    text-align: left;
    background: white;
    color: var(--ink);
    border: 1px solid var(--line);
}

.estimate-levels button.is-active {
    background: #d8ebe7;
    border-color: var(--brand);
    box-shadow: inset 0 0 0 2px var(--brand);
}

.estimate-levels strong {
    color: var(--brand-dark);
}

.affected-cell {
    background: #fff4dc;
    color: #6f4300;
    font-weight: 850;
}

.warning-line {
    border: 1px solid #f2b8a8;
    background: #fff3ef;
    color: var(--danger);
    border-radius: 8px;
    padding: 12px;
    font-weight: 800;
}

.floor-counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.floor-counter {
    display: grid;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfc;
}

.floor-counter.is-invalid {
    border-color: var(--danger);
    background: #fff3ef;
    color: var(--danger);
}

.parts-list {
    display: grid;
    gap: 10px;
}

.layout-preview {
    display: grid;
    gap: 16px;
    padding: 4px 0;
}

.floor-preview {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfb;
    padding: 12px;
}

.floor-preview.is-invalid {
    border-color: var(--danger);
    background: #fff3ef;
}

.floor-preview header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--muted);
}

.floor-preview header strong {
    color: var(--ink);
}

.room-blocks {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    min-height: 170px;
    border: 1px dashed #c8d4dc;
    border-radius: 8px;
    padding: 10px;
    background: white;
}

.room-block {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 6px;
    border: 1px solid #9ec8c0;
    border-radius: 8px;
    background: #d8ebe7;
    color: var(--brand-dark);
    padding: 10px;
    text-align: center;
}

.room-block.is-invalid {
    border-color: var(--danger);
    background: #fff3ef;
    color: var(--danger);
}

.room-block strong {
    font-size: 0.9rem;
}

.room-block span {
    font-size: 0.78rem;
    font-weight: 800;
}

.part-impact {
    display: grid;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: white;
}

.part-impact span {
    color: var(--muted);
}

.part-impact em {
    color: var(--brand-dark);
    font-style: normal;
    font-weight: 800;
}

.estimate-hero {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) 1fr;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
    padding: 16px;
}

.estimate-hero img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 6px;
}

.estimate-hero h3 {
    margin: 0 0 8px;
}

.estimate-hero strong {
    display: block;
    margin-top: 12px;
    color: var(--brand-dark);
    font-size: 1.3rem;
}

.accordion-list {
    display: grid;
    gap: 10px;
}

.material-accordion {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    overflow: hidden;
}

.material-accordion summary {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    cursor: pointer;
    font-weight: 850;
    color: var(--brand-dark);
}

.material-accordion[open] summary {
    background: #eef5f3;
}

.subhead {
    margin: 4px 0 -8px;
}

.error-line {
    margin: 0;
    color: var(--danger);
    font-weight: 800;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

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

th {
    background: #eef5f3;
}

.material-input {
    min-width: 96px;
}

.admin-toolbar,
.button-row,
.print-actions {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.danger {
    background: var(--danger);
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    list-style: none;
}

.pill-list li {
    background: #eef5f3;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 10px;
}

@media (max-width: 900px) {
    .app-header,
    .estimate-hero,
    .split {
        grid-template-columns: 1fr;
    }

    .app-header {
        display: grid;
    }

    .controls-grid,
    .selection-grid,
    .estimate-levels,
    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

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

    .room-item,
    .professional-item {
        grid-template-columns: auto minmax(0, 1fr) 88px;
    }

    .room-item input[data-area-type],
    .room-item select,
    .professional-item input[data-salary-type],
    .professional-item input[data-days-type],
    .professional-item strong {
        grid-column: 2 / -1;
    }
}

@media (min-width: 901px) and (max-width: 1180px) {
    .models-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .app-header {
        padding: 24px 18px;
    }

    .controls-grid,
    .selection-grid,
    .estimate-levels,
    .summary-grid,
    .models-grid,
    .totals-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 16px;
    }

    table {
        font-size: 0.78rem;
    }

    .step-tabs {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px;
    }

    .step-tabs button {
        grid-template-columns: 44px 1fr;
        justify-items: start;
        min-height: 54px;
        text-align: left;
    }

    .step-tabs button::after {
        left: 30px;
        right: auto;
        top: 44px;
        width: 4px;
        height: 22px;
    }

    .tab-footer {
        align-items: stretch;
        flex-direction: column;
    }
}

@media print {
    .app-header,
    form,
    .print-actions,
    .ghost-link {
        display: none !important;
    }

    body {
        background: white;
    }

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