/* Slice 2 onward: parts the design system does not draw. Built only from the system's own tokens.
   The pages of our own (sign-in, sign-up, two-step, Settings, People) are in system.css. */

.topbar__back { margin-left: -12px; }

/* ---------- Slice 2: customers, things, services, people ---------- */

/* Search box with a Current / Archived switch beside it. */
.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.list-tools .search { flex: 1 1 260px; }
.list-count { padding: var(--space-3) var(--space-5) var(--space-2); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--line); }
.pager .btn { flex: none; }
.pager .meta { flex: 1; text-align: center; }
.seg a.seg__item { text-decoration: none; }

/* Forms on a record: fields in a grid that is one column on a phone. */
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.record-form { max-width: 880px; }
.form-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.facts-heading { font-size: var(--text-xs); font-weight: 700; color: var(--ink-3); text-transform: none; letter-spacing: 0.02em; margin: var(--space-4) 0 var(--space-2); }
.facts-heading:first-child { margin-top: 0; }
.card__body > .facts + .facts-heading, .card__body > .facts-heading + .facts { margin-top: var(--space-2); }
.variant { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); display: grid; gap: var(--space-3); min-width: 0; }
.variant legend { padding: 0 var(--space-2); }

/* A registration field with its Look up button beside it (under it on a phone). */
.lookup-row { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 560px) { .lookup-row { grid-template-columns: minmax(0, 1fr) auto; align-items: start; } .lookup-row > .btn { margin-top: 30px; } }
.lookup-row .input { font-family: var(--font-plate); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.thing-form { border-top: 1px solid var(--line); margin-top: var(--space-3); }

/* Show something only on a phone, or only when there is room. */
.show-narrow { display: none; }
@media (max-width: 699px) { .hide-narrow { display: none !important; } .show-narrow { display: block; } span.meta.show-narrow { display: inline; } }
.facts-group > .facts-heading { margin-top: 0; }
.facts-group > .facts-heading + .facts { margin-top: var(--space-2); }

/* ---------- Slice 3: the diary ---------- */

/* The date in the diary header: a button that opens the browser's own date picker. */
.datenav__label { position: relative; display: inline-flex; align-items: center; }
.datenav__pick { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.datenav__label:focus-within { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.diary-region { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: var(--space-3); }
.diary-region > .diary { flex: 1; }
.toast-area:empty { display: none; }

/* A job being dragged by touch must not scroll the grid under the finger. */
.diary__body .job { touch-action: pan-x pan-y; }
.diary.is-dragging .diary__body .job { touch-action: none; }

/* Rows of hours in Settings: day, from, to, off. */
.hours-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2) var(--space-3); align-items: center; padding-block: var(--space-2); border-top: 1px solid var(--line); }
.hours-row:first-child { border-top: 0; }
.hours-row__day { font-weight: 700; }
.hours-row__off { grid-column: 2 / -1; }
.hours-row__error { grid-column: 1 / -1; }
@media (min-width: 700px) { .hours-row { grid-template-columns: 64px 150px 150px 1fr; } .hours-row__off { grid-column: auto; } }
.person-row .row .input { max-width: 340px; }
.card__more { white-space: nowrap; flex: none; }

/* Slice 3b: a page header whose buttons do not fit beside the title (the gym timetable on an upright tablet) wraps instead of running off the screen. */
.page-head { flex-wrap: wrap; }
.page-head > .cluster:last-child { flex-wrap: wrap !important; }

/* ---------- Slice 4: public booking pages ---------- */

/* The cards, days and times of the public page are real radio buttons and tick boxes inside a label, so the page works as a plain form.
   These give them the look system.css draws for buttons with aria-pressed. */
label.option, label.day, label.slot { cursor: pointer; }
.option:has(> input:checked) { border-color: var(--accent-edge); box-shadow: inset 0 0 0 1px var(--accent-edge); background: var(--accent-soft); }
.option:has(> input:checked) .option__mark { background: var(--accent); border-color: var(--accent-edge); color: var(--on-accent); }
.option:has(> input:focus-visible), .day:has(> input:focus-visible), .slot:has(> input:focus-visible), .btn:has(> input:focus-visible) { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.day:has(> input:checked) { background: var(--accent); border-color: var(--accent-edge); color: var(--on-accent); }
.day:has(> input:checked) b { color: var(--on-accent); }
.day:has(> input:disabled) { background: transparent; border-style: dashed; color: var(--ink-3); cursor: not-allowed; }
.day:has(> input:disabled) b { color: var(--ink-3); font-weight: 500; }
a.day { text-decoration: none; }
.slot { display: flex; align-items: center; justify-content: center; position: relative; }
.slot:has(> input:checked) { background: var(--accent); border-color: var(--accent-edge); color: var(--on-accent); }
a.session, div.session { text-decoration: none; color: inherit; }
div.session[aria-disabled="true"] { cursor: not-allowed; opacity: 0.8; }
.public .option__price small.above { display: block; }
/* The summary bar and the button inside the form: shown on a phone, then the wide layout takes over from 900px (system.css switches at 900 and 960). */
@media (min-width: 900px) and (max-width: 959px) { .public .wide-only { display: flex !important; } }
/* The field only a program fills in. It is taken off the page, not just hidden, so it cannot be tabbed to or read out. */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
/* A small globe on a job or place that was booked on the public page. */
.online-mark { display: inline-flex; vertical-align: middle; margin-left: 4px; opacity: 0.85; }
.online-mark .icon { width: 14px; height: 14px; }
.public__head .logo { text-decoration: none; }
/* On a wide screen the day strip stays inside its column (system.css lets it run to the edge of a phone), and the times sit four across. */
@media (min-width: 900px) { .public__main .days { margin-inline: 0; padding-inline: 2px; } }
@media (min-width: 560px) { .public .slots { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* The details on a customer's own booking page: long values (a date and time) sit beside short labels without squeezing them. */
.public .totals { grid-template-columns: auto 1fr; }
.public .totals dt { white-space: nowrap; }
.public .totals .totals__grand { white-space: nowrap; }

/* A message in a list: the line, and its words when opened. */
.msg details > summary { list-style: none; cursor: pointer; }
.msg details > summary::-webkit-details-marker { display: none; }
.msg__body { padding: var(--space-2) var(--space-5) var(--space-4) calc(var(--space-5) + 40px); }
.msg__text { overflow-wrap: anywhere; font-size: var(--text-sm); }
@media (max-width: 600px) { .msg__body { padding-left: var(--space-5); } }

/* Slice 6: the installed app (queued notes, the install card, alerts, photos) */
.banner[hidden], .install[hidden], [data-install-for][hidden], [data-push-for][hidden], [data-push] [hidden], [data-push-badge][hidden] { display: none !important; }
.banner--queue { background: var(--info-soft); color: var(--info-text); border-bottom: 1px solid var(--info-line); }
.install .guide { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.install .guide li { display: flex; align-items: center; gap: var(--space-3); }
.install .guide__pic { flex: none; width: 124px; min-height: 52px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-2); }
.install .mock-share { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft-line); }
.install .mock-row { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; font-weight: 600; line-height: 1.2; }
.install .mock-row__ico { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--ink-2); }
.install .mock-pill { font-size: 13px; font-weight: 700; padding: 4px 14px; border-radius: var(--radius-full); background: var(--accent); color: var(--on-accent); }
.photos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: var(--space-3); }
.photos img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface-3); }
.banners { position: sticky; top: 60px; z-index: 19; }
@media (min-width: 700px) { .banners { top: 0; } }
.install [data-install-dismiss], #alerts form[action="/push/test"] .btn--quiet { margin-left: calc(var(--space-3) * -1); }

