/* Layout and components. Mobile first: phone styles are the base, bigger screens add to them. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading);
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
p { margin: 0 0 var(--space-4); }
a { color: var(--primary); text-underline-offset: 0.15em; }
a:hover { color: var(--primary-hover); }
code { font-family: var(--font-mono); font-size: 0.95em; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: var(--space-2); top: -100px; z-index: 100;
    background: var(--accent); color: var(--on-accent); padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md); font-weight: 700;
}
.skip-link:focus { top: var(--space-2); }

/* Top bar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: var(--space-2);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(var(--space-3), env(safe-area-inset-right)) 0 max(var(--space-3), env(safe-area-inset-left));
    background: var(--bg-nav); color: var(--text-nav);
}
.topbar__menu {
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--touch); height: var(--touch);
    background: transparent; color: inherit; border: 0; border-radius: var(--radius-md); cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.topbar__menu svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.topbar__menu:hover { background: rgb(255 255 255 / 0.08); }
.brand {
    display: inline-flex; align-items: center; gap: var(--space-2);
    min-height: var(--touch); color: inherit; text-decoration: none; font-weight: 700; font-size: var(--text-lg);
}
.brand:hover { color: inherit; }
.brand__mark { fill: var(--accent); }
.env-badge {
    margin-left: auto; padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full); background: var(--accent); color: var(--on-accent);
    font-size: var(--text-sm); font-weight: 700;
}

/* Shell: menu drawer on phones and upright tablets, fixed side menu from 1024px */
.shell { display: block; }
.sidenav {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
    width: min(85vw, var(--nav-w));
    padding: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--space-2)) var(--space-3) var(--space-6) max(var(--space-3), env(safe-area-inset-left));
    background: var(--bg-nav); color: var(--text-nav);
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--transition), visibility var(--transition);
}
.sidenav.is-open { transform: none; visibility: visible; box-shadow: var(--shadow-md); }
.sidenav { padding-top: calc(env(safe-area-inset-top) + var(--space-3)); }
.sidenav__close { width: 100%; margin-bottom: var(--space-3); }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / 0.45); }
.scrim[hidden] { display: none; }
.main { display: block; min-width: 0; padding: var(--space-4) max(var(--space-4), env(safe-area-inset-right)) var(--space-10) max(var(--space-4), env(safe-area-inset-left)); }
.main:focus { outline: none; }

@media (min-width: 1024px) {
    .topbar__menu, .sidenav__close { display: none; }
    .shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); }
    .sidenav {
        position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h));
        width: auto; padding-top: var(--space-4);
        transform: none; visibility: visible; transition: none;
    }
    .scrim { display: none; }
    .main { padding: var(--space-8); }
}

/* Menu */
.menu { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.menu__item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    min-height: var(--touch); padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md); color: var(--text-nav); text-decoration: none;
}
a.menu__item:hover { background: rgb(255 255 255 / 0.08); color: var(--text-nav); }
.menu__item[aria-current="page"] { background: rgb(255 255 255 / 0.12); box-shadow: inset 3px 0 0 var(--accent); font-weight: 700; }
.menu__item--soon { color: var(--text-nav-muted); cursor: default; }
.badge {
    display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-full);
    border: 1px solid currentColor; font-size: 0.8125rem; line-height: 1.6; white-space: nowrap;
}

/* Pages and cards */
.page { max-width: var(--content-max); margin: 0 auto; }
.page--narrow { max-width: 640px; }
.page__head { margin-bottom: var(--space-6); }
.lead { font-size: var(--text-lg); color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.eyebrow { font-size: var(--text-sm); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--space-2); }
.card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-5); box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }
@media (min-width: 768px) { .card { padding: var(--space-6); } }
.card--message { margin-top: var(--space-6); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--touch); padding: var(--space-2) var(--space-5);
    border: 1px solid transparent; border-radius: var(--radius-md);
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn--secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.btn--secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* Stage progress list */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.steps__item {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
    padding: var(--space-3); border-radius: var(--radius-md); background: var(--bg-muted);
}
.steps__state {
    flex: 0 0 auto; min-width: 7.5rem; text-align: center;
    padding: 0 var(--space-2); border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 700;
}
.steps__name { flex: 1 1 14rem; }
.steps__item--done .steps__state { background: var(--success-bg); color: var(--success); }
.steps__item--building .steps__state { background: var(--warning-bg); color: var(--warning); }
.steps__item--waiting .steps__state { background: var(--bg-surface); color: var(--text-muted); }

