/* One small stylesheet, no framework: the whole app should load in a blink on a shop PC or a phone. */
:root {
    --ink: #1f2a28; --muted: #6b7775; --line: #dfe5e3; --bg: #f5f7f6; --card: #fff;
    --brand: #0f766e; --brand-ink: #fff; --ok: #e7f6ec; --ok-ink: #1d6b35; --err: #fdecec; --err-ink: #9b1c1c;
}
* { box-sizing: border-box; }
/* "hidden" must always win: rules like `label { display: block }` below would otherwise override it. */
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: .2rem 0 .3rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* top bar */
.top { display: flex; align-items: center; gap: 18px; padding: 8px 16px; background: var(--brand); color: var(--brand-ink); flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.top a { color: var(--brand-ink); text-decoration: none; }
/* line icons: stroke only, take the text colour */
.top .ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
/* each item a pill: icon + label; the current page stands out, hover lightens */
.top nav a { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; opacity: .88;
    transition: background .15s, opacity .15s; }
.top nav a:hover { background: rgba(255, 255, 255, .12); opacity: 1; }
.top nav a.on { background: rgba(255, 255, 255, .22); opacity: 1; font-weight: 600; }
.top .who { display: flex; gap: 10px; align-items: center; margin: 0; font-size: .9rem; }
.top .who .link { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); padding: 6px 10px; border-radius: 8px;
    text-decoration: none; }