/* "This page needs a signal": shown by the installed app in place of a page it has not kept (views/owner-offline.php), and, with only its
   first part, by the worker when the device has nothing kept at all. A state in the middle of the page, then what is still here as rows. */
.offline { display: grid; gap: var(--space-8); max-width: 560px; margin-inline: auto; padding-top: var(--space-6); }
.offline__head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); min-width: 0; }
.offline__text { color: var(--ink-2); max-width: 38ch; }
.offline__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); width: 100%; margin-top: var(--space-3); }
@media (max-width: 479px) { .offline__actions .btn { flex: 1 1 100%; } }
@media (min-width: 700px) { .offline { padding-top: var(--space-10); } }
/* The worker's own page has no top bar or menu above it, so it sits a little lower. */
body > .page > .offline { padding-top: max(var(--space-12), 12vh); }

/* ---------- Slice 7: money ---------- */

/* The credit note sheet shows the part for the way of crediting that is chosen. With no :has() support both parts show. */
.credit-when[data-when-mode] { display: none; flex-direction: column; gap: var(--space-2); }
.dialog:has(input[name="mode"][value="lines"]:checked) .credit-when[data-when-mode="lines"],
.dialog:has(input[name="mode"][value="amount"]:checked) .credit-when[data-when-mode="amount"] { display: flex; }
@supports not selector(:has(*)) { .credit-when[data-when-mode] { display: flex; } }