/* Forms */
.field { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); }
.field label, .field legend { font-weight: 700; }
.input, select.input, textarea.input {
    width: 100%; min-height: var(--touch); padding: var(--space-2) var(--space-3);
    font: inherit; font-size: max(16px, var(--text-base)); color: var(--text-primary);
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.input:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--primary); }
.input.input-validation-error { border-color: var(--error); }
.input--code { font-family: var(--font-mono); letter-spacing: 0.2em; font-size: 1.25rem; max-width: 14rem; }
.field__error { color: var(--error); font-size: var(--text-sm); }
.field__error:empty { display: none; }
.field__hint { color: var(--text-muted); font-size: var(--text-sm); }
.btn--block { width: 100%; }
.btn--danger { background: var(--error); color: #fff; }
.btn--danger:hover { filter: brightness(0.92); color: #fff; }
.checks { display: grid; gap: var(--space-2); border: 0; padding: 0; margin: 0 0 var(--space-4); }
.check { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch); padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); cursor: pointer; }
.check:hover { background: var(--bg-hover); }
.check input { width: 1.375rem; height: 1.375rem; flex: 0 0 auto; accent-color: var(--primary); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-4); }

/* Messages */
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid transparent; margin-bottom: var(--space-4); }
.alert p:last-child { margin-bottom: 0; }
.alert--error { background: var(--error-bg); color: var(--error); border-color: currentColor; }
.alert--warning { background: var(--warning-bg); color: var(--warning); border-color: currentColor; }
.alert--success { background: var(--success-bg); color: var(--success); border-color: currentColor; }
.alert--info { background: var(--info-bg); color: var(--info); border-color: currentColor; }

/* Login and setup pages */
.main--plain { padding-top: var(--space-6); }
.auth { max-width: 460px; margin: 0 auto; }
.auth--wide { max-width: 560px; }
.auth__note { margin-top: var(--space-4); font-size: var(--text-sm); }
.howto { padding-left: var(--space-6); }
.howto li { margin-bottom: var(--space-2); }
.qr { width: min(240px, 100%); margin: 0 auto var(--space-4); background: #fff; padding: var(--space-2); border-radius: var(--radius-md); }
.qr svg { display: block; width: 100%; height: auto; }
.setup-key { word-break: break-all; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--space-2); margin: 0 0 var(--space-4); }
.codes code { display: block; padding: var(--space-2); background: var(--bg-muted); border-radius: var(--radius-sm); text-align: center; font-size: 1.05rem; }

