/* LEMS — Lethbridge Emergency Medical Services
   Modern, high-contrast, accessible theme. Light and dark follow the OS setting. */

:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --text: #111827;
    --muted: #4b5563;
    --border: #d8dee6;
    --brand: #c8102e;            /* LEMS red */
    --primary: #0f3d5e;          /* deep navy */
    --primary-hover: #0a2c45;
    --primary-text: #ffffff;
    --link: #0b57a4;
    --topbar: #0d1b2a;
    --topbar-text: #e8eef5;
    --focus: #f5a524;
    --danger: #b42318;
    --danger-bg: #fdecea;
    --success: #13693a;
    --success-bg: #e7f6ec;
    --info-bg: #e8f1fb;
    --warn-bg: #fff4dc;
    --warn: #8a5300;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

    --s-full: #dbeafe;    --s-full-t: #1e3a8a;
    --s-reg: #d1fae5;     --s-reg-t: #065f46;
    --s-spec: #ede9fe;    --s-spec-t: #4c1d95;
    --s-adhoc: #fef3c7;   --s-adhoc-t: #78350f;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --surface: #121b2b;
        --surface-2: #172235;
        --text: #eef2f7;
        --muted: #b3bfce;
        --border: #2a3850;
        --primary: #5aa9e6;
        --primary-hover: #7cbcf0;
        --primary-text: #08121f;
        --link: #8cc8ff;
        --topbar: #070d18;
        --danger: #ff8a80;
        --danger-bg: #3a1513;
        --success: #7ee2a8;
        --success-bg: #0f2e1e;
        --info-bg: #13263d;
        --warn-bg: #3a2a08;
        --warn: #ffd27a;
        --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);

        --s-full: #1e3a8a;   --s-full-t: #dbeafe;
        --s-reg: #065f46;    --s-reg-t: #d1fae5;
        --s-spec: #4c1d95;   --s-spec-t: #ede9fe;
        --s-adhoc: #78350f;  --s-adhoc-t: #fef3c7;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 106.25%; /* 17px base */ -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
p { margin: 0 0 1rem; }

a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 1rem; top: -100px; z-index: 100;
    background: var(--focus); color: #000; padding: .6rem 1rem;
    border-radius: 8px; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.ok { color: var(--success); font-weight: 600; }

/* ---------- Top bar ---------- */