.top .who .link:hover { background: rgba(255, 255, 255, .12); }
.top .who .link .ico { width: 16px; height: 16px; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.card.narrow { max-width: 380px; margin: 40px auto; }
.alert { padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.alert.ok { background: var(--ok); color: var(--ok-ink); }
.alert.err { background: var(--err); color: var(--err-ink); }
label { display: block; font-size: .85rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; padding: 6px 8px; margin-top: 3px;
    border: 1px solid #c9d2cf; border-radius: 6px; background: #fff; }
input[type=checkbox], input[type=radio] { width: auto; margin: 0 4px 0 0; }
.btn { display: inline-block; font: inherit; padding: 7px 16px; border: 1px solid var(--brand); border-radius: 6px;
    background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.card.narrow label { margin-top: 10px; }

/* ready to deliver */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters .grow { flex: 1 1 220px; }
.filters .check { display: flex; align-items: center; color: var(--ink); padding-bottom: 8px; }
.filters .total { margin-left: auto; padding-bottom: 8px; }
/* two columns: customer list | arrange a trip (stacks on a phone) */
.ready { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.ready .right { position: sticky; top: 12px; }
.ready .right .card { margin-top: 0; }
.ready .right h2 { font-size: 1rem; margin: 0 0 4px; }
.ready .right label { margin-top: 8px; }
.cust { padding: 0; margin: 0 0 8px; }
.cust.is-picked { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.cust .head { display: flex; gap: 10px; align-items: center; padding: 8px 14px; }
.cust .head:hover { background: #f0f7f5; }
.cust .cust-check { width: 18px; height: 18px; flex: none; }
/* Ready row: ▸ | name ........ counts
                  address ..... labels   (left side left-aligned, right side right-aligned) */
.cust .expand { flex: 1; min-width: 0; padding: 2px 0; border: 0; background: none; font: inherit; color: var(--ink);
    text-align: left; cursor: pointer;
    display: grid; grid-template-columns: 1em minmax(0, 1fr) auto; column-gap: 8px; row-gap: 6px; align-items: baseline; }
.cust .expand .arrow { grid-row: 1; grid-column: 1; }
.cust .expand .name { grid-row: 1; grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust .expand .counts { grid-row: 1; grid-column: 3; text-align: right; }
.cust .expand .addr { grid-row: 2; grid-column: 2; min-width: 0; }
.cust .expand .tags { grid-row: 2; grid-column: 3; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.cust .addr, .picked .addr { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust .arrow { color: var(--muted); width: 1em; flex: none; }
.cust .body { padding: 0 14px 12px; }
.cust tr.off td { color: #9aa5a2; background: #fafbfb; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; white-space: nowrap; }
.badge.wip { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
/* Ready: coming soon (orders still in production, expected within Settings' days) */
.badge.soon { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.badge.soon.late { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.incoming { margin: 0 0 8px 15px; font-size: .85rem; color: #075985; }
.incoming summary { cursor: pointer; }
.incoming table { margin: 6px 0 4px; border-collapse: collapse; color: var(--ink); }
.incoming td { padding: 3px 12px 3px 0; border-bottom: 1px solid #eef1f0; }
.incoming tr.late td:last-child { color: #b45309; font-weight: 600; }
/* Ready: the Late orders view */
.late-cust { padding: 10px 14px; margin-bottom: 8px; }
.late-cust .late-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.late-cust table { border-collapse: collapse; font-size: .9rem; }
.late-cust td { padding: 3px 14px 3px 0; border-bottom: 1px solid #eef1f0; }
.late-cust .late-days { color: #b45309; font-weight: 600; }
.po .badge { margin-left: auto; }
/* Ready: By area | A–Z switch, and the area headings in the list */
.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.sort-bar .area-pick { margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.sort-bar select { width: auto; min-width: 200px; padding: 7px 10px; }
.sort-bar select.sort-pick { min-width: 140px; font-weight: 600; }
.badge.due { background: #f1f5f4; color: var(--ink); border: 1px solid var(--line); }
.area-head { display: flex; align-items: center; gap: 8px; margin: 16px 0 6px 15px; }
.area-head:first-of-type { margin-top: 4px; }
.area-head label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--brand); margin: 0; }
.picked .area { flex-basis: 100%; text-align: left; font-size: 11px; color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .03em; }
.center { text-align: center; }
.picked { list-style: none; margin: 12px 0 4px; padding: 0; max-height: 45vh; overflow-y: auto; border-top: 1px solid var(--line); }
.picked li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid #eef1f0; }
.picked li > div { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; column-gap: 4px; }
.picked .addr { flex-basis: 100%; }
.picked .addr.warn { color: #b45309; }
.picked.collect .addr { display: none; }
.picked .x { border: 0; background: none; font-size: 1.2rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.picked .x:hover { color: var(--err-ink); }
.po { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid #eef1f0; font-size: .95rem; }
.po-block:first-child .po { border-top: 0; }
/* POs indented a little under their customer: half the way to the company name. */
.cust .items .po-block { margin-left: 28px; }
@media (max-width: 640px) { .cust .items .po-block { margin-left: 14px; } }
.po .po-check { flex: none; }
.po-toggle { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; flex: 1; min-width: 0; padding: 2px 0;
    border: 0; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.po-toggle:hover b { text-decoration: underline; }
.po-partial { font-size: .8rem; color: #b45309; }
.po-block table { margin: 2px 0 8px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--line); padding: 4px 6px; }
td { border-bottom: 1px solid #eef1f0; padding: 5px 6px; vertical-align: middle; }
tr:has(input[name=Pick]:checked) td { background: #e6f4f1; }
.num { text-align: right; }
input.qty { width: 5.5em; text-align: right; margin: 0; }
.trip { padding: 12px 14px 14px; }
.kinds { display: flex; gap: 22px; margin-bottom: 8px; }
.kinds label { display: flex; align-items: center; color: var(--ink); font-size: 1rem; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 18px 0; }

/* all trips */
.trip-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.trip-filters .grow { flex: 1 1 160px; }
.trip-filters label:not(.grow) { flex: 0 1 128px; }
.trip-links { display: flex; gap: 16px; margin-top: 10px; font-size: .9rem; }
.trip-links .muted { margin-left: auto; }
.table-wrap { padding: 0; overflow-x: auto; }
table.trips th, table.trips td { padding: 8px 10px; }
table.trips tbody tr:hover td { background: #f6faf9; }
.center { text-align: center; }
.right { text-align: right; }
.btn.small { padding: 3px 10px; font-size: .85rem; }
.btn.disabled { opacity: .45; cursor: not-allowed; }
/* trip status colours, same meaning as the original: waiting / on the way / done / not done */
.badge.st-pending { background: #fef3c7; color: #92400e; }
.badge.st-intransit { background: #dbeafe; color: #1e40af; }
.badge.st-delivered { background: #dcfce7; color: #166534; }
.badge.st-failed { background: #fee2e2; color: #991b1b; }

/* settings */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; align-items: start; }
.cols h2 { font-size: 1rem; margin: 18px 0 6px; }
.cols h2:first-child { margin-top: 0; }
.cols label { margin-top: 8px; }
.cols label.check { display: flex; align-items: center; color: var(--ink); }
.cols label.short input { max-width: 120px; }
.cols .btn { margin-top: 16px; }
.cols p.small { margin: 4px 0 0; }
dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 8px 0 0; font-size: .9rem; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }

@media (max-width: 900px) {
    .ready { grid-template-columns: minmax(0, 1fr); }   /* minmax: never wider than the screen */
    .ready .right { position: static; }
}
@media (max-width: 640px) {
    main { padding: 10px; }
    /* the Size column (3rd) of the item tables only — least needed on a phone. Other tables keep every column. */
    .cust .items th:nth-child(3), .cust .items td:nth-child(3) { display: none; }
}
.po-line { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; flex: 1; min-width: 0; }

/* ---- trip page ---- */
.alert.warn { background: #fef3c7; color: #92400e; }
.trip-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.trip-head h1 { margin: 0; }
.trip-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }
.badge.kind { background: #f1f5f4; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost.warn { color: #b45309; border-color: #f0b35a; }
.btn.ghost.danger { color: var(--err-ink); border-color: #f1a7a7; }
.btn.ghost.ok { color: #166534; border-color: #86c79b; }
.trip-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.trip-cols h2, .resched h2, .edit-trip h2 { font-size: 1rem; margin: 0 0 8px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-title h2 { margin: 0; }
.card-title .tools { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photos figure { width: 150px; margin: 0; }
.photos .shot { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: zoom-in; background: #fff; }
.photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photos figure.removed img { opacity: .35; filter: grayscale(1); }
.photos figcaption { font-size: .8rem; color: var(--muted); margin-top: 4px; line-height: 1.3; }
.good { color: #166534; }
.bad { color: #b91c1c; }
.strong { font-weight: 600; }
tr.row-warn td { background: #fef9e7; }
.trip-cols aside input[readonly] { font-size: .85rem; margin-bottom: 8px; }
.link-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.details dl { grid-template-columns: 110px 1fr; }
.resched-row, .edit-grid { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.resched-row label { flex: 0 1 200px; }
.edit-grid label { flex: 1 1 220px; }
.edit-grid .wide { flex-basis: 100%; }
.edit-buttons { display: flex; gap: 10px; margin: 12px 0; }
.edit-trip { max-width: 760px; }
.viewer { width: min(1100px, 94vw); padding: 0; border: 0; border-radius: 8px; }
.viewer::backdrop { background: rgba(0, 0, 0, .75); }
.viewer-head, .viewer-foot { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 12px; font-size: .85rem; }
.viewer img { display: block; width: 100%; max-height: 75vh; object-fit: contain; background: #111; }
.viewer .sha { font-family: Consolas, monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.viewer .x { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); }
/* previous / next photo: round buttons over the left and right edge of the photo */
.viewer { position: relative; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.viewer .nav:hover { background: rgba(0, 0, 0, .8); }
.viewer .nav.prev { left: 10px; }
.viewer .nav.next { right: 10px; }
@media (max-width: 900px) { .trip-cols { grid-template-columns: minmax(0, 1fr); } }   /* never wider than the screen */

/* all trips: a row expands to show its POs */
tr.trip-row { cursor: pointer; }
tr.trip-row .arrow { color: var(--muted); display: inline-block; width: 1em; }
tr.trip-row[aria-expanded="true"] td { background: #f0f7f5; }
tr.trip-lines > td { background: #fafcfb; padding: 6px 14px 12px 38px; }
.trip-pos { list-style: none; margin: 2px 0; padding: 0; }
.trip-pos li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }

/* drivers */
.drivers { display: grid; grid-template-columns: minmax(280px, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.drivers h2 { font-size: 1rem; margin: 0 0 6px; }
.drivers form label { margin-top: 8px; }
.drivers form label.check { display: flex; align-items: center; color: var(--ink); }
.pair2 { display: grid; grid-template-columns: 7fr 5fr; gap: 10px; }
tr.inactive td { color: var(--muted); }
tr.editing td { background: #e6f4f1; }
@media (max-width: 900px) { .drivers { grid-template-columns: minmax(0, 1fr); } }
.badge.role-admin { background: #1f2a28; color: #fff; }
/* All trips: sortable column headings */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--brand); }
th.sortable .sort-ind { font-size: .7em; color: var(--brand); }
/* A card that folds away (office trip page: On this trip) — same look as the phone screens' */
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; }
.fold > summary::after { content: "▾"; font-size: 18px; color: var(--muted); transition: transform .15s; }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold[open] > summary { margin-bottom: 10px; }
/* Office menu on a phone / narrow window: folds behind a ☰ button, drops down as a list */
.top .menu-btn { display: none; }
@media (max-width: 820px) {
    .top { gap: 8px; }
    .top .menu-btn { display: inline-flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; border-radius: 8px;
        background: rgba(255, 255, 255, .12); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; }
    .top .menu-btn .ico { width: 22px; height: 22px; }
    .top .who { margin-left: auto; }
    .top .who > span { display: none; }                  /* the name makes the bar too crowded on a phone */
    .top nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; gap: 2px; padding: 4px 0 6px;
        border-top: 1px solid rgba(255, 255, 255, .2); }
    .top.open nav { display: flex; }
    .top nav a { padding: 11px 12px; font-size: 1rem; }  /* big enough for a thumb */
    .top nav a .ico { width: 20px; height: 20px; }
}
/* Ready to deliver on a phone: nothing wider than the screen */
@media (max-width: 640px) {
    /* the three dropdowns share the width instead of each insisting on its own minimum */
    .sort-bar, .sort-bar .area-pick { width: 100%; }
    .sort-bar select, .sort-bar select.sort-pick { min-width: 0; flex: 1 1 120px; }
    /* a customer row: name + counts, then the address, then the labels on their own line */
    .cust .head { padding: 8px 10px; gap: 8px; }
    .cust .expand { grid-template-columns: 1em minmax(0, 1fr) auto; }
    .cust .expand .name { white-space: normal; }           /* the full company name, over two lines if needed */
    .cust .expand .addr { grid-column: 2 / 4; }
    .cust .expand .tags { grid-row: 3; grid-column: 2 / 4; justify-content: flex-start; }
    .cust .expand .tags:empty { display: none; }
    .area-head { margin-left: 4px; flex-wrap: wrap; }
    .incoming { margin-left: 4px; }
    .incoming table { display: block; overflow-x: auto; }   /* the coming-soon table scrolls inside itself */
    .filters .total { margin-left: 0; }
}
/* Ready on a phone: bar fixed to the bottom of the screen — what is ticked + jump to the trip panel */
.pick-bar { display: none; }
@media (max-width: 900px) {
    .pick-bar:not([hidden]) { display: flex; }
    .pick-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; align-items: center; justify-content: space-between;
        gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--card);
        border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0, 0, 0, .12); font-weight: 600; }
    main { padding-bottom: 70px; }   /* the last customer is never hidden behind the bar */
}
/* Pickups list (office page): the same cards as the phone screens */
.pickups { max-width: 760px; }
.pickups .section { margin: 18px 0 8px; }
.pickups .between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.pickups .job { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line);
    border-radius: 10px; padding: 14px; margin-bottom: 10px; transition: border-color .15s, box-shadow .15s; }
.pickups .job:hover { border-color: var(--brand); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.pickups .job .do { font-weight: 700; font-size: 1rem; }
.pickups .job .cust { margin-top: 2px; }
.pickups .job .addr { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.pickups .pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pickups .pill.pending   { background: #fef3c7; color: #92400e; }
.pickups .pill.intransit { background: #dbeafe; color: #1d4ed8; }
.pickups .pill.delivered { background: #dcfce7; color: #166534; }
.pickups .pill.failed    { background: #fee2e2; color: #991b1b; }
/* Trip page on a phone: history / item cells wrap instead of pushing the page wider */
@media (max-width: 640px) {
    .trip-cols td, .trip-cols td.nowrap { white-space: normal; overflow-wrap: anywhere; }
}
/* Ready on a phone: each coming-soon order as two lines — company name, then PO · pieces · due */
@media (max-width: 640px) {
    .incoming table, .incoming tbody, .incoming tr { display: block; }
    .incoming tr { padding: 6px 0; border-bottom: 1px solid #eef1f0; }
    .incoming td { display: inline; padding: 0; border: 0; white-space: normal; }
    .incoming td:first-child { display: block; font-weight: 600; margin-bottom: 2px; }
    .incoming td + td + td::before { content: " · "; color: var(--muted); font-weight: 400; }
}
/* All trips on a phone: each trip as a small card —
     date ................ driver
     company name
     8 PO ................ status
     .......... received by Kevin
   The column headings (and so sorting) are desktop only. Cells by position:
   1 date · 2 customer · 3 PO · 4 driver · 5 status · 6 received by */
@media (max-width: 640px) {
    #trips, #trips tbody { display: block; }
    #trips thead { display: none; }
    #trips tr.trip-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 3px;
        padding: 10px 12px; border-bottom: 1px solid var(--line); }
    #trips tr.trip-row > td { display: block; padding: 0; border: 0; background: none; }
    #trips tr.trip-row > td:nth-child(1) { grid-area: 1 / 1; }                                          /* date */
    #trips tr.trip-row > td:nth-child(4) { grid-area: 1 / 2; text-align: right; font-size: .85rem; }    /* driver */
    #trips tr.trip-row > td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-weight: 600; }                /* company */
    #trips tr.trip-row > td:nth-child(3) { grid-area: 3 / 1; text-align: left; font-size: .85rem; color: var(--muted); } /* PO */
    #trips tr.trip-row > td:nth-child(3)::after { content: " PO"; }
    #trips tr.trip-row > td:nth-child(5) { grid-area: 3 / 2; text-align: right; }                       /* status */
    #trips tr.trip-row > td:nth-child(6) { grid-area: 4 / 1 / 5 / 3; text-align: right; color: var(--muted); } /* received by */
    #trips tr.trip-row > td:nth-child(6):not(:empty)::before { content: "Received by "; }
    #trips tr.trip-row > td:nth-child(6):empty { display: none; }
    #trips tr.trip-row[aria-expanded="true"] { background: #f0f7f5; }
    #trips tr.trip-lines { display: block; }
    #trips tr.trip-lines[hidden] { display: none; }
    #trips tr.trip-lines > td { display: block; padding: 6px 12px 12px 28px; }
}
/* Trip page on a phone: each History entry as two lines — what happened · detail, then date · who */
@media (max-width: 640px) {
    .history table, .history tbody, .history tr { display: block; }
    .history tr { display: flex; flex-wrap: wrap; column-gap: 6px; padding: 7px 0; border-bottom: 1px solid #eef1f0; }
    .history td { display: block; padding: 0; border: 0; overflow-wrap: normal; }
    .history td:nth-child(2) { order: 1; font-weight: 600; }                     /* Delivered */
    .history td:nth-child(3) { order: 2; flex: 1 1 60%; }                       /* Received by Kevin; 3 photo(s) */
    .history td:nth-child(1) { order: 4; margin-top: 2px; }                     /* 30 Sep 2026, 8:22 PM */
    .history td:nth-child(4) { order: 5; margin-top: 2px; }                     /* admin (office) */
    .history td:nth-child(1)::after { content: " ·"; }
    .history td:nth-child(3):empty { display: none; }
    .history tr::after { content: ""; order: 3; flex-basis: 100%; }             /* line break before the date */
}
/* Trip page "On this trip": on a phone the table is swapped for PO groups of two-line items */
.lines-phone { display: none; }
@media (max-width: 640px) {
    .trip-cols table.lines { display: none; }
    .lines-phone { display: block; }
    .lines-phone .po-group + .po-group { margin-top: 12px; }
    .lines-phone .po-head { font-weight: 700; color: var(--brand); padding: 4px 0; border-bottom: 2px solid var(--line); }
    .lines-phone .po-head span { font-weight: 400; color: var(--muted); font-size: .85rem; }
    .lines-phone .line { padding: 7px 0; border-bottom: 1px solid #eef1f0; }
    .lines-phone .l1 { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; }
    .lines-phone .l1 .q { white-space: nowrap; }
    .lines-phone .l2 { font-size: .8rem; color: var(--muted); margin-top: 2px; }
    .lines-phone .l3 { font-size: .8rem; color: #b45309; font-weight: 600; margin-top: 2px; }
}
/* Trip page "On this trip" (PC): a heading row per PO instead of a PO column */
table.lines tr.po-row td { padding-top: 12px; font-weight: 700; color: var(--brand); border-bottom: 2px solid var(--line); }
table.lines tr.po-row:first-child td { padding-top: 4px; }
table.lines tr.po-row td span { font-weight: 400; color: var(--muted); font-size: .85rem; }
/* Settings: the lorry list */
.lorry-list { list-style: none; margin: 8px 0 12px; padding: 0; border-top: 1px solid var(--line); }
.lorry-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; border-bottom: 1px solid #eef1f0; font-weight: 600; }
.lorry-list li .link { color: #b91c1c; font-weight: 400; }
.lorry-add { display: flex; gap: 8px; }
.lorry-add input { flex: 1; margin: 0; }