/* Passkeys: the login page's second way in, and the list on My account */
.auth__passkey[hidden], [data-passkey-unsupported][hidden] { display: none; }
.auth__or { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; color: var(--text-muted); font-size: var(--text-sm); }
.auth__or::before, .auth__or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.passkeys { list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.passkeys__item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: var(--space-3) 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.passkeys__item > span { min-width: 0; flex: 1 1 12rem; }
[data-passkey-error]:empty { display: none; }

/* Signed-in person in the top bar */
.whoami { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; min-width: 0; }
.whoami__name { color: var(--text-nav); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; min-height: var(--touch); display: inline-flex; align-items: center; }
.whoami__name:hover { color: var(--text-nav); text-decoration: underline; }
.whoami + .env-badge { margin-left: 0; }
.btn--topbar { background: transparent; color: var(--text-nav); border-color: rgb(255 255 255 / 0.35); padding: var(--space-2) var(--space-3); }
.btn--topbar:hover { background: rgb(255 255 255 / 0.1); color: var(--text-nav); }
@media (max-width: 479px) { .whoami__name { display: none; } }

/* Tables that become cards on phones */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: var(--text-sm); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
@media (max-width: 767px) {
    .table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
    .table--cards tr { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: var(--space-3); padding: var(--space-2) var(--space-3); background: var(--bg-surface); }
    .table--cards td { border: 0; padding: var(--space-1) 0; }
    .table--cards td[data-label]::before { content: attr(data-label) ": "; font-weight: 700; color: var(--text-muted); }
}
.table-scroll { overflow-x: auto; position: relative; } /* keeps hidden labels inside the box */
.status { font-weight: 700; }
.status--on { color: var(--success); }
.status--off { color: var(--text-muted); }
.page__head--row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.page__head--row h1 { margin: 0; }
.search { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.search .input { flex: 1 1 auto; min-width: 0; }
.search .btn { flex: 0 0 auto; white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.status--warn { color: var(--warning); }
.row-link { display: inline-flex; align-items: center; min-height: var(--touch); font-weight: 700; }
.actions form { margin: 0; }

/* Fixes found in the screen checks */
@media (min-width: 1024px) { .sidenav .sidenav__close { display: none; } }
.btn { white-space: nowrap; }
.checks legend { font-weight: 700; margin-bottom: var(--space-1); }
@media (max-width: 479px) {
    .topbar:has(.whoami) .brand__name { display: none; }
}
.grid-2 { display: grid; gap: 0 var(--space-4); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.subhead { margin-top: var(--space-6); font-size: var(--text-lg); }
.more { margin-top: var(--space-4); }
.more summary { display: flex; align-items: center; min-height: var(--touch); cursor: pointer; font-weight: 700; color: var(--primary); }
textarea.input { min-height: 6rem; resize: vertical; }

/* Customers */
.search-form { margin-bottom: var(--space-4); }
.search-form .search { margin-bottom: var(--space-2); }
.check--inline { display: inline-flex; }
.input--short { max-width: 10rem; }
.dupes { margin: var(--space-2) 0 var(--space-3); padding-left: var(--space-6); }
.dupes a { display: inline-flex; align-items: center; min-height: var(--touch); font-weight: 700; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.facts dt { font-weight: 700; color: var(--text-muted); }
.facts dd { margin: 0; }
@media (max-width: 599px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: var(--space-2); } }
.addresses { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-3); }
.address { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.address .actions { margin-top: 0; }
.badge--main { color: var(--success); margin-left: var(--space-2); }

/* Products */
.actions--tight { margin-top: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.field--inline { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 0; }
.field--inline .input { width: auto; min-width: 12rem; }
.checks--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--space-1) var(--space-3); }
.input--scan { font-size: 1.25rem; letter-spacing: 0.04em; }
.price-card { margin-top: var(--space-4); }
.price-card__price { font-size: clamp(2.25rem, 1.8rem + 2vw, 3rem); font-weight: 700; margin: var(--space-2) 0 0; color: var(--text-primary); }
.badge { margin-right: var(--space-1); }

/* Stock */
.qty { font-variant-numeric: tabular-nums; }
.qty--low { color: var(--error); font-weight: 700; }

/* Price labels: on screen a preview, on paper an A4 sheet of 21 (63.5 x 38.1 mm, 3 across, 7 down). */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--space-3); max-width: var(--content-max); margin: var(--space-4) auto 0; }
.label { background: #fff; color: #000; border: 1px dashed #bbb; border-radius: var(--radius-sm); padding: 6px 8px; display: flex; flex-direction: column; overflow: hidden; min-height: 9rem; }
.label__name { font-weight: 700; font-size: 0.85rem; line-height: 1.2; }
.label__desc { font-size: 0.75rem; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.label__price { font-size: 1.6rem; font-weight: 700; line-height: 1.1; margin-top: auto; }
.label__barcode svg { display: block; width: 100%; height: 28px; }
.label__code { font-family: var(--font-mono); font-size: 0.7rem; text-align: center; }
@media print {
    @page { size: A4; margin: 15.1mm 7.2mm; }
    body { background: #fff; }
    .topbar, .sidenav, .scrim, .skip-link, .no-print { display: none !important; }
    .shell { display: block !important; }
    .main { padding: 0 !important; }
    .labels { display: grid; grid-template-columns: repeat(3, 63.5mm); grid-auto-rows: 38.1mm; column-gap: 2.5mm; row-gap: 0; gap: 0 2.5mm; margin: 0; max-width: none; }
    .label { border: 0; border-radius: 0; min-height: 0; height: 38.1mm; padding: 2mm 3mm; break-inside: avoid; }
    .label__barcode svg { height: 9mm; }
}

/* Sales */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.sale { display: grid; gap: var(--space-4); }
.sale__main, .sale__side { display: grid; gap: var(--space-4); align-content: start; min-width: 0; }
.sale .card { margin-bottom: 0; }
@media (min-width: 1024px) { .sale { grid-template-columns: minmax(0, 1fr) 22rem; } }
.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.pick { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.pick > span { min-width: 0; overflow-wrap: anywhere; }
.pick form { margin: 0; }
.sale-line { border-top: 1px solid var(--border); padding-top: var(--space-3); margin-top: var(--space-3); overflow-wrap: anywhere; }
.sale-line:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.sale-line__form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); }
.sale-line__form .field { margin-bottom: var(--space-3); }
.sale-line__desc, .sale-line__sum, .sale-line__form .actions { grid-column: 1 / -1; }
.sale-line__sum { margin: 0 0 var(--space-2); }
.badge--warn { color: var(--warning); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-4); margin: var(--space-3) 0; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--text-secondary); }
.totals dd { margin: 0; text-align: right; }
.totals .totals__grand { font-weight: 700; font-size: var(--text-lg); color: var(--text-primary); }
.pay-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); }
.pay-row .field:last-child { grid-column: 1 / -1; }
fieldset { border: 0; margin: 0 0 var(--space-3); padding: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: var(--space-2); }