.topbar {
    background: var(--topbar);
    color: var(--topbar-text);
    position: sticky; top: 0; z-index: 10;
    border-bottom: 3px solid var(--brand);
}
.topbar-inner {
    max-width: var(--page-max); margin: 0 auto;
    padding: .7rem 1.25rem;
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand {
    display: flex; align-items: center; gap: .7rem;
    color: inherit; text-decoration: none;
}
.logo-mark { width: 40px; height: 40px; color: var(--brand); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.2rem; letter-spacing: .06em; }
.brand-sub { font-size: .78rem; opacity: .85; }

.site-nav { display: flex; align-items: center; gap: 1rem; flex: 1; justify-content: space-between; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; flex-wrap: wrap; }
.site-nav a {
    display: block; padding: .5rem .75rem; white-space: nowrap; border-radius: 10px;
    color: var(--topbar-text); text-decoration: none; font-weight: 550;
}
.site-nav a:hover { background: rgba(255,255,255,.1); }
.site-nav a[aria-current="page"] { background: rgba(255,255,255,.16); box-shadow: inset 0 -3px 0 var(--brand); }

.logout-form { display: flex; align-items: center; gap: .75rem; }
.whoami { font-size: .92rem; }
.topbar .btn-ghost { color: var(--topbar-text); border-color: rgba(255,255,255,.35); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

.nav-toggle {
    display: none; margin-left: auto;
    background: transparent; color: var(--topbar-text);
    border: 1px solid rgba(255,255,255,.35); border-radius: 10px;
    padding: .5rem .85rem; font: inherit; font-weight: 600; cursor: pointer;
    align-items: center; gap: .5rem;
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
    display: block; width: 18px; height: 2px; background: currentColor; position: relative; content: "";
}
.nav-toggle-bars::before { position: absolute; top: -6px; }
.nav-toggle-bars::after { position: absolute; top: 6px; }

@media (max-width: 1100px) {
    .nav-toggle { display: inline-flex; }
    .site-nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
    .site-nav.open { display: flex; }
    .site-nav ul { flex-direction: column; }
    .site-nav a { padding: .75rem 1rem; }
    .brand-sub { display: none; }
    .logout-form { justify-content: space-between; padding: .5rem 1rem 0; border-top: 1px solid rgba(255,255,255,.15); }
    .js .site-nav:not(.open) { display: none; }
}
/* The full group name is on the sign-in page and footer; the menu needs the room */
.topbar .brand-sub { display: none; }
/* Without JavaScript the menu is always visible */
html:not(.js) .site-nav { display: flex; }
html:not(.js) .nav-toggle { display: none; }

/* ---------- Layout ---------- */

:root { --page-max: 1440px; }
body.page-wide { --page-max: 1880px; }   /* the schedule uses the whole width of big monitors */
.container { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: 2rem 1.25rem 3rem; flex: 1; }
main:focus { outline: none; }

.page-head { margin-bottom: 1.5rem; }
.page-head p { margin: 0; }
.page-head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(300px, 400px) 1fr; align-items: start; }
@media (max-width: 860px) { .grid-sidebar { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.grid > .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-accent { border-top: 4px solid var(--brand); }
.card-narrow { max-width: 720px; }
.empty { text-align: center; padding: 2.5rem 1.5rem; }

.breadcrumb { margin: 0 0 .5rem; }
.breadcrumb a { text-decoration: none; font-weight: 600; }

.site-footer { text-align: center; color: var(--muted); font-size: .88rem; padding: 1.5rem; }
.site-footer p { margin: 0; }

/* ---------- Details & stats ---------- */

.details { margin: 0 0 1rem; display: grid; gap: .1rem; }
.details > div { display: grid; grid-template-columns: minmax(9rem, 13rem) 1fr; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.details > div:last-child { border-bottom: 0; }
.details dt { color: var(--muted); font-weight: 600; }
.details dd { margin: 0; word-break: break-word; }
@media (max-width: 480px) { .details > div { grid-template-columns: 1fr; gap: 0; } }

.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; display: flex; flex-direction: column; }
.stat-num { font-size: 2rem; font-weight: 750; line-height: 1.1; }
.stat-label { color: var(--muted); font-weight: 550; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block; padding: .15rem .6rem; border-radius: 999px;
    font-size: .8rem; font-weight: 650; line-height: 1.5; white-space: nowrap;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    vertical-align: middle;
}
.badge-admin { background: var(--brand); color: #fff; border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-status { border-color: transparent; }
.status-full_time     { background: var(--s-full);  color: var(--s-full-t); }
.status-regular_locum { background: var(--s-reg);   color: var(--s-reg-t); }
.status-special_locum { background: var(--s-spec);  color: var(--s-spec-t); }
.status-adhoc_locum   { background: var(--s-adhoc); color: var(--s-adhoc-t); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .65rem 1.15rem; min-height: 44px;
    border-radius: 10px; border: 2px solid transparent;
    font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .8rem; min-height: 36px; font-size: .92rem; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
legend { font-weight: 700; font-size: 1.1rem; margin-bottom: .75rem; padding: 0; }
.field { margin-bottom: 1.1rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: .35rem; }
.hint { font-size: .9rem; color: var(--muted); margin: .35rem 0 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
    width: 100%; font: inherit; color: var(--text);
    background: var(--surface); border: 2px solid var(--border); border-radius: 10px;
    padding: .6rem .8rem; min-height: 46px;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); }
textarea { resize: vertical; }

.password-wrap { display: flex; gap: .5rem; }
.password-wrap input { flex: 1; }

.radio-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.radio { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500 !important; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--primary); }

.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
form.inline { display: inline; }

.toolbar { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .field { margin-bottom: 0; min-width: 220px; flex: 0 1 320px; }
.toolbar p { margin: 0 0 .7rem; }

/* ---------- Alerts ---------- */

.alert { border-radius: 10px; padding: .85rem 1rem; margin-bottom: 1.25rem; border-left: 5px solid; }
.alert p, .alert ul { margin: 0; }
.alert ul { padding-left: 1.25rem; margin-top: .35rem; }
.alert-success { background: var(--success-bg); border-color: var(--success); }
.alert-error   { background: var(--danger-bg);  border-color: var(--danger); }
.alert-info    { background: var(--info-bg);    border-color: var(--primary); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { background: var(--surface-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table tbody th { font-weight: 600; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .nowrap { white-space: nowrap; }
.table .actions { white-space: nowrap; text-align: right; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
td.actions { display: table-cell; }
td.actions > * + * { margin-left: .4rem; }

/* ---------- Resources ---------- */

.resource-group { margin-bottom: 2rem; }
.resource-group h2 { padding-bottom: .4rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.resource-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.resource-card {
    display: flex; flex-direction: column; gap: .3rem; height: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow);
    transition: border-color .15s, transform .15s;
}
.resource-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.resource-title { font-weight: 700; font-size: 1.08rem; color: var(--link); }
.resource-desc { color: var(--text); }
.resource-host { color: var(--muted); font-size: .85rem; margin-top: auto; }

.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.admin-list li:last-child { border-bottom: 0; }
.admin-list li.is-editing { background: var(--info-bg); margin: 0 -1rem; padding: .85rem 1rem; border-radius: 10px; }
.admin-list p { margin: 0; word-break: break-all; }
.admin-list-title { font-weight: 650; word-break: normal !important; }

/* ---------- Sign-in page ---------- */

.auth-main {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem 1rem;
}
body:has(.auth-main) {
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(200, 16, 46, .14), transparent 60%),
        radial-gradient(900px 600px at 110% 110%, rgba(15, 61, 94, .2), transparent 60%),
        var(--bg);
}
.auth-main > .alert { width: 100%; max-width: 440px; }
.auth-card {
    width: 100%; max-width: 440px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
    box-shadow: var(--shadow); padding: 2rem;
}
.auth-brand { display: flex; align-items: center; gap: .85rem; margin-bottom: 1.5rem; }
.auth-brand .logo-mark { width: 52px; height: 52px; }
.auth-title { font-size: 1.5rem; font-weight: 800; letter-spacing: .08em; margin: 0; }
.auth-sub { color: var(--muted); margin: 0; font-size: .92rem; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.auth-card form + p { margin: 1rem 0 0; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* ---------- Paperwork checklist ---------- */

.checklist { list-style: none; margin: 0 0 1rem; padding: 0; }
.checklist li {
    display: grid; grid-template-columns: 2rem 1fr auto; align-items: center; gap: .75rem;
    padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.checklist li:last-child { border-bottom: 0; }
.check-icon {
    width: 2rem; height: 2rem; border-radius: 999px; display: grid; place-items: center;
    font-weight: 800; font-size: 1rem;
}
.check-value { font-weight: 650; white-space: nowrap; }
.check-yes .check-icon     { background: var(--success-bg); color: var(--success); }
.check-no .check-icon      { background: var(--danger-bg);  color: var(--danger); }
.check-pending .check-icon { background: var(--warn-bg);    color: var(--warn); }
.check-no .check-value      { color: var(--danger); }
.check-pending .check-value { color: var(--warn); }

.checklist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; margin-top: .75rem; }
.cell-note { display: block; font-size: .85rem; color: var(--muted); white-space: nowrap; }

/* Fields that only apply in some cases, indented under the field that controls them */
.subfields { border-left: 4px solid var(--border); padding-left: 1rem; margin: -.25rem 0 1.1rem; }
.subfields > :last-child { margin-bottom: 0; }
fieldset.field { margin-bottom: 1.1rem; }
fieldset.field legend.label { font-size: 1rem; font-weight: 600; margin-bottom: .35rem; }
[hidden] { display: none !important; }

input[type="date"] { max-width: 16rem; }

.input-suffix { display: flex; align-items: center; gap: .75rem; }
.input-suffix input { max-width: 8rem; }
.input-suffix span { font-weight: 500; }
.checkbox-list { display: grid; gap: .5rem; margin-top: .5rem; }
.checkbox-list input { width: 20px; height: 20px; accent-color: var(--primary); }
fieldset.field .hint { margin-top: 0; }

/* ---------- Payments ---------- */
.card-on-file { font-size: 1.15rem; font-weight: 650; margin-bottom: 1rem; }
.pay-status { display: inline-block; font-weight: 650; padding: .1rem .6rem; border-radius: 999px; white-space: nowrap; }
.pay-status.check-yes     { background: var(--success-bg); color: var(--success); }
.pay-status.check-no      { background: var(--danger-bg);  color: var(--danger); }
.pay-status.check-pending { background: var(--warn-bg);    color: var(--warn); }
.pager { margin-top: 1rem; }
.inline-links { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: .5rem 0 0; font-weight: 600; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
code { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: .92em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .35rem; }
.choose-customer { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1.25rem; }
.choose-customer h3 { font-size: 1.1rem; }
/* Keep the admin menu on one line on laptop screens: the name is also on the profile page */
@media (min-width: 1101px) and (max-width: 1500px) {
    .whoami { display: none; }
}
.badge-super { background: #6b1fb1; color: #fff; border-color: transparent; }
.check-not_needed .check-icon  { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.check-not_needed .check-value { color: var(--muted); font-weight: 600; }
.checklist li { grid-template-columns: 2rem minmax(0, 1fr) auto; }
.check-label .cell-note { white-space: normal; }

/* ---------- Shifts ---------- */
.shift-stats { margin-bottom: 1.25rem; }
.shift-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.shift-table th.num { text-align: right; }
.shift-table .my-row > * { background: var(--info-bg); }
.shift-table tfoot th, .shift-table tfoot td { border-top: 2px solid var(--border); background: var(--surface-2); font-weight: 650; }
.year-picker { display: flex; align-items: center; gap: .6rem; margin: 0; }
.year-picker label { margin: 0; }
.year-picker select { width: auto; }
.review-facts { margin: 0; padding-left: 1.25rem; display: grid; gap: .4rem; }
.warn-text { color: var(--warn); font-weight: 600; }
.cancel-form { margin-bottom: 1.25rem; }
.admin-tools { margin-bottom: 1.25rem; }

.months-pick { margin-bottom: 1.5rem; }
.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.month-pick { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.month-pick input { width: 20px; height: 20px; margin-top: .15rem; accent-color: var(--primary); flex: none; }
.month-pick.unfinished { border-style: dashed; }
.month-pick .cell-note { white-space: normal; }
.month-pick > span { min-width: 0; }

/* ---------- Schedule calendar ---------- */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; }
.cal-nav { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.cal-title { margin: 0 .5rem; font-size: 1.35rem; min-width: 10ch; text-align: center; }
.cal-options { display: flex; gap: .75rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg a { padding: .45rem .9rem; text-decoration: none; color: var(--text); font-weight: 600; }
.seg a + a { border-left: 2px solid var(--border); }
.seg a[aria-current] { background: var(--primary); color: var(--primary-text); }
.cal-legend { margin: 0 0 .75rem; }
.legend-mine { background: var(--info-bg); border-left: 4px solid var(--primary); padding: 0 .4rem; font-weight: 650; color: var(--text); }
.legend-open { border: 2px dashed var(--warn); padding: 0 .35rem; border-radius: 6px; font-weight: 650; color: var(--warn); }

.cal-card { padding: .5rem; overflow-x: auto; }
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 760px; }
.cal-grid th { padding: .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cal-grid td { vertical-align: top; border: 1px solid var(--border); height: 7.5rem; padding: .3rem .35rem .5rem; }
.cal-grid td.other-month { background: var(--surface-2); }
.cal-grid td.today { outline: 3px solid var(--primary); outline-offset: -3px; }
.cal-day { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: .2rem; }
.cal-add { text-decoration: none; font-weight: 800; padding: 0 .4rem; border-radius: 6px; }
.cal-add:hover { background: var(--surface-2); }
.cal-shifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cal-shifts li { font-size: .82rem; line-height: 1.3; padding: .12rem .3rem; border-radius: 5px; overflow-wrap: anywhere; }
.cal-shifts li a { color: inherit; text-decoration: none; display: block; }
.cal-shifts li a:hover { text-decoration: underline; }
.cal-shifts .t { font-variant-numeric: tabular-nums; color: var(--muted); }
.cal-shifts li.mine { background: var(--info-bg); border-left: 4px solid var(--primary); font-weight: 700; }
.cal-shifts li.mine .t { color: inherit; }
.cal-shifts li.open { border: 2px dashed var(--warn); color: var(--warn); font-weight: 700; }

.cal-list-day { padding: .25rem 0 1rem; border-bottom: 1px solid var(--border); }
.cal-list-day:last-child { border-bottom: 0; }
.cal-list-day h3 { font-size: 1.05rem; margin: .5rem 0; scroll-margin-top: 6rem; }   /* clear the sticky top bar */
.cal-list-day ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.cal-list-day li { display: grid; grid-template-columns: 7.5rem 1fr auto auto; gap: .75rem; align-items: center; padding: .4rem .6rem; border-radius: 8px; }
.cal-list-day li .time { font-variant-numeric: tabular-nums; font-weight: 650; }
.cal-list-day li.mine { background: var(--info-bg); border-left: 4px solid var(--primary); }
.cal-list-day li.open { border: 2px dashed var(--warn); }
@media (max-width: 640px) { .cal-list-day li { grid-template-columns: 1fr; gap: .1rem; } }

/* On small screens the calendar grid becomes the list */
.cal-list-narrow { display: none; }
@media (max-width: 820px) {
    .cal-grid-wrap { display: none; }
    .cal-list-narrow { display: block; }
}
.badge-sched { background: #0d6b5c; color: #fff; border-color: transparent; }

/* ---------- Trades ---------- */
.nav-count { display: inline-block; min-width: 1.4rem; padding: 0 .4rem; margin-left: .2rem; border-radius: 999px; background: var(--brand); color: #fff; font-size: .8rem; font-weight: 800; text-align: center; line-height: 1.4rem; }
.trade-list { list-style: none; margin: 0; padding: 0; }
.trade-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.trade-list li:last-child { border-bottom: 0; }
.trade-body p { margin: 0 0 .25rem; }
.trade-title { font-size: 1.05rem; }
.lead-shift { font-size: 1.2rem; font-weight: 650; margin: 0; }
.pick-list { display: grid; gap: .45rem; max-height: 22rem; overflow-y: auto; padding: .25rem; border: 1px solid var(--border); border-radius: 10px; }
.pick-list .radio { padding: .3rem .4rem; }
.cal-shifts li.offered { box-shadow: inset 0 0 0 2px var(--warn); }
.cal-list-day li { grid-template-columns: 7.5rem 1fr auto auto; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }

/* ---------- Schedule: month/year jump, your shifts, long names ---------- */
.cal-jump { display: flex; gap: .4rem; align-items: center; }
.cal-jump select { width: auto; font-weight: 700; font-size: 1.05rem; padding: .35rem 2rem .35rem .6rem; }
.sched-summary { margin: .25rem 0 0; }
.sched-summary strong { font-size: 1.05rem; }

/* Your shifts: solid, saturated, impossible to miss */
:root { --mine-bg: #0b6bcb; --mine-text: #ffffff; --mine-edge: #ffb703; }
@media (prefers-color-scheme: dark) { :root { --mine-bg: #3d9df5; --mine-text: #04101e; --mine-edge: #ffd166; } }
.cal-shifts li.mine, .cal-list-day li.mine {
    background: var(--mine-bg); color: var(--mine-text); border-left: 5px solid var(--mine-edge);
    font-weight: 750; box-shadow: 0 1px 4px rgba(11, 107, 203, .35);
}
.cal-shifts li.mine .t, .cal-list-day li.mine .type, .cal-list-day li.mine .muted { color: inherit; opacity: .92; }
.cal-list-day li.mine .btn-ghost { color: var(--mine-text); border-color: currentColor; }
.cal-list-day li.mine .badge { background: var(--mine-edge); color: #1b1300; border-color: transparent; }
.legend-mine { background: var(--mine-bg); color: var(--mine-text); border-left: 4px solid var(--mine-edge); border-radius: 4px; padding: 0 .4rem; }

/* Names stay on one line; long ones get smaller type */
.cal-shifts li { overflow-wrap: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-shifts li.name-long { font-size: .74rem; letter-spacing: -.01em; }
.cal-shifts li.name-xl { font-size: .64rem; letter-spacing: -.03em; }
.cal-shifts li.name-long .t, .cal-shifts li.name-xl .t { font-size: .95em; }

/* ---------- Badges ---------- */
.badge-learner { background: #8a3ffc; color: #fff; border-color: transparent; }
.badge-edu { background: #a0420d; color: #fff; border-color: transparent; }
.badge-off { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-mine { background: var(--mine-bg); color: var(--mine-text); border-color: transparent; }

/* ---------- Shift page, accounts ---------- */
.mt { margin-top: 1.25rem; }
.h4 { font-size: 1.05rem; margin: 0 0 .25rem; }
.stack > * + * { margin-top: .5rem; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form select { width: auto; flex: 1 1 14rem; }
.copy-wrap { display: flex; gap: .5rem; }
.copy-wrap input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1rem 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.icon { width: 1.25em; height: 1.25em; vertical-align: -.25em; margin-right: .35rem; }
.passkey-error { margin-top: .75rem; }

/* Outstanding items on Edit user */
.field.is-outstanding, .check-row.is-outstanding {
    background: #fff4b8; border-left: 5px solid #e0a800; border-radius: 8px; padding: .5rem .75rem;
}
@media (prefers-color-scheme: dark) {
    .field.is-outstanding, .check-row.is-outstanding { background: #3b3200; border-left-color: #ffd60a; }
}
.outstanding-tag { display: inline-block; font-size: .78rem; font-weight: 700; color: #6b4e00; margin-left: .4rem; }
@media (prefers-color-scheme: dark) { .outstanding-tag { color: #ffe066; } }

/* Unit clerk view: plain, read-only, big */
.clerk-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; }
.clerk-bar h1 { margin: 0; }
.row-off th, .row-off td { opacity: .62; }
.alert-card { border-left: 5px solid var(--warn); }
#calendar .inline-links { gap: .5rem; margin-bottom: 1rem; }
#calendar details { margin-bottom: 1rem; }
#calendar .copy-wrap { max-width: 46rem; }
.passkey-signin + p { margin-top: 1.25rem; }

/* Manage users: name, email and phone in one column so the table fits without scrolling */
.member-cell { min-width: 16rem; }
.member-contact { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; margin-top: .15rem; overflow-wrap: anywhere; }
.member-contact .sep { margin: 0 .4rem; }
.user-actions { white-space: nowrap; text-align: right; }
.user-actions .inline { display: inline-block; }
.user-actions .btn-sm { padding-inline: .6rem; }

/* Date pickers: the browser's calendar icon follows light/dark mode and is easy to see and hit */
:root { color-scheme: light dark; }
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer; width: 1.4rem; height: 1.4rem; padding: .2rem; border-radius: 6px; opacity: 1;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { background-color: var(--info-bg); }

/* "Add a card" reminder */
.alert-warn { background: var(--warn-bg); border-color: var(--warn); }
.card-reminder { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.card-reminder p { margin: 0; }

/* Redistribution */
.stat-row { margin-bottom: 1rem; }
.stat-row .stat-num { font-size: 1.6rem; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot th, .table tfoot td { font-weight: 750; border-top: 2px solid var(--border); }
.row-me th, .row-me td { background: var(--info-bg); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 1rem; }
.history-add { margin-top: 1rem; }
.subfield { margin-left: 2rem; margin-top: .5rem; }
.subfield input[type="number"] { max-width: 14rem; }

/* Tabs (Manage Users: Users / Learners) */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin: 0 0 1.25rem; }
.tabs a { padding: .6rem 1.2rem; text-decoration: none; color: var(--muted); font-weight: 700; font-size: 1.05rem;
          border: 2px solid transparent; border-bottom: none; border-radius: 10px 10px 0 0; margin-bottom: -2px; }
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--primary); background: var(--surface); border-color: var(--border); border-bottom: 2px solid var(--surface); }
.cats-card > summary { cursor: pointer; font-weight: 700; display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; }
.cats-card > summary .muted { font-weight: 400; }
.cats-card[open] > summary { margin-bottom: .75rem; }

/* Calendar key: a small pop-up instead of a paragraph above the calendar */
.cal-key { position: relative; }
.cal-key > summary { list-style: none; cursor: pointer; }
.cal-key > summary::-webkit-details-marker { display: none; }
.cal-key-panel {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20; width: min(24rem, 85vw);
    background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: .75rem 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.cal-key-panel ul { margin: 0; padding-left: 1.1rem; }
.cal-key-panel li + li { margin-top: .4rem; }
.key-icon { font-size: 1.2em; }

/* Learner hat: bigger so it's easy to spot */
.lrn { font-size: 1.3em; line-height: 1; vertical-align: -0.1em; }

/* Schedule > Compare: each physician you compare with gets a colour (you stay blue) */
:root {
    --cmp1: #0f8b8d; --cmp2: #8e44ad; --cmp3: #2b9348; --cmp4: #d35400; --cmp5: #c2185b; --cmp6: #6d4c41;
    --cmp-tint: 16%;
}
@media (prefers-color-scheme: dark) {
    :root { --cmp1: #3cc7c9; --cmp2: #c08ae0; --cmp3: #6fd08c; --cmp4: #ff9f5a; --cmp5: #ff6fa5; --cmp6: #c9a497; --cmp-tint: 24%; }
}
.cmp1 { --cmp: var(--cmp1); } .cmp2 { --cmp: var(--cmp2); } .cmp3 { --cmp: var(--cmp3); }
.cmp4 { --cmp: var(--cmp4); } .cmp5 { --cmp: var(--cmp5); } .cmp6 { --cmp: var(--cmp6); }
.cal-shifts li.cmp, .cal-list-day li.cmp, .compare-chip.cmp {
    background: var(--info-bg);   /* older browsers */
    background: color-mix(in srgb, var(--cmp) var(--cmp-tint), transparent);
    border-left: 5px solid var(--cmp); font-weight: 700;
}
.cal-shifts li.cmp .t { color: inherit; }
.compare-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .75rem; }
.compare-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 6px; font-weight: 700; }
.compare-chip.mine { background: var(--mine-bg); color: var(--mine-text); border-left: 5px solid var(--mine-edge); }
.chip-remove { color: inherit; text-decoration: none; font-size: 1.15em; line-height: 1; padding: 0 .15rem; }
.chip-remove:hover, .chip-remove:focus-visible { text-decoration: underline; }
.cal-compare .cal-key-panel { width: min(22rem, 90vw); }
.cal-compare input[type=search] { width: 100%; margin: .25rem 0 .5rem; }
.compare-list { border: 0; margin: 0 0 .6rem; padding: 0; max-height: 16rem; overflow-y: auto; display: grid; gap: .15rem; }
.compare-list label { display: flex; gap: .5rem; align-items: center; padding: .3rem .25rem; border-radius: 6px; cursor: pointer; font-weight: 500; }
.compare-list label:hover { background: var(--info-bg); }
.compare-list input { width: 1.15rem; height: 1.15rem; }

/* Schedule: "Learners: shown" lists each shift's learners in small text under the physician */
.toggle-btn { border: 2px solid var(--border); background: transparent; color: var(--text); font-weight: 600; }
.toggle-btn.is-on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.cal-shifts .lrn-lines { display: block; margin-top: .05rem; }
.cal-shifts .lrn-lines > span {
    display: block; font-size: .7rem; font-weight: 500; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .95;
}
.cal-shifts .lrn-lines > span::before { content: "🎓 "; font-size: .9em; }

.cal-list-day .lrn-list { display: block; margin-top: .15rem; }
.cal-list-day .lrn-list > span { display: block; font-size: .85rem; font-weight: 500; line-height: 1.35; }

/* Wide monitors: bigger calendar cells, so names keep a readable size instead of shrinking */
@media (min-width: 1500px) {
    .cal-grid td { height: 8.5rem; }
    .cal-shifts li { font-size: .95rem; }
    .cal-shifts li.name-long { font-size: .9rem; letter-spacing: 0; }
    .cal-shifts li.name-xl { font-size: .84rem; letter-spacing: -.01em; }
    .cal-shifts .lrn-lines > span { font-size: .8rem; }
}
@media (min-width: 1800px) {
    .cal-shifts li, .cal-shifts li.name-long { font-size: 1rem; }
    .cal-shifts li.name-xl { font-size: .92rem; letter-spacing: 0; }
    .cal-shifts .lrn-lines > span { font-size: .85rem; }
}
