/* Locum Manager styles. Sections, in order:
   1. Base            2. Top bar           3. Layout & utilities   4. Alerts
   5. Forms           6. Buttons           7. Tables               8. Tags & status text
   9. Admin home & reports                 10. Opening times       11. Review bookings
   12. Shift form     13. Calendar         14. Quick-book menu     15. Modal
   16. Invoices       17. Invoice tick-list                        18. Activity & error log
   19. Login pages & footer                    20. Reminders
   Each section's mobile tweaks sit at the end of that section. */

/* ---------- 1. Base ---------- */
:root {
    --bg: #eceff3;   /* a touch darker than the white boxes, so each box stands out */
    --surface: #ffffff;
    --card-border: #dfe3e8;
    --card-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;   /* message text on --danger-bg: easier to read than --danger */
    --success-bg: #ecfdf5;
    --success: #047857;
    --warn-bg: #fffbeb;
    --warn: #b45309;
    --warn-text: #92400e;
    --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }

/* ---------- 2. Top bar ---------- */
.topbar { background: var(--primary); color: #fff; }
.topbar-inner {
    max-width: 1200px; margin: 0 auto; padding: 0 16px;
    display: flex; align-items: center; flex-wrap: wrap; min-height: 56px;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; margin-right: 1.5rem; display: inline-flex; align-items: center; gap: .5rem; }
/* Logo sits on a small white badge so its blue/green shows up on the teal bar */
.brand-badge { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: #fff; }
.brand-badge img { display: block; width: 22px; height: 22px; }
.nav { display: flex; align-items: center; gap: .25rem; flex: 1; }
.nav a, .nav .link {
    color: #e6fffb; text-decoration: none; padding: .45rem .75rem; border-radius: 6px;
    font-size: .95rem; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav .link:hover, .nav a.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-spacer { flex: 1; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }
.badge { background: rgba(255,255,255,.25); border-radius: 4px; font-size: .7rem; padding: 1px 5px; vertical-align: middle; }
.nav .count { display: inline-block; background: var(--danger); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 6px; margin-left: 2px; }
.nav a.nav-review { color: #fff; font-weight: 600; }

@media (max-width: 760px) {
    .nav-toggle { display: block; }
    .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .75rem; }
    .nav.open { display: flex; }
    .nav-spacer { display: none; }
    .nav .inline { display: block; }
    .nav .link { width: 100%; text-align: left; }
}

/* ---------- 3. Layout & utilities ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.card {
    background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 20px; box-shadow: var(--card-shadow);   /* a soft lift off the page */
}
.card.narrow { max-width: 640px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.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; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 480px; }
.month-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.month-nav h1 { margin: 0 .25rem; min-width: 10ch; text-align: center; }
.filters { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters select { width: auto; min-width: 200px; }
/* Tabs + filter bar (e.g. Invoices), section headings with a control on the right */
.view-tabs { display: flex; gap: .4rem; margin: -.25rem 0 1rem; }
.view-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: -.25rem 0 1rem; }
.view-bar .view-tabs { margin: 0; }
.view-filter { display: flex; align-items: center; gap: .4rem; margin: 0; }
.view-filter select, .view-filter input[type=date] { width: auto; padding: .3rem .5rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.section-head h2 { margin-bottom: .5rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: .75rem; margin: .75rem 0; }
.pager [aria-disabled] { opacity: .45; pointer-events: none; }

/* ---------- 4. Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); border-color: #fecaca; }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); border-color: #fde68a; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.alert-own { background: #faf5ff; color: #6b21a8; border-color: #e9d5ff; }
/* Messages from the last action (render_flashes): cards floating at the top middle, just below the top bar.
   "Done" messages fade on their own; the rest stay until closed. */
.topbar + .container .toasts { top: 72px; }   /* below the top bar; pages without it (log in, a locum's link) use the very top */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1100; display: grid; justify-items: center; gap: .5rem;
    width: min(640px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: .7rem; padding: .75rem .9rem .75rem .8rem; pointer-events: auto; line-height: 1.45;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px;
    box-shadow: 0 12px 32px rgba(17, 24, 39, .16); animation: toast-in .25s ease-out; transition: opacity .3s ease, transform .3s ease; }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); }
.toast-icon { display: grid; place-items: center; flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; font-size: .8rem; font-weight: 700; color: #fff; }
.toast-text { flex: 1; font-weight: 500; padding-top: .1rem; white-space: pre-line; }   /* pre-line: a list of form problems, one per line */
.toast-close { flex: none; border: 0; background: none; color: inherit; opacity: .5; font-size: 1.3rem; line-height: 1; padding: 0 .15rem; cursor: pointer; }
.toast-close:hover { opacity: 1; }
.toast-success { background: var(--success-bg); color: #065f46; border-color: #6ee7b7; border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success); }
.toast-error { background: var(--danger-bg); color: var(--danger-text); border-color: #fca5a5; border-left-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger); }
.toast-warning { background: var(--warn-bg); color: var(--warn-text); border-color: #fcd34d; border-left-color: #d97706; }
.toast-warning .toast-icon { background: #d97706; }
.toast-info { background: #eff6ff; color: #1e3a8a; border-color: #93c5fd; border-left-color: #2563eb; }
.toast-info .toast-icon { background: #2563eb; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; transition: none; } }

/* ---------- 5. Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.field { margin-bottom: 1rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=search], input[type=tel], input[type=month], select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid #d1d5db; border-radius: 6px;
    font: inherit; background: #fff; color: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #99f6e4; border-color: var(--primary); }
input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.checkbox input { width: 18px; height: 18px; }
.checkbox.disabled { color: var(--muted); }
.checkbox.copy-me { margin-top: .3rem; gap: .35rem; font-size: .8rem; font-weight: 400; color: var(--muted); }   /* "Send me a copy" under an email button */
.checkbox.copy-me input { width: 14px; height: 14px; }
.required::after { content: " *"; color: var(--danger); }

/* ---------- 6. Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .55rem 1rem; border-radius: 6px; border: 1px solid transparent;
    background: var(--primary); color: #fff; font: inherit; font-weight: 600;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: #d1d5db; }
.btn-secondary:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
/* Xero: anything that sends to Xero is blue (a darker Xero blue, so white text stays readable) */
.btn-xero { background: #0b78b5; }
.btn-xero:hover { background: #09659a; }
/* WhatsApp: opens WhatsApp with a message ready to send (locum page, invoice page) */
.btn-whatsapp { color: #0b7a5e; border-color: #9fd8c4; align-items: baseline; }   /* baseline: lines up by its words, like the buttons beside it */
.btn-whatsapp:hover { background: #ecfdf5; }
.icon-whatsapp { width: 1.15em; height: 1.15em; flex: none; align-self: center; fill: #25d366; }   /* WhatsApp's own green; centred, so it doesn't set the line-up */
.btn:disabled .icon-whatsapp { fill: currentColor; }
/* Locums list: WhatsApp icon just before the mobile number; same width on every row so the numbers line up */
.row-whatsapp { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; margin: -.3rem .45rem -.3rem -.3rem;
    vertical-align: middle; border-radius: 8px; }
a.row-whatsapp:hover { background: #ecfdf5; }
.row-whatsapp .icon-whatsapp { width: 1.3rem; height: 1.3rem; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--primary); }
.disabled-link { pointer-events: none; opacity: .45; }
.input-with-btn { display: flex; gap: .4rem; align-items: center; }
.input-with-btn input { flex: 1; min-width: 0; }
.input-with-btn .btn { white-space: nowrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

/* ---------- 7. Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafafa; }
tr:hover td { background: #fafafa; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot th { background: #f9fafb; color: var(--text); font-size: .9rem; text-transform: none; letter-spacing: 0; }
tr.row-conflict td { background: var(--danger-bg); }
tr.row-flag td { background: #fff5f5; }
tr.row-skipped td { color: var(--muted); }
.row-muted td { color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: .4rem; border: 1px solid rgba(0,0,0,.1); }
/* Phones: a "stack" table shows each row as a small card - the first cell as its heading,
   the others as "Label  value" lines (label from data-label). No sideways scrolling. */
@media (max-width: 640px) {
    th, td { padding-left: .5rem; padding-right: .5rem; }
    table.stack thead { display: none; }
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
    table.stack tbody tr { padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
    table.stack td { border: 0; padding: .1rem 0; white-space: normal; }
    table.stack td.num { text-align: left; }
    table.stack td:first-child, table.stack td.stack-title { font-weight: 600; padding-bottom: .25rem; }
    table.stack td[data-label]::before, table.stack tfoot th[data-label]::before { content: attr(data-label); display: inline-block; min-width: 6.5rem; margin-right: .5rem;
        font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
    table.stack tfoot th[data-label]::before { min-width: 0; }
    table.stack td:empty { display: none; }
    table.stack td[data-label] > .tag:first-child { margin-left: 0; }
    table.stack td.stack-actions { padding-top: .45rem; text-align: left; }
    table.stack td.stack-inline { display: inline-block; width: auto; vertical-align: middle; margin-right: .5rem; }
    table.stack tr.row-conflict, table.stack tr.row-flag { background: var(--danger-bg); }
    table.stack tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; padding: .25rem .9rem; background: #f9fafb; }
    table.stack tfoot th { display: block; border: 0; padding: .35rem 0; }
    table.stack tfoot th:empty { display: none; }
}

/* ---------- 8. Tags & status text ---------- */
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #e5e7eb; color: #374151; margin-left: .3rem; vertical-align: middle; }
.tag-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.tag-retro { background: #f3f4f6; color: #4b5563; font-weight: 500; font-style: italic; }
.tag-ok { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }
/* Invoices: self-billed (ours) vs the locum's own - always clearly different */
.tag-self { background: #e0f2f1; color: #0f766e; border: 1px solid #99d5cf; }
.tag-own { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
/* ...except in invoice lists, where the type is a quiet grey label before the reference */
.tag-kind { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; margin-left: 0; margin-right: .35rem; }
.tag-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.tag-future { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
/* Coloured text - after the buttons so it also colours a grey button (e.g. a red "Delete") */
.danger-text { color: var(--danger); }
.issue-line { color: var(--danger); }
.status-ok { color: var(--success); font-weight: 600; }
.status-skip { color: var(--warn); }
/* Old shifts are locked (see shift_lock_date) */
/* "🔒 Paid" in place of Edit / Delete: quiet grey, links to the invoice (Undo paid unlocks the shift) */
.paid-lock { color: var(--muted); font-size: .85rem; text-decoration: none; white-space: nowrap; }
.paid-lock:hover { color: var(--text); text-decoration: underline; }
.lock-note { color: #475569; background: #f1f5f9; border: 1px solid var(--border); border-radius: 6px; padding: .45rem .75rem; margin: 0 0 1rem; }
.match-ok { color: #15803d; font-weight: 600; }

/* ---------- 9. Admin home & reports ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.grid-cards a.card { display: block; text-decoration: none; color: inherit; margin: 0; }
.grid-cards a.card:hover { border-color: var(--primary); }
.grid-cards a.card h3 { margin: 0 0 .25rem; color: var(--primary); font-size: 1.05rem; }
.grid-cards a.card-attention { border-left: 4px solid var(--warn); }
.card-stat { font-weight: 600; margin-bottom: .25rem; }
.card-stat-lines > div { line-height: 1.5; }
.cover-month { margin-top: 1.75rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.share-bar { display: inline-block; width: 80px; height: 8px; background: #f3f4f6; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.share-bar span { display: block; height: 100%; }

/* ---------- 10. Opening times ---------- */
.day-row { border-bottom: 1px solid var(--border); padding: 14px 0; display: grid; grid-template-columns: 130px 110px 1fr; gap: 1rem; align-items: start; }
.day-row:last-child { border-bottom: 0; }
.day-name { font-weight: 600; padding-top: .45rem; }
.segments { display: flex; flex-direction: column; gap: .5rem; }
.segment { display: flex; align-items: center; gap: .5rem; }
.segment input[type=time] { width: 130px; }
.day-row.closed .segments { opacity: .4; pointer-events: none; }
.opening-period.current { border-left: 4px solid var(--primary); }
.opening-period.scheduled { border-left: 4px solid #3b82f6; }
.opening-period.past { opacity: .75; }
@media (max-width: 640px) {
    .day-row { grid-template-columns: 1fr 1fr; }
    .day-row .segments { grid-column: 1 / -1; }
}

/* ---------- 11. Review bookings ---------- */
.review-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.review-help { margin-top: -.5rem; }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 12px 16px; }
.review-actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.review-actions form { display: inline; }
.fit-choice { border: 1px solid #fde68a; background: var(--warn-bg); border-radius: 6px; padding: .6rem .8rem; margin-bottom: 1rem; }
.fit-choice .fit-title { font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.fit-choice .checkbox { margin: .25rem 0; align-items: flex-start; }
.fit-choice .checkbox input { margin-top: 3px; flex-shrink: 0; }

/* ---------- 12. Shift form ---------- */
.day-info { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 6px; padding: .6rem .8rem; margin: -.25rem 0 1rem; font-size: .9rem; }
.day-info .bh { color: var(--warn); font-weight: 600; }
.quick-times { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .4rem; }
.quick-times:empty { display: none; }
.summary { font-weight: 600; margin-top: .75rem; font-size: 1.05rem; }
.override-box { margin: .5rem 0; padding: .5rem .7rem; border-radius: 6px; border: 1px dashed #d1d5db; align-items: flex-start; }
.override-box.attention { border-color: var(--warn); background: var(--warn-bg); }
.override-box input { margin-top: 3px; flex-shrink: 0; }
.override-box .hint { display: block; }
.override-box.disabled { opacity: .5; background: #f3f4f6; border-style: solid; border-color: var(--border); cursor: not-allowed; }
.override-box.disabled input { cursor: not-allowed; }
.weekday-picks { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }

/* ---------- 13. Calendar ---------- */
.cal-summary { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin-bottom: 1rem; }
.cal-summary strong { font-size: 1.1rem; }
.legend-item { font-size: .9rem; white-space: nowrap; }
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: .5rem; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; background: #fafafa; border-bottom: 1px solid var(--border); }
.cal-cell { position: relative; min-height: 110px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
/* Month change (swipe or ‹ ›): the calendar slides out one side and the new month in from the other.
   Only the calendar page turns page transitions on (index.php), and only with motion allowed. */
.cal { view-transition-name: cal; }
html:active-view-transition-type(next)::view-transition-old(cal) { animation: cal-out-left .22s ease-in both; }
html:active-view-transition-type(next)::view-transition-new(cal) { animation: cal-in-right .22s ease-out both; }
html:active-view-transition-type(prev)::view-transition-old(cal) { animation: cal-out-right .22s ease-in both; }
html:active-view-transition-type(prev)::view-transition-new(cal) { animation: cal-in-left .22s ease-out both; }
::view-transition-group(root) { animation-duration: .22s; }
@keyframes cal-out-left { to { transform: translateX(-25%); opacity: 0; } }
@keyframes cal-out-right { to { transform: translateX(25%); opacity: 0; } }
@keyframes cal-in-right { from { transform: translateX(25%); opacity: 0; } }
@keyframes cal-in-left { from { transform: translateX(-25%); opacity: 0; } }
.cal-cell:hover { background: #f9fafb; }
.cal-cell:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-cell.other { background: #fafafa; cursor: default; }
.cal-cell.closed { background: repeating-linear-gradient(135deg, #fafafa, #fafafa 6px, #f3f4f6 6px, #f3f4f6 12px); }
/* Signals - the same everywhere: red = needs sorting out (a problem nobody approved, or hours nobody is booked for),
   amber = a problem that was approved (nothing to do), teal = today. Bank holidays are a quiet grey-blue with a star. */
.cal-cell.bank-holiday { background: #eef2f7; }
.cal-cell.needs-review { background: #fee2e2; box-shadow: inset 0 0 0 3px var(--danger); }
.cal-cell.needs-review:hover { background: #fecaca; }
.cal-dwarn { color: #b91c1c; font-weight: 800; }
.cal-label { font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.cal-label-review { background: #b91c1c; color: #fff; }
.cal-label-approved { background: #fef3c7; color: #92400e; margin-right: 14px; }
/* Approved problem: a small amber folded corner, top right */
.cal-fold { position: absolute; top: 0; right: 0; width: 0; height: 0; border-style: solid; border-width: 0 18px 18px 0; border-color: transparent #d97706 transparent transparent; }
.cal-review-line { font-size: .75rem; font-weight: 700; color: #991b1b; line-height: 1.3; }
/* Above the calendar: problems nobody has approved yet, in words - loud, because they're rare */
.problem-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 1rem; border-radius: var(--radius); background: #b91c1c; color: #fff; }
.problem-icon { font-size: 1.25rem; line-height: 1; }
.problem-text { flex: 1; min-width: 0; }
.problem-text ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.problem-note { font-size: .9rem; opacity: .9; margin-top: .2rem; }
.btn.problem-fix { background: #fff; color: #b91c1c; }
.btn.problem-fix:hover { background: #fee2e2; }
.cal-cell.past .cal-dnum { color: var(--muted); }
.cal-date { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.cal-dname { display: none; }
.cal-cell.today .cal-dnum { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 700; }
.cal-warn { color: var(--danger); font-weight: 700; }
.cal-note { font-size: .72rem; color: var(--muted); }
.cal-note.bh { color: #334155; font-weight: 600; }
.chip {
    font-size: .74rem; line-height: 1.25; border-left: 4px solid var(--c, #999); border-radius: 4px; padding: 2px 5px;
    background: #f3f4f6; background: color-mix(in srgb, var(--c, #999) 14%, white);
    display: flex; flex-wrap: wrap; column-gap: .35rem; overflow: hidden;
}
.chip-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chip-time { white-space: nowrap; }
.chip-cost { color: #374151; white-space: nowrap; }
/* Not yet reviewed (on a red day): white with a red outline, so the shifts involved stand out.
   An approved problem leaves the shift looking normal - the day gets the amber corner instead. */
.chip-review { background: #fff; outline: 2px solid var(--danger); outline-offset: -2px; }
.chip-review .chip-name { color: #991b1b; }
/* Booked / changed retrospectively - informational, deliberately not red */
.chip-retro { flex-basis: 100%; font-size: .68rem; color: #4b5563; font-style: italic; }
.retro-line { color: #4b5563; font-style: italic; }
.swatch-review { background: #fee2e2; border: 2px solid var(--danger); }
.swatch-approved { background: linear-gradient(225deg, #d97706 0 45%, #fff 45%); border: 1px solid #d1d5db; }
/* Hours nobody is booked for ("Needs cover") - red dashed, on any open day. Clicking one books it (unless the day is locked). */
.open-slot {
    display: block; font-size: .74rem; line-height: 1.3; padding: 2px 5px; border-radius: 4px;
    border: 2px dashed var(--danger); color: #991b1b; font-weight: 600; text-decoration: none; background: #fff;
}
a.open-slot:hover { border-style: solid; background: #fef2f2; color: #7f1d1d; }
/* After next month (cover_gap_urgent): calm grey - not booked yet is normal that far out */
.open-slot.open-slot-later { border: 1px dashed #9ca3af; color: #4b5563; font-weight: 400; }
a.open-slot.open-slot-later:hover { border-color: var(--primary); color: var(--primary); background: #f0fdfa; }
.cover-gap.cover-gap-later { color: #4b5563; font-weight: 600; }
.swatch-open { background: #fff; border: 2px dashed var(--danger); }
.legend-open { color: var(--text); text-decoration: none; }
.legend-open:hover { color: var(--primary); text-decoration: underline; }
.legend-open-later .swatch-open { border-color: #9ca3af; }
.cal-total { margin-top: auto; text-align: right; font-size: .78rem; font-weight: 700; }
/* Cover check: bottom row of each day - tick / gaps on the left, day total on the right */
.cal-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.cal-foot .cal-total { margin-top: 0; }
.cover-ok {
    display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
    border-radius: 50%; background: #bbf7d0; color: #166534; font-size: .7rem; font-weight: 800; line-height: 1;
}
.cover-gap { color: var(--danger); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.cover-line { color: #15803d; font-weight: 600; font-size: .9rem; margin: .4rem 0; }
/* Phones only: initials and the ? help (the desktop shows full chips and the legend instead) */
.chip-ini, .cal-help-btn, .cal-help { display: none; }
/* Phones: the whole month at a glance - coloured initials in time order, a red dash where
   nobody is booked. Same page, same data as the desktop: only the layout changes.
   Tapping a day opens the day pop-up (as a sheet from the bottom). */
@media (max-width: 760px) {
    .cal-summary { gap: .25rem .75rem; margin-bottom: .5rem; }
    .cal-summary .legend-locum, .cal-summary .legend-mark, .legend-hours { display: none; }
    .legend-open { color: var(--danger-text, #991b1b); font-weight: 700; }
    /* The header mark is the same dash the days show: red this month and next, grey further ahead */
    .legend-open .swatch-open { width: 18px; height: 0; border: 0; border-top: 3px dashed var(--danger); border-radius: 0; }
    .legend-open.legend-open-later { color: #4b5563; }
    .legend-open.legend-open-later .swatch-open { border-top-color: #9ca3af; }
    .cal-help-btn {
        display: inline-flex; align-items: center; justify-content: center; margin-left: auto; width: 44px; height: 44px;
        border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
    }
    .cal-help-btn[aria-expanded="true"] { background: #ccfbf1; color: var(--primary); border-color: var(--primary); }
    .cal-help:not([hidden]) {
        display: flex; flex-direction: column; margin: 0 0 .5rem; padding: 4px 12px;
        background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: .85rem; color: #1f2937;
    }
    /* Each line of the key: a small picture of a day square, then the word used everywhere, then plain words */
    .help-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
    .help-row + .help-row { border-top: 1px solid #f1f5f9; }
    .help-row strong { display: block; }
    .help-row small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.35; }
    .help-cell {
        position: relative; flex: none; width: 44px; height: 40px; overflow: hidden;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: .72rem; font-weight: 700; line-height: 1.25;
    }
    .help-cell .cal-fold { border-width: 0 12px 12px 0; }
    .help-cell-review { background: #fee2e2; box-shadow: inset 0 0 0 2px var(--danger); color: #b91c1c; }
    .help-cell-closed { background: #f3f4f6; color: var(--muted); }
    .help-ini-a { color: #a16207; }
    .help-ini-b { color: #1e40af; }
    .help-dash { display: block; width: 24px; border-top: 3px dashed var(--danger); }
    .help-today { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 999px; background: var(--primary); color: #fff; }

    .cal { border-radius: 8px; }
    .cal-head div { padding: .35rem 0; text-align: center; font-size: .72rem; }
    .cal-cell { min-height: 84px; padding: 4px 1px 3px; align-items: center; gap: 2px; }
    .cal-date { justify-content: center; font-size: .85rem; font-weight: 600; }
    .cal-cell.today .cal-dnum { padding: 0 6px; }
    .cal-fold { border-width: 0 14px 14px 0; }
    /* Words move to the pop-up: the grid keeps only the marks */
    .cal-label, .cal-review-line, .cal-foot, .cal-note-text { display: none; }
    .cal-cell.closed:not(.bank-holiday) .cal-note { display: none; }
    .cal-cell.closed .cal-dnum { color: var(--muted); }
    .cal-cell.today .cal-dnum { color: #fff; } /* today stays white on teal, even on a closed day */
    .cal-note.bh { font-size: .8rem; }
    .chip { display: block; background: none; border: 0; outline: 0; padding: 0; font-size: .8rem; overflow: visible; }
    .chip-name, .chip-time, .chip-cost, .chip-retro { display: none; }
    .chip-ini { display: block; font-weight: 700; line-height: 1.15; color: var(--c, #374151); color: color-mix(in srgb, var(--c, #374151) 70%, black); }
    .chip-review .chip-ini { color: #991b1b; }
    .cal-cell.past .chip-ini { color: #9ca3af; }
    /* A gap is a dash in the place it falls; tapping goes to the day (Book is in the pop-up) */
    .open-slot {
        width: 22px; height: 0; margin: 6px 0 5px; padding: 0; border: 0; border-top: 3px dashed var(--danger); border-radius: 0;
        background: none; font-size: 0; line-height: 0; overflow: hidden; pointer-events: none;
    }
    .open-slot.open-slot-later { border: 0; border-top: 3px dashed #9ca3af; }
}

/* ---------- 14. Quick-book menu (click a "Needs cover" gap) ---------- */
.qb-menu {
    position: fixed; z-index: 1000; width: 230px; max-width: calc(100vw - 16px); padding: .35rem;
    background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.qb-head { font-size: .78rem; font-weight: 700; color: var(--muted); padding: .3rem .5rem .4rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.qb-item { display: flex; align-items: center; gap: .45rem; padding: .4rem .5rem; border-radius: 5px; color: var(--text); text-decoration: none; font-size: .9rem; }
.qb-item:hover, .qb-item:focus { background: #f0fdfa; color: var(--primary); outline: none; }
.qb-item .swatch { margin: 0; }
.qb-other { width: 100%; margin: .35rem 0 .2rem; padding: .35rem; font-size: .88rem; }
.qb-plain { display: block; padding: .3rem .5rem; text-decoration: none; }
.qb-plain:hover { text-decoration: underline; }
/* Phones: bigger targets for fingers */
@media (max-width: 760px) {
    .qb-menu { width: 260px; }
    .qb-item { padding: .7rem .6rem; font-size: 1rem; }
    .qb-plain { padding: .6rem .6rem; }
    .qb-other { padding: .55rem; font-size: 1rem; }
}

/* ---------- 15. Modal (calendar day) ---------- */
.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(17, 24, 39, .45); }
.modal-body { padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.modal-head h2 { margin: 0 0 .25rem; }
.modal-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-shifts { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0 .5rem; }
.modal-shift { display: flex; justify-content: space-between; gap: .75rem; align-items: center; border-left: 5px solid var(--c, #999); background: #f9fafb; border-radius: 6px; padding: .5rem .75rem; flex-wrap: wrap; }
.modal-shift.chip-review { background: #fff; }
.issue-approved { color: #92400e; }
.modal-shift-main { flex: 1 1 14rem; }   /* wraps its own text first, so Edit / Delete (or "Paid") stay on the right */
.modal-shift-actions { display: flex; gap: .4rem; }
.modal-total { text-align: right; font-weight: 700; }
.modal .alert { margin: .75rem 0 0; }
.modal-close { min-width: 44px; min-height: 44px; }
/* Name in the locum's colour (darkened so it stays readable) */
.shift-name { color: var(--c, var(--text)); color: color-mix(in srgb, var(--c, #374151) 70%, black); }
.chip-review .shift-name { color: #991b1b; }
/* A gap in the day's line-up: same dashes as the calendar - red this month and next, grey later */
.modal-gap { border-left: 0; border: 2px dashed var(--danger); background: #fff; }
.modal-gap .gap-name { color: #991b1b; }
.modal-gap.modal-gap-later { border: 1px dashed #9ca3af; }
.modal-gap.modal-gap-later .gap-name { color: #4b5563; }
/* Needs review: what's wrong, and the ways to sort it out */
.day-review { margin: .75rem 0 0; padding: .7rem .8rem; border: 2px solid var(--danger); border-radius: 10px; background: #fef2f2; color: #991b1b; display: flex; flex-direction: column; gap: .5rem; }
.day-review-line { font-weight: 700; }
.day-review-edits { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; }
.day-review-edits .btn { text-align: center; }
.day-review form { margin: 0; }
.day-review a.small { color: #991b1b; }
.btn.btn-keep { width: 100%; background: #b45309; border-color: #b45309; color: #fff; }
.btn.btn-keep:hover { background: #92400e; border-color: #92400e; }
.day-foot { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: .25rem 0 .5rem; }
.day-foot .cover-gap { font-size: .9rem; }
.day-foot .cover-line { margin: 0; }
/* Phones: the same pop-up as a sheet from the bottom of the screen */
@media (max-width: 760px) {
    .modal { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 88vh; max-height: 88dvh; animation: sheet-up .18s ease-out; }
    .modal-body { padding: 8px 16px 20px; }
    .modal-body::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: #d1d5db; margin: 0 auto 8px; }
    .modal-head h2 { font-size: 1.1rem; }
    .modal-shifts { margin: .75rem 0 .5rem; }
    .modal .actions .btn { width: 100%; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

/* ---------- 16. Invoices ---------- */
.invoice-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }   /* baseline: buttons stay level when one has "Send me a copy" under it */
.invoice-actions form { display: inline; }
/* Send invoice: one button, the ticks (Email locum / Email Xero / copy to me) underneath */
.invoice-actions form.send-box { display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; flex: 1 1 0; min-width: 15rem; }   /* takes the space left by the buttons on the right; the ticks wrap first */
.send-ticks { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.send-ticks .checkbox { gap: .4rem; }
.send-note { color: var(--muted); font-weight: 400; font-size: .85rem; }
.invoice-actions-side { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; margin-left: auto; }   /* PDF, change, delete, cancel - over on the right */
/* The invoice page is one column, the invoice's width; the invoice itself looks like a sheet of paper */
.invoice-page { max-width: 820px; margin: 0 auto; }
.invoice-preview { border-radius: 2px; padding: 48px 56px 56px; margin: 28px 0 32px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 18px 40px rgba(17, 24, 39, .12); }
@media (max-width: 640px) { .invoice-preview { padding: 20px; margin: 20px 0 24px; } }
.inv-head { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.inv-business { font-weight: 700; font-size: 1.15rem; }
.inv-title { font-weight: 800; font-size: 1.3rem; color: var(--primary); text-align: right; }
.inv-revised { font-size: .85rem; color: var(--danger); }
.inv-prepared { font-size: .75rem; font-weight: 400; color: var(--muted); max-width: 300px; margin-left: auto; }
.inv-label { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.inv-lines { line-height: 1.45; }
.inv-meta { width: auto; background: none; }
.inv-meta th { background: none; text-align: left; padding: .15rem .75rem .15rem 0; border: 0; }
.inv-meta td { font-weight: 700; text-align: right; padding: .15rem 0; border: 0; }
.inv-meta tr:hover td { background: none; }
.paid-ref { display: inline-block; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.ood-list { margin: .4rem 0 .5rem 1.1rem; padding: 0; }
.ood-list li { margin: .2rem 0; }
.own-box { margin-top: .5rem; padding: .6rem .8rem; border: 1px solid #e9d5ff; background: #faf5ff; border-radius: 6px; }
.payment-box { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1rem; }
/* Straight after an email, the natural next step: "Email it to Xero too?" / "Let them know on WhatsApp too?" */
.offer-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .75rem 1rem; border-radius: 10px; background: var(--success-bg);
    border: 2px solid #6ee7b7; color: #065f46; font-weight: 600; font-size: 1.02rem; animation: offer-pulse 1.4s ease-out .3s 2; }   /* pulses twice to catch the eye */
.offer-line .btn:not(.btn-sm) { padding: .65rem 1.4rem; font-size: 1rem; }
@keyframes offer-pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); } 100% { box-shadow: 0 0 0 14px rgba(16, 185, 129, 0); } }
@media (prefers-reduced-motion: reduce) { .offer-line { animation: none; } }
.offer-line .btn-whatsapp { background: var(--surface); }
.invoice-actions .offer-line, .payment-box .offer-line { order: 1; }   /* under the row of buttons, above the note */
.invoice-actions > .small, .payment-box > .small { order: 2; }
.payment-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin: 0; }
.payment-form .field { margin: 0; }
/* One status box per invoice: calm by default, red only when something must be done */
.inv-status { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.inv-status-done { border-left-color: var(--success); }
.inv-status-quiet { border-left-color: #cbd5e1; color: var(--muted); }
.inv-status-act { background: var(--danger-bg); border-color: #fecaca; border-left-color: var(--danger); color: #7f1d1d; }
.inv-status .status-note { margin-top: .4rem; }
.inv-status .status-warn { color: var(--warn); font-weight: 600; }
.inv-status .status-problems { margin-top: .5rem; color: var(--danger); }
.inv-status .status-problems ul { margin: .25rem 0; padding-left: 1.2rem; }
/* Test mode: deliberately loud, so nobody forgets it is on */
.test-mode-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius); border: 3px solid #facc15;
    background: repeating-linear-gradient(135deg, #db2777, #db2777 18px, #be185d 18px, #be185d 36px); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(219,39,119,.35); }
.test-mode-banner strong { background: #facc15; color: #111827; padding: 3px 12px; border-radius: 4px; font-size: 1.05rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.test-mode-banner b { text-decoration: underline; }

/* ---------- 17. Invoice tick-list (choose the shifts an invoice covers) ---------- */
.tick-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: 1rem 0 .5rem; }
.cover-month .checkbox { display: inline-flex; font-weight: 700; font-size: inherit; }
/* Fold / unfold a month; the heading says how much of it is ticked */
.tick-fold { padding: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 6px; width: 1.9rem; height: 1.9rem; margin-right: .4rem; cursor: pointer; font-size: 1.15rem; line-height: 1; color: var(--muted); vertical-align: middle; }
.tick-fold span[aria-hidden] { display: inline-block; transition: transform .15s; }
.tick-fold[aria-expanded="false"] span[aria-hidden] { transform: rotate(-90deg); }
.tick-month-sum { font-weight: 400; margin-left: .5rem; }
/* Whose shifts these are, on every month (clear) and week (quieter) heading */
.cover-month .tick-who { display: inline-flex; align-items: center; gap: .35rem; margin-left: .75rem; padding: 2px 10px; border-radius: 999px;
    background: #f1f5f9; border: 1px solid var(--border); font-size: .95rem; font-weight: 600; color: var(--text); vertical-align: middle; }
.cover-month .tick-who .swatch { margin: 0; }
/* Invoice form: whose invoice it is, in view while scrolling */
.locum-banner { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; margin-bottom: 1rem;
    padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--c, var(--primary)); border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(17, 24, 39, .08); }
.locum-banner-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.locum-banner-name { font-size: 1.4rem; line-height: 1.2; }
.tick-reg { font-weight: 500; color: var(--muted); font-size: .85em; margin-left: .25rem; }
.tick-who-small { font-weight: 400; color: var(--muted); font-size: .8rem; margin-left: .35rem; }
.tick-week { margin-bottom: .75rem; }
.tick-week-head { padding: .5rem .75rem; border-bottom: 1px solid var(--border); background: #f9fafb; }
/* Shifts indented under their week, ticked rows highlighted, columns lined up */
.tick-table { table-layout: fixed; width: 100%; }
.tick-table .c-tick { width: 3.75rem; }
.tick-table .c-date { width: 22%; }
.tick-table .c-time { width: 22%; }
.tick-row { cursor: pointer; transition: background-color .12s; }
.tick-row:hover td { background: #f9fafb; }
.tick-row td.tick-cell { padding-left: 2.25rem; }
.tick-row.is-ticked td { background: #ecfdf5; }
.tick-row.is-ticked:hover td { background: #d1fae5; }
/* Shifts in the future (not worked yet) - pastel yellow */
.tick-row.is-future td { background: #fefce8; }
.tick-row.is-future:hover td { background: #fef9c3; }
.tick-row.is-future.is-ticked td { background: #fef08a; }
.future-warning { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; color: #854d0e; background: #fef9c3; border: 1px solid #fde047; border-radius: 4px; padding: 4px 8px; font-weight: 600; }
/* Summary bar stuck to the bottom. Recording a locum's own invoice: pastel red until the totals match, then pastel green */
.tick-summary { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; z-index: 5; box-shadow: 0 -4px 12px rgba(0,0,0,.06);
    transition: background-color .2s, border-color .2s; }
.tick-summary.summary-bad { background: #fee2e2; border-color: #fca5a5; }
.tick-summary.summary-ok { background: #dcfce7; border-color: #86efac; }
.tick-summary.summary-bad .issue-line { color: #b91c1c; font-weight: 600; }
.tick-summary.summary-ok .match-ok { color: #15803d; }
.match-arrow { display: inline-block; font-size: 1.15rem; line-height: 1; vertical-align: -1px; margin-right: .15rem; }
@media (max-width: 760px) {
    .tick-row td.tick-cell { padding-left: 1rem; }
    .tick-table .c-tick { width: 2.5rem; }
    .tick-table .c-rate { width: 0; }
    .tick-table td:nth-child(5) { display: none; }
}
@media (max-width: 360px) {
    .tick-table .c-tick { width: 2rem; }
    .tick-row td.tick-cell { padding-left: .5rem; }
}

/* ---------- 18. Activity & error log ---------- */
.activity-filters .row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.activity-detail { margin-top: .35rem; font-size: .85rem; }
.activity-detail summary { cursor: pointer; color: var(--primary); }
.activity-detail table { margin-top: .35rem; }
.activity-detail td, .activity-detail th { padding: .15rem .6rem .15rem 0; vertical-align: top; }
.activity-detail tr.changed td { background: #fef9c3; }
.error-detail { white-space: pre-wrap; font-size: 11px; background: #f3f4f6; padding: 8px; border-radius: 6px; max-height: 300px; overflow: auto; margin: .5rem 0 0; }

/* ---------- 19. Login pages & footer ---------- */
.auth-wrap { max-width: 400px; margin: 8vh auto 0; }
.auth-wrap h1 { text-align: center; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.auth-logo img { display: block; }
.auth-wordmark { width: 220px; max-width: 70%; height: auto; }
.auth-wrap .auth-logo + h1 { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin-top: 0; }
.site-footer { text-align: center; font-size: .78rem; color: var(--muted); padding: 0 16px 24px; }

/* ---------- 20. Reminders ---------- */
/* Locum form: the reminder tick box, then (once ticked) the message for everyone and their own - lined up under the label */
.reminders-box > .checkbox { align-items: flex-start; }
.reminders-box > .checkbox input { margin-top: 3px; flex-shrink: 0; }
.reminders-box .checkbox .hint { display: block; }
.reminders-box .more-info, .reminder-note { margin-left: 26px; }
.reminder-note textarea { min-height: 0; }
.general-note { margin: .3rem 0 .7rem; padding: .4rem .7rem; border-left: 3px solid var(--primary); background: #f9fafb; font-size: .9rem; }
/* "How reminders work" - a quiet drop-down with the rules */
.more-info { margin: 0 0 .7rem; font-size: .82rem; color: var(--muted); }
.more-info summary { cursor: pointer; color: var(--primary); width: max-content; }
.more-info ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.more-info li { margin-bottom: .3rem; }
/* Locum page, Reminders card: their shifts page and ways to send it, what has happened, then the quiet extras */
.share-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; }
.share-row .hint { display: block; }
.share-buttons { display: flex; gap: .4rem; flex-wrap: wrap; }
.reminder-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .5rem 1rem; margin: 1rem 0; padding: .7rem .9rem; background: #f9fafb; border-radius: 6px; }
.reminder-status dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.reminder-status dd { margin: .15rem 0 0; font-weight: 500; }
.reminder-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.btn-link.quiet { color: var(--muted); font-size: .85rem; }
/* my_shifts.php: a locum's own shifts, opened from their emails (no login) */
.my-shifts { max-width: 560px; margin: 4vh auto 0; }
.my-shifts .auth-logo { margin-bottom: 1rem; }
.my-shifts h1 { font-size: 1.25rem; }
.my-shifts-week { font-size: .95rem; margin: 1.1rem 0 .3rem; color: var(--muted); }
.my-shifts-table { width: 100%; border-collapse: collapse; table-layout: fixed; }   /* fixed widths: columns line up week to week */
.my-shifts-table td:first-child { width: 48%; }
.my-shifts-table td:last-child { width: 18%; text-align: right; }
.my-shifts-table td { padding: .5rem .25rem; border-bottom: 1px solid var(--border); }
/* details.php: a locum fills in missing details and how they're paid (no login) */
.details-form .field label { display: block; }
.details-form .hint { display: block; margin-bottom: .2rem; }
.details-form label .hint { display: inline; }   /* "(optional)" stays next to its label */
.details-form .details-company-tick .hint { display: block; }
.details-form .input-postcode { max-width: 10rem; text-transform: uppercase; }   /* shown in capitals as they type; saved tidied */
.details-form input, .details-form textarea { font-size: 1rem; }   /* 16px+: phones don't zoom in on the box */
.details-section { font-size: 1rem; margin: 1.25rem 0 .6rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.field-error { color: var(--danger-text); font-size: .85rem; margin-top: .25rem; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.details-choices { border: 0; padding: 0; margin: 0; }
.details-choice { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; margin-bottom: .5rem; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.details-choice input { margin-top: .2rem; }
.details-choice strong, .details-choice .hint { display: block; }
.details-choice.on { border: 2px solid var(--primary); padding: calc(.7rem - 1px) calc(.8rem - 1px); }
.details-box { margin: .75rem 0 0; padding: .8rem .9rem; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); }
.details-box ul { margin: .4rem 0 .9rem; padding-left: 1.2rem; line-height: 1.55; }
.details-box h3 { font-size: 1rem; }
.details-save { width: 100%; margin-top: 1rem; padding: .75rem; font-size: 1rem; }
.details-done-icon { width: 48px; height: 48px; margin: 0 auto .5rem; border-radius: 50%; background: var(--success-bg); color: var(--success); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; }
/* Edit locum: sections with headings, a two-way switch, on/off switches, and a save bar */
.locum-form.narrow { max-width: 640px; }
.locum-form .card { margin-bottom: 1.25rem; }
.form-section-title { display: block; font-size: 1.05rem; font-weight: 600; margin: 0 0 .9rem; }
.form-section > .form-section-title { padding-bottom: .6rem; border-bottom: 1px solid #eef0f3; }   /* heading clearly apart from its boxes */
.form-sub { font-size: .92rem; font-weight: 600; margin: 1.1rem 0 .5rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.locum-form .hint { font-weight: 400; }
.locum-form .field { margin-bottom: .8rem; }
.locum-form .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* fixed pairs, so boxes line up section to section */
.locum-form .row-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr); }
.locum-form .row-address { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.page-sub { margin-top: .1rem; }
.swatch-lg { width: 18px; height: 18px; vertical-align: -1px; margin-right: .5rem; }
.label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.segmented label { margin: 0; font-weight: 500; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .5rem .85rem; font-size: .88rem; white-space: nowrap; }
.segmented label + label span { border-left: 1px solid var(--border); }
.segmented input:checked + span { background: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -3px; }
.switch-row { display: flex; align-items: center; gap: .6rem; margin: .4rem 0 .6rem; font-weight: 600; cursor: pointer; }
.switch-row-head { align-items: flex-start; margin-top: 0; }
.switch-row-head .hint { display: block; margin-top: -.6rem; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 2.2rem; height: 1.3rem; margin: 0; border-radius: 999px; background: #d1d5db; position: relative; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(.9rem); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nested { margin: 0 0 .4rem .45rem; padding-left: 1.1rem; border-left: 2px solid var(--border); }
.field-note { font-size: .85rem; color: var(--warn-text); margin: -.2rem 0 .6rem; }
.other-text { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.other-text summary { cursor: pointer; font-weight: 600; font-size: .92rem; margin-bottom: .5rem; }
.other-text textarea { width: 100%; }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin: 0 0 1rem;
    padding: .75rem 1rem; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.colour-pick { display: flex; align-items: center; gap: .5rem; margin: 0 auto 0 0; font-weight: 500; font-size: .85rem; color: var(--muted); cursor: pointer; }
.colour-pick input[type="color"] { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
@media (max-width: 640px) {
    .locum-form .row, .locum-form .row-3, .locum-form .row-address { grid-template-columns: 1fr; }
    .segmented span { padding: .5rem .6rem; }
    .colour-pick span { display: none; }
}
/* Locums list: Details and Invoicing columns */
.list-ok { color: var(--success); font-weight: 500; }
.list-missing { color: var(--warn-text); font-weight: 500; }
.list-company { margin-left: .4rem; padding: 0 .35rem; border: 1px solid var(--border); border-radius: 4px; font-size: .72rem; color: var(--muted); vertical-align: 1px; cursor: help; }
/* Every row one line high: details that don't fit go in a hover note (stacked phone layout still wraps) */
@media (min-width: 641px) { table.one-line th, table.one-line td { white-space: nowrap; } }
/* Locum page: the "Details and invoicing" card */
.details-status { display: flex; gap: .5rem; align-items: baseline; font-weight: 600; margin: .25rem 0; }
.details-status-agreed { color: var(--success); }
.details-status-none, .details-status-admin { color: var(--warn-text); }
.details-history { list-style: none; margin: .5rem 0 0; padding: .5rem 0 0; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.details-history li { padding: .15rem 0; }
.agreement-record { white-space: pre-line; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
/* Admin -> Reminders: the email preview */
.email-preview { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 6px; background: #f3f4f6; }
.cron-line { display: block; padding: .5rem .7rem; background: #111827; color: #f9fafb; border-radius: 6px; font-size: .85rem; overflow-x: auto; white-space: nowrap; }

/* Small one-off adjustments (used instead of style="" in templates). !important so they win like an inline style did. */
.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.p-0 { padding: 0 !important; }
.mt-xs { margin-top: .35rem !important; }
.mt-sm { margin-top: 12px !important; }
.mb-sm { margin-bottom: .5rem !important; }
.mb-md { margin-bottom: .75rem !important; }
.pt-xs { padding-top: .45rem !important; }
.pad-head { padding: 16px 16px 0 !important; }
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }
.ml-auto { margin-left: auto !important; }   /* pushes it (and what follows) over to the right */
.w-2rem { width: 2rem !important; }
.max-w-260 { max-width: 260px !important; }
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.fw-normal { font-weight: 400 !important; }
.fw-semibold { font-weight: 600 !important; }
.items-start { align-items: start !important; }
.basis-full { flex-basis: 100% !important; }
/* display is not !important, so [hidden] still hides it */
.row-between { display: flex; justify-content: space-between !important; align-items: center !important; gap: 1rem !important; flex-wrap: wrap !important; }

/* View-only link on a staff login (user_edit.php) */
.view-link-url { font-size:.8rem; word-break:break-all; background:var(--bg, #f6f7f9); padding:.35rem .5rem; border-radius:6px; flex:1 1 16rem; }