/* Invoice (screen and A4 print) */
.invoice { max-width: 50rem; margin: 0 auto; padding: var(--space-4); background: var(--bg-surface); color: var(--text-primary); overflow-wrap: anywhere; }
.invoice__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4); }
.invoice__business { margin: 0 0 var(--space-2); }
.invoice__meta h2 { margin: 0 0 var(--space-2); }
.invoice__meta dl { display: grid; grid-template-columns: max-content 1fr; gap: 0 var(--space-3); margin: 0; }
.invoice__meta dd { margin: 0; }
.invoice__to { margin: var(--space-4) 0; }
.invoice__lines .num, .invoice__lines th.num { text-align: right; white-space: nowrap; }
/* Words break only where they must, and the first column (the description) keeps a readable width: on a phone the
   table scrolls inside its own box instead of squeezing the description to one letter a line. */
.invoice table { overflow-wrap: break-word; }
.invoice th { white-space: nowrap; }
.invoice__lines th:first-child, .invoice__lines td:first-child { min-width: 11rem; }
.invoice__totals { max-width: 24rem; margin-left: auto; }
.invoice__footer { margin-top: var(--space-6); font-size: var(--text-sm); color: var(--text-secondary); }
@media print {
    .invoice { max-width: none; padding: 0; background: #fff; color: #000; font-size: 10.5pt; }
    .invoice .table-scroll { overflow: visible; }
    .invoice__lines tr { break-inside: avoid; }
}
/* Long button texts wrap on phones instead of widening the page; grid columns may shrink below their content. */
.btn--wrap { white-space: normal; text-align: center; }
@media (max-width: 479px) { .sale .btn, .page .btn--block { white-space: normal; text-align: center; } }
.grid-2 > * { min-width: 0; }

/* Customer signature for cash: always dark ink on white, so the saved picture reads the same in light and dark mode. */
.signature { margin: var(--space-3) 0; }
.signature[hidden] { display: none; }
.signature__label { margin-bottom: var(--space-2); }
.signature__pad { display: block; width: 100%; height: 180px; background: #fff; border: 2px dashed var(--border); border-radius: var(--radius-md); touch-action: none; cursor: crosshair; margin-bottom: var(--space-2); }
.signed { display: block; margin-top: var(--space-1); }
.signed__img { display: block; max-width: 100%; width: 260px; height: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); margin-top: var(--space-1); }

/* Supplier orders */
.order-line { border-top: 1px solid var(--border); padding: var(--space-3) 0; overflow-wrap: anywhere; }
.order-line:first-child { border-top: 0; }
.order-line__name { margin-bottom: var(--space-2); }
.order-line__name .muted { display: block; }
.order-line__form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); }
.order-line__form .actions { grid-column: 1 / -1; }
.pre-line { white-space: pre-line; }
.totals-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.totals-row > div { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); min-width: 0; }
.totals-row strong { display: block; font-size: 1.25rem; }
.badge--wrap { white-space: normal; overflow-wrap: anywhere; }
.filters select { max-width: 100%; }
.field--grow { flex: 1 1 16rem; min-width: 0; max-width: 100%; margin-bottom: 0; }

/* Copies of bills and receipts (Stage 4). */
.files { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-3); }
.files__item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.files__thumb { display: block; flex: 0 0 auto; }
.files__thumb img { display: block; width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--border); }
.files__text { display: grid; gap: var(--space-1); flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.files__add { display: grid; gap: var(--space-3); }

/* Stage 5: jobs, deliveries, repairs, signatures */
.signed-list { list-style: none; padding: 0; margin: 0; }
.signed-list__item { border-top: 1px solid var(--border); padding: var(--space-3) 0; }
.signed-list__item:first-child { border-top: 0; }
.fingerprint { font-size: 0.8rem; font-family: ui-monospace, monospace; }
.doc-sign { margin-top: var(--space-4); break-inside: avoid; }
.job-line { border-top: 1px solid var(--border); padding: var(--space-3) 0; overflow-wrap: anywhere; }
.job-line:first-child { border-top: 0; }
.job-line__form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.job-line__form .field { margin: 0; }
.job-line__form .field--grow { flex: 1 1 14rem; }
.room-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: var(--space-2); border-top: 1px solid var(--border); padding: var(--space-3) 0; align-items: end; }
.room-row:first-of-type { border-top: 0; }
.room-row .field { margin: 0; }
.day-sheet { break-after: page; }
.day-sheet:last-child { break-after: auto; }
.visit { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); margin-bottom: var(--space-3); break-inside: avoid; }
.visit h3 { margin-top: 0; }
.tear-off { border-top: 2px dashed var(--text-muted); margin-top: var(--space-5); padding-top: var(--space-3); }
.tear-off__number { font-size: 1.6rem; font-weight: 700; margin: 0; }
.form-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.form-grid .field { margin: 0; }

/* Web shop */
.shop-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.shop-item h2 { font-size: 1.125rem; margin-top: 0; }
.basket-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.basket-line > span { flex: 1 1 12rem; min-width: 0; }