/* Money settings: the VAT number and how prices are typed only show for a business that is registered. */
.card [data-vat-on] { display: none; }
.card:has(input[name="registered"]:checked) [data-vat-on] { display: flex; flex-direction: column; gap: 6px; }
.card:has(input[name="registered"]:checked) [data-vat-off] { display: none; }
@supports not selector(:has(*)) { .card [data-vat-on] { display: flex; flex-direction: column; gap: 6px; } .card [data-vat-off] { display: none; } }

/* A row that is a button (the list of job types in the add-a-line sheet) looks like any other row. */
button.row { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
.pick-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); min-height: var(--tap); }
.list > li:last-child > .pick-row { border-bottom: 0; }
.dialog .list { margin-inline: calc(var(--space-5) * -1); }

/* The buttons at the foot of a form that is laid out in columns sit in a row (the column rule would stack them). */
.split > .actionbar { display: flex; }

/* The job card (slice 8). A line that says what needs a signal is shown only with none; what needs one is dimmed then. */
[data-when-offline] { display: none; }
html[data-state="offline"] [data-when-offline] { display: block; }
html[data-state="offline"] [data-needs-signal] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Slice 10: the vehicle lookup cards ---------- */

/* Check again: while the answer is awaited the button turns and the two lines give way to grey bars. */
#vehicle-status .when-busy, #vehicle-status .status-wait, #vehicle-status .status-wait-sr { display: none; }
#vehicle-status.htmx-request .when-idle, #vehicle-status.htmx-request .status-live { display: none; }
#vehicle-status.htmx-request .when-busy { display: inline-flex; align-items: center; gap: var(--space-2); }
#vehicle-status.htmx-request .status-wait { display: grid; }
#vehicle-status.htmx-request .status-wait-sr { display: block; }
#vehicle-status .when-idle { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ---------- Slice 11: memberships ---------- */

/* A plan's form shows the part for the kind chosen (a membership that carries on, or a pass), and the hours only when "Only at certain times" is on.
   With no :has() support every part shows. */
.plan-form [data-plan-kind] { display: none; flex-direction: column; gap: var(--space-4); }
.plan-form:has(input[name="kind"][value="recurring"]:checked) [data-plan-kind="recurring"],
.plan-form:has(input[name="kind"][value="pass"]:checked) [data-plan-kind="pass"] { display: flex; }
.plan-form [data-hours] { display: none; }
.plan-form:has(input[name="hours_on"]:checked) [data-hours] { display: grid; }
@supports not selector(:has(*)) { .plan-form [data-plan-kind], .plan-form [data-hours] { display: flex; } }
