:root {
    color-scheme: light;
    --ink: #213128;
    --muted: #53635a;
    --forest: #17271f;
    --accent: #e79c65;
    --paper: #f6f4ee;
    --line: #dedfd5;
    font: 16px/1.5 system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, p { margin: 0 0 .65rem; }
h1 { font-size: clamp(1.85rem, 4vw, 3rem); letter-spacing: -.05em; line-height: 1.1; }
h2 { font-size: 1.12rem; letter-spacing: -.015em; }
small { display: block; color: var(--muted); }
button, input, textarea, select { font: inherit; }
button {
    padding: .56rem .9rem;
    cursor: pointer;
    background: var(--forest);
    color: white;
    font-weight: 650;
    border: 1px solid transparent;
    border-radius: .45rem;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid #bd642e; outline-offset: 2px; }
.secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.primary { background: var(--accent); color: #2e1d12; }
label { display: grid; gap: .28rem; font-size: .9rem; font-weight: 600; min-width: 0; }
input, textarea, select {
    display: block;
    width: 100%;
    background: #fff;
    color: var(--ink);
    border: 1px solid #aeb6ac;
    border-radius: .4rem;
    min-height: 44px;
    padding: .45rem .65rem;
}
textarea { min-height: 6rem; resize: vertical; }
.error { color: #9d3227; font-size: .92rem; }
.error:empty, #notice:empty { display: none; }
.loading { padding: 2rem; }
.brand img { display: block; width: 7rem; max-width: 100%; height: auto; border-radius: .35rem; }
.sidebar .brand img, .login-brand .brand img { width: 7.5rem; }
.workspace { min-height: 100dvh; display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
.sidebar { padding: 1.3rem; display: flex; flex-direction: column; gap: 1.3rem; background: var(--forest); color: #fff; }
.sidebar small, .login-brand small { color: #c4cec5; }
.sidebar nav { display: grid; gap: .3rem; }
.sidebar nav button { text-align: left; display: flex; align-items: center; gap: .65rem; padding-inline: .7rem; white-space: nowrap; }
.sidebar nav span { width: 1.15rem; text-align: center; color: var(--accent); }
.sidebar nav [aria-current] { background: #33463a; border-color: #546858; }
.sidebar .secondary { color: white; border-color: #56665b; }
.profile { margin-top: auto; display: flex; align-items: center; gap: .7rem; overflow-wrap: anywhere; }
.avatar { flex: 0 0 2.2rem; text-align: center; line-height: 2.2rem; border-radius: 50%; background: #526456; }
.topbar { background: #fffdf8; border-bottom: 1px solid var(--line); padding: .9rem clamp(1rem, 4vw, 3rem); display: flex; justify-content: space-between; font-weight: 650; }
.topbar span { color: var(--muted); font-size: .9rem; }
.content { max-width: 78rem; margin: auto; padding: clamp(1rem, 4vw, 3rem); }
.page-title, .panel-heading, .row { display: flex; justify-content: space-between; align-items: center; gap: .7rem; flex-wrap: wrap; }
.page-title { margin-bottom: 1.5rem; }
.page-title p { color: var(--muted); margin: 0; }
.panel-heading { margin-bottom: .65rem; }
.panel-heading h2 { margin: 0; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit,minmax(8.5rem,1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stats section, .panel { background: #fffdf8; border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; overflow-wrap: anywhere; }
.stats strong { display: block; font-size: 2rem; line-height: 1.25; }
.stats span, .empty { color: var(--muted); }
.panel { margin-bottom: 1rem; }
.row { padding-block: .75rem; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.empty { padding: 1.25rem 0; margin: 0; }
.badge { color: #384d40; background: #e8eee6; border-radius: 1rem; padding: .18rem .55rem; font-size: .83rem; white-space: nowrap; }
.multiline { white-space: pre-wrap; }
.totals { display: grid; grid-template-columns: auto auto; justify-content: end; gap: .3rem 1.3rem; margin-bottom: 0; }
.totals dd { text-align: right; margin: 0; }
dialog { border: 1px solid var(--line); border-radius: .85rem; width: min(38rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 1.25rem; color: var(--ink); }
dialog::backdrop { background: #142219a8; }
form { display: grid; gap: .85rem; }
form > button, .proposal > button { justify-self: start; }
.fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(9.5rem,1fr)); gap: .65rem; }
fieldset { margin: 0 0 .65rem; padding: .75rem; min-width: 0; border: 1px solid var(--line); border-radius: .5rem; }
fieldset button, .proposal > button { margin-top: .65rem; }
#notice { position: fixed; bottom: 1rem; right: 1rem; max-width: calc(100% - 2rem); border-radius: .5rem; padding: .65rem 1rem; background: var(--forest); color: white; }
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100dvh; }
.login-brand { background: var(--forest); color: white; padding: clamp(1.5rem, 6vw, 5rem); display: grid; align-content: space-between; gap: 3rem; }
.login-brand h1 { font-size: clamp(3rem, 7vw, 6rem); color: #fff9ec; }
.login-brand p { max-width: 27rem; color: #d9e0da; }
.login-content { display: grid; place-items: center; padding: 1.5rem; }
.login-content form { width: min(100%, 24rem); background: #fffdf8; border: 1px solid var(--line); border-radius: .85rem; padding: clamp(1.2rem, 4vw, 2rem); }
.login-content h2 { font-size: 1.65rem; }
@media (max-width: 760px) {
    .workspace, .login { grid-template-columns: 1fr; }
    .workspace { display: block; }
    .sidebar { display: grid; grid-template-columns: minmax(0,1fr) auto; padding: .85rem; gap: .65rem; align-items: center; }
    .sidebar nav { grid-row: 2; grid-column: 1 / -1; display: flex; overflow-x: auto; }
    .sidebar nav button { flex: 0 0 auto; font-size: .9rem; }
    .sidebar .profile, .topbar { display: none; }
    .login { min-height: 100dvh; grid-template-rows: auto 1fr; }
    .login-brand { gap: 1.5rem; }
}
@media print {
    body:has(.proposal) #app, #notice, .proposal button { display: none; }
    #editor:has(.proposal) { position: static; display: block; max-height: none; overflow: visible; width: auto; border: 0; }
    #editor::backdrop { background: transparent; }
}

.customer-layout { display: grid; grid-template-columns: minmax(12rem, 1fr) minmax(0, 2.4fr); gap: 1rem; align-items: start; }
.customer-directory, .customer-details { min-width: 0; overflow-wrap: anywhere; }
#customer-results { display: grid; gap: .25rem; margin-top: .75rem; max-height: 64vh; overflow: auto; }
.customer-choice { width: 100%; text-align: left; background: transparent; color: var(--ink); border: 1px solid transparent; padding: .65rem; }
.customer-choice:hover, .customer-choice[aria-pressed="true"] { background: #e8eee6; color: var(--forest); border-color: var(--line); }
.customer-choice small { display: block; }
.record-link { text-align: left; color: var(--forest); background: transparent; border: 0; padding: 0; text-decoration: underline; }
.record-link:hover { background: transparent; color: var(--ink); }
@media (max-width: 900px) {
    .customer-layout { grid-template-columns: 1fr; }
    #customer-results { max-height: 16rem; }
}

.dashboard-tabs { display: flex; flex-wrap: wrap; gap: .55rem; margin-bottom: 1rem; }
.dashboard-tabs [aria-current] { background: var(--forest); color: white; }
.mobile-customer-back { display: none; }
@media (max-width: 760px) {
    .customer-selected .customer-directory { display: none; }
    .mobile-customer-back { display: inline-block; margin-bottom: .75rem; }
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .35rem; margin: .75rem 0; text-align: center; }
.calendar-day { min-height: 2.7rem; padding: .25rem; }
.calendar-day small { display: block; color: inherit; }
.calendar-day[aria-pressed="true"] { background: var(--forest); color: white; }
.crew-choice { display: flex; gap: .5rem; align-items: center; }
.crew-choice input { width: auto; }

#estimate-calculators { width: 100%; min-height: 450px; border: 0; display: block; }

.customer-info-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.customer-info-layout > .panel { min-width: 0; }
.customer-info-addresses { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.customer-log-entry { display: grid; gap: .15rem; border-color: var(--line); font-weight: 400; }
.customer-log-addresses { margin-top: .2rem; }
@media (max-width: 900px) {
    .customer-info-layout { grid-template-columns: 1fr; }
}

.customer-info-editor .danger { color: #9d3227; border-color: #cda29c; }

.estimate-proposal { display:grid; grid-template-columns:minmax(13rem,16rem) minmax(0,1fr); gap:1rem; align-items:start; }
.proposal-controls { display:grid; gap:.65rem; }
.proposal-controls h2 { margin:0; }
.proposal-controls button { width:100%; text-align:left; }
.proposal-tabs { display:grid; gap:.35rem; }
.proposal-tabs button[aria-pressed="false"] { background:transparent; border-color:var(--line); color:var(--ink); }
.proposal-price-toggle { margin:.4rem 0; }
.proposal-document { border-top:4px solid var(--forest); padding:clamp(1rem,3vw,2rem); }
.proposal-document > header { border-bottom:1px solid var(--line); padding-bottom:.7rem; }
#proposal-title { font-size:clamp(1.65rem,4vw,2.6rem); margin:.7rem 0 .35rem; }
.proposal-document h3 { font-size:1.02rem; margin:.85rem 0 .4rem; }
.proposal-area { border:1px solid var(--line); border-radius:.5rem; margin:.6rem 0; overflow:hidden; }
.proposal-area h3 { background:#e8eee6; padding:.5rem .7rem; margin:0; }
.proposal-area dl { display:grid; grid-template-columns:7rem minmax(0,1fr); gap:.45rem .65rem; margin:0; padding:.65rem .7rem; }
.proposal-area dt { font-weight:650; color:var(--muted); }
.proposal-area dd { margin:0; white-space:pre-wrap; }
.proposal-review { color:#773411; background:#fff0dd; padding:.55rem .7rem; border-radius:.35rem; }
.proposal-money .row { padding-inline:.7rem; }
.proposal-total { background:var(--forest); border-radius:.35rem; color:white; }
.proposal-money > small { margin-top:.35rem; }
.estimate-internal > summary { cursor:pointer; font-weight:650; }
@media(max-width:900px) { .estimate-proposal { grid-template-columns:1fr; } }
@media(max-width:440px) { .proposal-area dl { grid-template-columns:1fr; } }
@media print {
    body:has(.estimate-proposal):not(:has(#editor[open])) { background:white; }
    body:not(:has(#editor[open])) .workspace:has(.estimate-proposal) { display:block; }
    body:not(:has(#editor[open])) .workspace:has(.estimate-proposal) > .sidebar,
    body:not(:has(#editor[open])) .main:has(.estimate-proposal) > .topbar,
    body:not(:has(#editor[open])) .content:has(.estimate-proposal) > :not(.estimate-proposal),
    .estimate-proposal .proposal-controls, .estimate-proposal .proposal-review { display:none; }
    .content:has(.estimate-proposal) { max-width:none; padding:0; }
    .estimate-proposal { display:block; }
    .proposal-document { border:0; background:white; padding:0; }
    .proposal-area, .proposal-money { break-inside:avoid; }
    .proposal-total { color:var(--ink); background:white; border-top:1px solid var(--ink); }
}

.rate-table { overflow-x: auto; }
.rate-table table { width: 100%; border-collapse: collapse; text-align: left; }
.rate-table th, .rate-table td { padding: .65rem; border-bottom: 1px solid var(--line); }
.rate-table .actions { flex-wrap: nowrap; }
.rate-fields > label { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 1.7fr); align-items: center; gap: .5rem; }
.rate-fields input[type=checkbox] { justify-self: start; width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: #b85a1d; }
#rate-prep-help { font-size: .9rem; }
@media (max-width: 480px) {
    .rate-fields > label { grid-template-columns: 1fr; }
}

.material-category > summary { font-weight: 700; font-size: 1.1rem; cursor: pointer; }
.material-category[open] > summary { margin-bottom: .75rem; }

dialog:has(.crew-plan-grid, .crew-plan-edit) { width: min(72rem, calc(100% - 1.5rem)); }
.crew-plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.crew-plan-grid > * { min-width: 0; }
.crew-area { padding: .75rem; margin: 0 0 .6rem; border: 1px solid var(--line); border-radius: .65rem; }
.crew-area h3, .crew-area p { margin: 0 0 .35rem; }
.crew-color-row { margin-bottom: .75rem; }
.crew-color-row button { margin-top: .5rem; }
.crew-manual-provider[hidden] { display: none; }
@media (max-width: 760px) { .crew-plan-grid { grid-template-columns: 1fr; } }

button.recycle-confirm { color: #fff; background: #922f27; border-color: #922f27; }

.estimate-bin .danger { color: #9d3227; border-color: #cda29c; }

.website-request > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.request-reference { margin-block: .7rem; }
.request-reference summary { cursor: pointer; }
.request-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.expenses-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(14rem,19rem); gap:1rem; align-items:start; }
.expense-job-picker label { margin:0; }
.expense-table { overflow:auto; }
.expense-table table { width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.expense-table th, .expense-table td { padding:.55rem; border-bottom:1px solid var(--line); text-align:left; }
.expense-table thead { background:#edf1e9; }
.expense-table th { white-space:nowrap; }
.expense-table .expense-number { text-align:right; white-space:nowrap; }
.expense-summary-row { display:flex; justify-content:space-between; gap:.65rem; padding:.45rem 0; border-bottom:1px solid var(--line); }
.expense-summary-row strong { white-space:nowrap; }
.expense-chart { border-bottom:1px solid var(--line); margin-bottom:1rem; padding-bottom:1rem; }
.expense-chart .expense-table { margin-top:.5rem; }
.expense-new-vendor { border:1px solid var(--line); border-radius:.5rem; padding:.65rem; margin-bottom:.65rem; }
@media (max-width:1020px) { .expenses-layout { grid-template-columns:minmax(0,1fr); } }

.content:has(.estimate-workspace-header) { padding-block-start: clamp(.85rem, 2vw, 1.5rem); }
.estimate-workspace-header .page-title { margin-bottom: .55rem; }
.estimate-workspace-header h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.25rem); overflow-wrap: anywhere; }
.workspace-exit { margin-top: .75rem; }
#estimate-details { background: #fffdf8; }
#estimate-details h2 { margin: 0; font-size: 1.6rem; }
#estimate-details .actions { justify-content: flex-end; }
.estimate-pricing-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.estimate-pricing-fields label { align-content: space-between; }
@media (max-width: 420px) {
    .estimate-pricing-fields { grid-template-columns: 1fr; }
}

.proposal-scope-list { margin:0; padding-inline-start:1.15rem; }
.proposal-scope-list li + li { margin-top:.2rem; }
.proposal-surface-name { display:inline-block; }
.proposal-surface-name::first-letter { text-transform:uppercase; }
.proposal-room-table { width:100%; border-collapse:collapse; white-space:normal; }
.proposal-room-table th, .proposal-room-table td { text-align:left; vertical-align:top; padding:.25rem .4rem; }
.proposal-room-table thead { border-bottom:1px solid var(--line); }

.invoice-panel, .invoice-payment-history { max-width: 54rem; }
.invoice-sheet { padding: clamp(.25rem, 2vw, 1.25rem); }
.invoice-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .85rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--forest);
}
.invoice-header h2 { font-size: 1.55rem; margin: 0; }
.invoice-header p { color: var(--muted); margin: 0; }
.invoice-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; padding: 1rem 0; }
.invoice-summary h3 { color: var(--muted); font-size: .9rem; margin: 0 0 .25rem; }
.invoice-summary p, .invoice-thanks p { margin: 0; }
.invoice-totals dt { text-align: right; }
.invoice-balance { border-top: 1px solid var(--line); padding-top: .35rem; font-weight: 750; }
.invoice-thanks { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: .8rem; }
.invoice-payment-history summary { cursor: pointer; font-weight: 650; }
@media (max-width: 480px) {
    .invoice-summary { grid-template-columns: 1fr; }
}
@media print {
    .invoice-sheet { padding: 0; }
    .invoice-header, .invoice-summary, .invoice-totals, .invoice-thanks { break-inside: avoid; }
}

.dashboard-tabs [aria-expanded="true"] { background: var(--forest); color: white; }
.summary-count { display: inline-block; min-width: 1.55em; padding: .05em .35em; margin-left: .35rem; border-radius: 1em; background: #e5ede6; color: #17271f; text-align: center; }
.customer-summary { margin-bottom: 1rem; }
.customer-info-side { min-width: 0; }
.customer-walkthrough-panel { margin-bottom: 1rem; }
.customer-walkthrough-panel form { margin-top: .75rem; }
.availability-preview { padding: .5rem .65rem; border-radius: .4rem; background: #edf1eb; }
.availability-preview:empty, .booking-confirmation:empty { display: none; }
.booking-confirmation { color: #245a3d; margin-bottom: 0; }
.saved-website-requests { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.saved-website-requests > summary { cursor: pointer; font-weight: 650; }

.company-columns {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr);
    align-items: start;
    gap: 1rem;
}
.company-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .55rem;
}
.company-check input {
    width: 1.1rem;
    height: 1.1rem;
    min-height: 0;
    accent-color: var(--forest);
}
#company-settings [hidden] { display: none; }
@media (max-width: 900px) {
    .company-columns { grid-template-columns: minmax(0, 1fr); }
}

.sales-report-dates { margin-top: 1rem; }
.sales-report-layout {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) minmax(0, 3fr);
    align-items: start;
    gap: 1rem;
}
.sales-report-menu { display: grid; gap: .45rem; }
.sales-report-menu button { text-align: left; }
.sales-report-table { overflow: auto; margin-bottom: 1rem; }
.sales-report-table table { width: 100%; border-collapse: collapse; }
.sales-report-table td, .sales-report-table th { padding: .45rem; border-bottom: 1px solid var(--line); text-align: left; }
@media (max-width: 750px) {
    .sales-report-layout { grid-template-columns: minmax(0, 1fr); }
}
.sales-report-table .sales-number { text-align: right; font-variant-numeric: tabular-nums; }
.sales-report-table td.sales-number { white-space: nowrap; }
.sales-report-totals { max-width: 42rem; }

@page ridgeway-report { size: letter portrait; margin: .55in; }
@page ridgeway-report-wide { size: letter landscape; margin: .55in; }

@media print {
    body:has(#sales-report-print) { background: white; color: black; }
    body:has(#sales-report-print) .sidebar, body:has(#sales-report-print) .topbar,
    body:has(#sales-report-print) .page-title, body:has(#sales-report-print) .sales-no-print,
    body:has(#sales-report-print) #report-dates, body:has(#sales-report-print) .sales-report-layout > aside {
        display: none !important;
    }
    body:has(#sales-report-print) .workspace,
    body:has(#sales-report-print) .sales-report-layout { display: block; min-height: 0; }
    body:has(#sales-report-print) .content { max-width: none; margin: 0; padding: 0; }
    #sales-report-print {
        page: ridgeway-report; background: white; border: 0; box-shadow: none;
        padding: 0; margin: 0; font-size: 10pt;
    }
    #sales-report-print.sales-report-wide { page: ridgeway-report-wide; }
    #sales-report-print h2, #sales-report-print h3 { break-after: avoid; }
    #sales-report-print .sales-report-table { overflow: visible; font-size: 9pt; }
    #sales-report-print .sales-report-table table { width: 100%; }
    #sales-report-print .sales-report-table thead { display: table-header-group; }
    #sales-report-print .sales-report-table tr { break-inside: avoid; }
    #sales-report-print .sales-report-table td, #sales-report-print .sales-report-table th {
        padding: .16rem .26rem; border-bottom-color: #b4b4b4; overflow-wrap: anywhere;
    }
    #sales-report-print .sales-report-totals { break-inside: avoid; }
}


.proposal-response { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); }
@media print {
    .proposal-response { break-inside: avoid; }
}

.production-rate-groups details { border: 1px solid #dedbd4; border-radius: 8px; margin-top: 8px; }
.production-rate-groups details details { margin: 8px 12px; }
.production-rate-groups summary { cursor: pointer; padding: 10px 12px; }
.production-rate-groups summary small { margin-inline-start: 8px; }
.production-rate-groups > details > summary { background: #f7f5f0; color: #302b24; border-radius: 7px; }
.production-rate-groups .rate-table { margin: 0 10px 10px; overflow-x: auto; }

/* Keep the main phone workflows reachable without scrolling the desktop menu. */
.phone-nav, .phone-header, .phone-customer-jump, .phone-summary-name { display: none; }

@media screen and (max-device-width: 599px) and (any-pointer: coarse),
       screen and (max-device-height: 599px) and (any-pointer: coarse) {
    .workspace > .sidebar { display: none; }
    .phone-header {
        display: flex; align-items: center; justify-content: space-between;
        gap: .5rem; padding: .4rem .75rem; background: var(--forest);
    }
    .phone-header .brand img { width: 5.25rem; }
    .phone-header button { color: white; min-height: 44px; }
    .phone-nav {
        position: fixed; inset: auto 0 0; z-index: 10;
        display: flex; background: var(--forest);
        padding: .2rem .2rem calc(.2rem + env(safe-area-inset-bottom));
        border-top: 1px solid #56665b;
    }
    .phone-nav button {
        display: grid; place-items: center; align-content: center;
        flex: 1 1 0; min-width: 0; min-height: 3.45rem; gap: .15rem;
        padding: .25rem .1rem; font-size: .72rem; line-height: 1.15;
        text-align: center; overflow-wrap: anywhere;
    }
    .phone-nav button span:first-child { color: var(--accent); font-size: 1rem; line-height: 1; }
    .phone-nav button[aria-current="page"] { background: #33463a; border-color: #627665; }
    .workspace > .main { min-width: 0; }
    .workspace .content { padding: .75rem .7rem calc(4.65rem + env(safe-area-inset-bottom)); }
    .workspace .page-title { margin-bottom: .8rem; gap: .45rem; overflow-wrap: anywhere; }
    .workspace .page-title h1 { font-size: 1.7rem; }
    .workspace .page-title > .actions:empty { display: none; }
    .workspace .panel { padding: .72rem; margin-bottom: .7rem; min-width: 0; }
    .workspace .fields, .workspace .schedule-fields { grid-template-columns: minmax(0, 1fr); }
    .workspace .row > div { min-width: 0; overflow-wrap: anywhere; }
    .workspace .content button, #editor button { min-height: 44px; }
    .workspace :is(.expense-table,.rate-table) { max-width: 100%; }
    .workspace .expense-table :is(th,td) { padding-inline: .32rem; }
    .workspace .schedule-grid.week { grid-template-columns: minmax(0,1fr); }
    .workspace .schedule-grid.month { gap: 2px; }
    .workspace .schedule-grid.month .schedule-date { padding-inline: 2px; }
    .workspace .schedule-weekday { overflow: hidden; font-size: .72rem; }
    .workspace .schedule-toolbar { gap: .5rem; flex-wrap: wrap; }
    .workspace .schedule-calendar-status { row-gap: .35rem; }
    .workspace .dashboard-tabs { gap: .35rem; }
    .workspace .dashboard-tabs button { font-size: .8rem; padding: .35rem .42rem; }
    .workspace .summary-count { margin-left: .1rem; }
    .phone-customer-jump {
        display: inline-flex; align-items: center; min-height: 44px;
        padding: .3rem .6rem; margin-bottom: .5rem; color: var(--forest);
    }
    .workspace .customer-log #customer-log-search { scroll-margin-top: .75rem; }
    .phone-summary-name { display: inline; }
    .workspace :is([data-action="new-estimate"],[data-action="customer-estimate"],
        [data-action="open-estimate"],[data-action="open-invoice"],[data-action="invoice-create"],
        [data-action="back-customer"]), #editor [data-action="schedule-estimate"] { display: none; }
    #editor { padding: .8rem; }
    #notice { bottom: calc(4.05rem + env(safe-area-inset-bottom)); z-index: 11; }
}

.phone-job-sections, .phone-material-label { display: none; }

@media screen and (max-device-width: 599px) and (any-pointer: coarse),
       screen and (max-device-height: 599px) and (any-pointer: coarse) {
    .phone-job-sections {
        position: sticky; top: 0; z-index: 2;
        display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .3rem;
        background: var(--paper); padding-block: .35rem; margin-bottom: .55rem;
    }
    .phone-job-sections a {
        display: grid; place-items: center; text-align: center;
        min-height: 44px; padding: .25rem; background: #fffdf8;
        border: 1px solid var(--line); border-radius: .45rem;
        color: var(--forest); font-size: .8rem; font-weight: 650; text-decoration: none;
    }
    .job-detail > section { scroll-margin-top: 7rem; }
    #job-instructions { display: flex; flex-direction: column; }
    #job-instructions > .panel-heading { display: contents; }
    #job-instructions h2 { margin-bottom: .35rem; }
    #job-instructions .panel-heading > .actions { order: 1; }
    .job-instructions-date { color: var(--muted); font-size: .9rem; }
    .job-instructions-text { font-size: 1.06rem; line-height: 1.55; }
    #job-scope .proposal-area dl { grid-template-columns: minmax(0,1fr); row-gap: .3rem; }
    #job-scope .proposal-area dd + dt { margin-top: .45rem; }
    #job-scope .proposal-finish-table th, #job-scope .proposal-finish-table td {
        padding: .35rem .2rem; overflow-wrap: anywhere;
    }
    #job-materials .rate-table { position: relative; overflow: visible; }
    #job-materials .rate-table table,
    #job-materials .rate-table tbody { display: block; width: 100%; min-width: 0; }
    #job-materials .rate-table thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip-path: inset(50%); white-space: nowrap;
    }
    #job-materials .rate-table tbody tr {
        display: block; margin: .6rem 0; border: 1px solid var(--line);
        border-radius: .55rem; background: #fffdf8; overflow: hidden;
    }
    #job-materials .rate-table tbody td {
        display: grid; grid-template-columns: minmax(5rem, 34%) minmax(0,1fr);
        gap: .55rem; padding: .45rem .55rem; border: 0;
        white-space: normal; overflow-wrap: anywhere;
    }
    #job-materials .rate-table tbody td + td { border-top: 1px solid var(--line); }
    #job-materials .rate-table tbody td:first-child { background: #e8eee6; font-weight: 650; }
    #job-materials .phone-material-label { display: block; color: var(--muted); font-size: .82rem; font-weight: 650; }
}
@media screen {
    .workspace.sidebar-collapsed {
        grid-template-columns: minmax(0, 1fr);
    }

    .workspace.sidebar-collapsed > .sidebar {
        display: none;
    }
}