:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --border: #e2e7ec;
    --border-strong: #d2d9e1;
    --text: #17202a;
    --muted: #697482;
    --muted-light: #8a95a1;
    --primary: #1f6feb;
    --primary-dark: #185fcf;
    --primary-soft: #edf4ff;
    --success: #167a4d;
    --shadow: 0 8px 26px rgba(23, 32, 42, 0.06);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

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

button,
input {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    height: 76px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--primary);
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.1;
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

.btn {
    min-height: 40px;
    padding: 0 16px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
}

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

.btn-secondary {
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
}

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

.estimate-page {
    width: min(1440px, calc(100% - 40px));
    margin: 28px auto 60px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.customer-card,
.estimate-output {
    padding: 24px;
}

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

.section-heading h2 {
    margin: 0;
    font-size: 17px;
}

.section-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.estimate-number {
    padding: 7px 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.form-grid {
    display: grid;
    gap: 16px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field > span {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

.field input,
.table-input,
.money-field input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: 0.15s ease;
}

.field input {
    padding: 0 12px;
}

.field input:focus,
.table-input:focus,
.money-field:focus-within input {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.field input::placeholder,
.table-input::placeholder,
.money-field input::placeholder {
    color: #a3acb6;
}

.work-section {
    margin-top: 30px;
}

.section-heading-main {
    margin-bottom: 14px;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-card {
    overflow: hidden;
}

.category-header {
    width: 100%;
    min-height: 68px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
}

.category-header:hover {
    background: var(--surface-soft);
}

.category-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-title-wrap strong {
    display: block;
    font-size: 15px;
}

.category-title-wrap small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.category-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 800;
}

.chevron {
    color: var(--muted);
    font-size: 20px;
}

.category-body {
    border-top: 1px solid var(--border);
}

.work-table,
.work-row {
    display: grid;
    grid-template-columns: minmax(190px, 1.5fr) 110px 100px 100px 85px 110px 110px;
    gap: 12px;
    align-items: center;
}

.work-table-header {
    min-height: 40px;
    padding: 0 20px;
    color: var(--muted-light);
    background: var(--surface-soft);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.work-row {
    min-height: 76px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.work-row:first-of-type {
    border-top: 0;
}

.work-name strong {
    display: block;
    font-size: 13px;
}

.work-name small,
.unit-price + small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.table-input {
    padding: 0 10px;
    text-align: right;
}

.muted-value {
    color: #a3acb6;
}

.calc-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.calc-sqft {
    color: #235f9e;
    background: #edf5ff;
}

.calc-linear {
    color: #53646f;
    background: #eef2f4;
}

.calc-qty {
    color: #5e4a8a;
    background: #f2edff;
}

.unit-price {
    font-size: 13px;
    font-weight: 800;
}

.row-total {
    font-size: 13px;
    font-weight: 800;
    text-align: right;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 16px;
    margin-top: 18px;
}

.materials-card,
.total-card {
    padding: 24px;
}

.money-field {
    height: 48px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
}

.money-field > span {
    padding-left: 14px;
    color: var(--muted);
    font-weight: 700;
}

.money-field input {
    height: 46px;
    padding: 0 14px 0 8px;
    border: 0;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    text-align: right;
}

.helper-text {
    margin: 9px 0 0;
    color: var(--muted-light);
    font-size: 11px;
}

.total-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.total-line,
.grand-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.total-line {
    padding: 7px 0;
    color: var(--muted);
    font-size: 14px;
}

.total-line strong {
    color: var(--text);
}

.divider {
    height: 1px;
    margin: 12px 0 14px;
    background: var(--border);
}

.grand-total span {
    font-size: 15px;
    font-weight: 800;
}

.grand-total strong {
    font-size: 25px;
    line-height: 1;
}

.estimate-output {
    margin-top: 18px;
}

.summary-preview {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfd;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.preview-title {
    margin-bottom: 22px;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.preview-category {
    margin-bottom: 24px;
}

.preview-category > strong {
    display: block;
    margin-bottom: 9px;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 6px 0;
    color: var(--muted);
}

.preview-totals {
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.preview-totals > div {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.preview-grand {
    margin-top: 7px;
    padding-top: 12px !important;
    border-top: 1px dashed var(--border-strong);
    color: var(--text);
    font-size: 15px;
    font-weight: 900;
}

@media (max-width: 1100px) {
    .work-table,
    .work-row {
        grid-template-columns: minmax(170px, 1.4fr) 100px 85px 85px 70px 95px 95px;
        gap: 8px;
    }

    .summary-grid {
        grid-template-columns: 1fr 340px;
    }
}

@media (max-width: 850px) {
    .topbar {
        height: auto;
        min-height: 70px;
        padding: 14px 18px;
        gap: 14px;
    }

    .topbar-actions .btn-secondary {
        display: none;
    }

    .estimate-page {
        width: min(100% - 24px, 720px);
        margin-top: 16px;
    }

    .form-grid-3 {
        grid-template-columns: 1fr;
    }

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

    .work-table-header {
        display: none;
    }

    .work-row {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 12px;
        padding: 16px;
    }

    .work-name {
        grid-column: 1 / -1;
    }

    .row-total {
        text-align: left;
    }
}

@media (max-width: 520px) {
    .topbar h1 {
        font-size: 19px;
    }

    .topbar-actions .btn-primary {
        padding: 0 12px;
    }

    .customer-card,
    .materials-card,
    .total-card,
    .estimate-output {
        padding: 18px;
    }

    .section-heading {
        flex-direction: column;
    }

    .estimate-number {
        align-self: flex-start;
    }

    .category-header {
        padding: 0 16px;
    }

    .work-row {
        grid-template-columns: 1fr 1fr;
    }

    .work-row > div:nth-child(2) {
        grid-column: 1 / -1;
    }

    .summary-preview {
        padding: 16px;
    }

    .preview-item {
        flex-direction: column;
        gap: 2px;
    }
}
