/* Pogon web design system (docs/DESIGN.md). Tokens only; no hardcoded colors outside :root blocks. */

@font-face { font-family: "Manrope"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/Manrope-Medium.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/Manrope-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/Manrope-Bold.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 800; font-style: normal; font-display: swap; src: url("/fonts/Manrope-ExtraBold.woff2") format("woff2"); }

:root {
    color-scheme: light;
    --bg: #F6F6F8;
    --surface: #FFFFFF;
    --surface-2: #F0F0F4;
    --border: #E8E8EE;
    --text: #15151A;
    --text-2: #44444E;
    --text-3: #7A7A86;
    --accent: #FF7A1A;
    --on-accent: #0B0B0F;
    --accent-text: #C2410C;
    --warn: #B85C00;
    --danger: #C2410C;
    --ok: #2F7D32;
    --input-bg: var(--surface);
    --input-border: #D6D6DE;
    --r-input: 10px;
    --r-card: 14px;
    --r-pill: 999px;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
    --sidebar-w: 232px;
    --strip-h: 28px;
    --rs-on: #0B0B0F;
    --rs-sa: #F0626A;
    --rs-clientadmin: #B39BF2;
    --rs-admin: #F58CB5;
    --rs-trainer: #F2CC3D;
    --rs-worker: #BDC1CC;
    --rs-member: #62CC84;
    --rs-fitness: #5BC4DE;
    --rs-none: #D9DBE3;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0B0B0F;
    --surface: #14141A;
    --surface-2: #1C1C24;
    --border: rgba(255, 255, 255, .08);
    --text: #F2F2F5;
    --text-2: #C9C9D2;
    --text-3: #8A8A96;
    --accent-text: #FFA052;
    --warn: #FFB45C;
    --danger: #FF6B6B;
    --ok: #7ED957;
    --input-bg: var(--surface-2);
    --input-border: transparent;
    --rs-sa: #E5484D;
    --rs-clientadmin: #9A7FE8;
    --rs-admin: #E56FA3;
    --rs-trainer: #E5B922;
    --rs-worker: #9BA0AD;
    --rs-member: #46B96C;
    --rs-fitness: #37AFCB;
    --rs-none: #26262F;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0B0B0F;
        --surface: #14141A;
        --surface-2: #1C1C24;
        --border: rgba(255, 255, 255, .08);
        --text: #F2F2F5;
        --text-2: #C9C9D2;
        --text-3: #8A8A96;
        --accent-text: #FFA052;
        --warn: #FFB45C;
        --danger: #FF6B6B;
        --ok: #7ED957;
        --input-bg: var(--surface-2);
        --input-border: transparent;
        --rs-sa: #E5484D;
        --rs-clientadmin: #9A7FE8;
        --rs-admin: #E56FA3;
        --rs-trainer: #E5B922;
        --rs-worker: #9BA0AD;
        --rs-member: #46B96C;
        --rs-fitness: #37AFCB;
        --rs-none: #26262F;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 500 14px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { flex: none; width: 20px; height: 20px; }

h1, h2, h3 { margin: 0; letter-spacing: -.02em; color: var(--text); }
h1, h2 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
h3 { font-size: 18px; font-weight: 700; margin: var(--s8) 0 var(--s3); }
p { margin: 0 0 var(--s3); color: var(--text-2); }
small { font-size: 13px; color: var(--text-3); }
em { font-style: normal; font-size: 13px; color: var(--text-3); }
strong { font-weight: 700; color: var(--text); }
ul { margin: 0 0 var(--s3); padding-left: var(--s5); }

/* ---------- Shell ---------- */
/* ---------- Role strip (docs/DESIGN.md "Role strip"): the one deliberate exception to the single-accent rule ---------- */
body { padding-top: var(--strip-h); }
.rolestrip {
    position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: var(--strip-h); display: flex; align-items: center; padding: 0 var(--s4);
    background: var(--rs-none); color: var(--rs-on);
    font: 700 12px/1 "Manrope", system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase;
}
.rolestrip ol { display: flex; align-items: center; flex-wrap: nowrap; min-width: 0; width: 100%; margin: 0; padding: 0; list-style: none; }
.rolestrip li { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rolestrip li + li::before {
    content: ""; display: inline-block; width: 12px; height: 12px; margin: 0 6px; vertical-align: -2px; background: currentColor; opacity: .6;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.rolestrip li.rs-app, .rolestrip li.rs-role, .rolestrip li.rs-last { flex: 0 0 auto; }
.rolestrip li.rs-last { flex: 0 0 auto; max-width: 60%; }
.rolestrip li.rs-tenant { flex: 0 10 auto; max-width: 28ch; min-width: 4ch; }
.rolestrip li.rs-crumb:not(.rs-last) { flex: 0 5 auto; min-width: 3ch; }
@media (max-width: 520px) { .rolestrip li.rs-app { display: none; } .rolestrip li.rs-app + li::before { display: none; } .rolestrip li:nth-child(2)::before { display: none; } }
.rolestrip a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.rolestrip a:hover { text-decoration-thickness: 2px; }
.rolestrip.rs-none { color: var(--text-2); }
.rolestrip.rs-sa { background: var(--rs-sa); }
.rolestrip.rs-clientadmin { background: var(--rs-clientadmin); }
.rolestrip.rs-admin { background: var(--rs-admin); }
.rolestrip.rs-trainer { background: var(--rs-trainer); }
.rolestrip.rs-worker { background: var(--rs-worker); }
.rolestrip.rs-member { background: var(--rs-member); }
.rolestrip.rs-fitness { background: var(--rs-fitness); }
.rolestrip:is(.rs-sa, .rs-clientadmin, .rs-admin, .rs-trainer, .rs-worker, .rs-member, .rs-fitness) { color: var(--rs-on); }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--strip-h)); }
.topbar, .nav-toggle { display: none; }
.sidebar {
    position: sticky; top: var(--strip-h); height: calc(100vh - var(--strip-h)); overflow-y: auto;
    display: flex; flex-direction: column; gap: var(--s4);
    padding: var(--s5) var(--s3); background: var(--surface); border-right: 1px solid var(--border);
}
.side-head { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--s2); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); font-size: 20px; font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.brand-dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--accent); }
.side-role { font-size: 13px; font-weight: 600; color: var(--text-2); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a, .nav-btn {
    display: flex; align-items: center; gap: var(--s3); width: 100%; height: 40px; padding: 0 var(--s3);
    border: 0; border-radius: var(--r-input); background: none; color: var(--text-2);
    font: 600 14px/1 "Manrope", system-ui, sans-serif; text-decoration: none; cursor: pointer; text-align: left;
}
.nav a:hover, .nav-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.page { background: var(--surface-2); color: var(--text); }
.nav a.page .ic { color: var(--accent-text); }
.side-foot { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); }
.side-foot form { margin: 0; max-width: none; }
.seg { display: inline-flex; gap: 2px; padding: 3px; margin-right: var(--s2); border-radius: var(--r-input); background: var(--surface-2); }
.side-foot .seg { margin: 0; display: flex; }
.seg a {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; height: 28px; min-width: 32px; padding: 0 var(--s2);
    border-radius: 8px; color: var(--text-2); font-size: 12px; font-weight: 700; text-decoration: none;
}
.seg a .ic { width: 16px; height: 16px; }
.seg a[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.seg a:hover { text-decoration: none; color: var(--text); }
.main { padding: 28px 32px 48px; min-width: 0; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s6); }
.page-head .actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: var(--s2); margin-bottom: var(--s4); color: var(--text-2); font-size: 13px; font-weight: 600; }
.back .ic { width: 16px; height: 16px; }
main > h1, main > h2, .main > h1, .main > h2 { margin-bottom: var(--s4); }
.page-head h1 { margin: 0; }

/* ---------- Auth ---------- */
.auth { min-height: calc(100vh - var(--strip-h)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s5); padding: var(--s6) var(--s4); }
.auth-card { width: 100%; max-width: 400px; padding: var(--s8); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); display: flex; flex-direction: column; gap: var(--s2); }
.auth-card .brand { margin-bottom: var(--s5); }
.auth-card h1, .auth-card h2 { font-size: 24px; margin-bottom: var(--s3); }
.auth-card form { margin: 0; }
.auth-link { margin: var(--s3) 0 0; font-size: 13px; }
p.hint { margin: var(--s2) 0 0; font-size: 13px; color: var(--text-3); }
.nav-btn.page { background: var(--surface-2); color: var(--text); }
.auth-foot { display: flex; }

/* ---------- Cards, stats ---------- */
.card, form.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s6); }
form.card { max-width: 720px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s5); }
.stat .label { display: block; }
.stat .num { display: block; margin-top: var(--s2); font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; color: var(--text); }
.label, th, legend { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }

/* ---------- Tables (rows with 1px separators) ---------- */
table {
    width: 100%; border-collapse: separate; border-spacing: 0; margin: 0 0 var(--s4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden;
}
th, td { padding: 12px var(--s4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { background: var(--surface); padding-top: 14px; padding-bottom: 10px; }
tr:last-child > td, tbody:last-child > tr:last-child > td { border-bottom: 0; }
td { color: var(--text); font-size: 14px; }
tbody tr:hover td { background: var(--surface-2); }
td:last-child:not(:first-child) { text-align: right; white-space: nowrap; }
td form { display: inline; margin: 0; padding: 0; border: 0; background: none; max-width: none; }
td .btn, td button { height: 32px; padding: 0 var(--s3); font-size: 13px; }
td + td { color: var(--text-2); }
td:first-child { color: var(--text); font-weight: 600; }
.row-dim td { opacity: .6; }
.who { display: inline-flex; align-items: center; gap: var(--s3); }
.avatar {
    flex: none; width: 32px; height: 32px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 12px; font-weight: 800; letter-spacing: 0;
}
.empty { padding: var(--s6); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-card); color: var(--text-2); }

/* ---------- Chips (multi-select) ---------- */
.chips, .presets { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s3); }
.chips > label.chip {
    display: inline-flex; align-items: center; margin: 0; height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill);
    font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); cursor: pointer;
}
.chips > label.chip:has(input:checked) { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.chips > label.chip input { accent-color: var(--on-accent); margin-right: var(--s2); }
.chips > label.chip:has(input:focus-visible) { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge.accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--danger); }
.badge.ok { color: var(--ok); }

.phone-mask { color: var(--text-3); letter-spacing: .04em; white-space: nowrap; }
.phone-line { display: flex; align-items: center; gap: var(--s3); min-height: 32px; margin-bottom: var(--s2); }
.phone-full { font-weight: 600; color: var(--text); }

/* ---------- Forms ---------- */
form { margin: 0 0 var(--s4); }
label { display: block; margin: var(--s4) 0 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
form > label:first-child, .row > div > label:first-child { margin-top: 0; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number],
input[type=date], input[type=time], input:not([type]), select, textarea {
    display: block; width: 100%; height: 40px; padding: 0 var(--s3); border-radius: var(--r-input);
    background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border);
    font: 500 14px/1 "Manrope", system-ui, sans-serif;
}
textarea { height: auto; padding: 10px var(--s3); line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
input[type=file] { color: var(--text-2); font: 500 13px "Manrope", system-ui, sans-serif; margin-bottom: var(--s3); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0 var(--s2) 0 0; accent-color: var(--accent); vertical-align: -3px; }
label:has(> input[type=checkbox]), label:has(> input[type=radio]) { display: flex; align-items: center; margin: var(--s3) 0; font-weight: 500; color: var(--text); }
fieldset { border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s3) var(--s4); margin: 0 0 var(--s4); }
legend { padding: 0 var(--s2); }
fieldset label { margin: var(--s2) 0; }
.row { display: flex; gap: var(--s3); align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--s3); }
.row > * { flex: 1 1 140px; min-width: 0; }
.row > div:has(> button), .row > button { flex: 0 0 auto; }
form.row { margin-bottom: var(--s4); }
#filters { margin-bottom: var(--s4); }
#filters > input { flex: 2 1 220px; }
form:not(.card) select, form:not(.card) input { max-width: 100%; }
.main > form:not(.card):not(.row) { max-width: 720px; }
td table { margin: 0; }

/* ---------- Buttons ---------- */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 40px; padding: 0 var(--s4);
    border-radius: var(--r-input); border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: 700 14px/1 "Manrope", system-ui, sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
button.primary:hover, .btn.primary:hover { background: var(--accent); filter: brightness(1.06); }
button.danger, .btn.danger { background: none; border-color: transparent; color: var(--danger); }
button.danger:hover { background: var(--surface-2); }
.btn.sm, button.sm { height: 32px; padding: 0 var(--s3); font-size: 13px; }
.nav-btn { border: 0 !important; justify-content: flex-start; }
form > button:not(.nav-btn) { margin-top: var(--s4); }
.row button { margin-top: 0 !important; }
.menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--r-input); color: var(--text); cursor: pointer; }
.menu-btn:hover { background: var(--surface-2); }

/* ---------- Toasts (docs/DESIGN.md "Notifications / toasts") ---------- */
#app { display: contents; }
.toasts { position: fixed; right: var(--s6); bottom: var(--s6); z-index: 100; display: flex; flex-direction: column; gap: var(--s2); width: min(380px, calc(100vw - 2 * var(--s4))); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-card); color: var(--text); font-weight: 600; font-size: 14px; line-height: 20px; animation: toast-in .18s ease-out; transition: opacity .2s, transform .2s; }
.toast.leaving { opacity: 0; transform: translateY(6px); }
.toast-ic { flex: 0 0 auto; margin-top: 0; }
.toast-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--ok); } .toast.ok .toast-ic { color: var(--ok); }
.toast.info { border-left-color: var(--accent); } .toast.info .toast-ic { color: var(--accent-text); }
.toast.warn { border-left-color: var(--warn); } .toast.warn .toast-ic { color: var(--warn); }
.toast.err { border-left-color: var(--danger); } .toast.err .toast-ic { color: var(--danger); }
.toast .toast-close { flex: 0 0 auto; width: 28px; height: 28px; padding: 0; margin: -2px 0 0; border-color: transparent; background: none; color: var(--text-3); }
.toast .toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-close .ic { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) { .toasts { right: 0; left: 0; bottom: var(--s4); margin: 0 auto; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; transition: none; } }

/* ---------- Inline field messages ---------- */
.field-err { margin: var(--s2) 0 0; color: var(--danger); font-size: 13px; font-weight: 600; }
.field-ok { margin: var(--s2) 0 0; color: var(--ok); font-size: 13px; font-weight: 600; }
.input-validation-error, input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--danger) !important; }
details.newperson { margin-top: var(--s3); border: 1px solid var(--border); border-radius: var(--r-input); background: var(--surface); }
details.newperson > summary { cursor: pointer; padding: 10px var(--s4); font-weight: 700; list-style: none; display: flex; align-items: center; gap: var(--s2); }
details.newperson > summary::-webkit-details-marker { display: none; }
details.newperson[open] > summary { border-bottom: 1px solid var(--border); }
details.newperson > .np-body { padding: var(--s4); }
section.region { margin: 0; }

/* ---------- Messages ---------- */
p.err, p.ok { padding: 10px var(--s4); border-radius: var(--r-input); background: var(--surface); border: 1px solid var(--border); font-weight: 600; }
p.err { color: var(--danger); }
p.ok { color: var(--ok); }
span.ok { color: var(--ok); font-weight: 600; }
.pick { list-style: none; padding: 0; margin: 0 0 var(--s3); }
#results ul { list-style: none; padding: 0; margin: var(--s2) 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-input); }
#results li { padding: 10px var(--s3); border-bottom: 1px solid var(--border); }
#results li:last-child { border-bottom: 0; }
#results > p { margin-top: var(--s2); color: var(--text-3); }
.day { display: flex; align-items: baseline; gap: var(--s3); }
.day small { font-weight: 600; }
.weeknav { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.weeknav .range { font-weight: 700; color: var(--text); }

/* Row actions (members list): 32 px buttons at the right; icon-only ones stay square. */
.btn.icon { width: 32px; padding: 0; }
.btn.icon .ic { width: 16px; height: 16px; }
td.row-actions > * { margin-left: var(--s2); vertical-align: middle; }
td.row-actions > :first-child { margin-left: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .narrow-hide { display: none; } }
/* Phones: each member becomes a small card-like block (name, membership, then the actions on their own line) instead of a clipped table. */
@media (max-width: 600px) {
    table.members, table.members tbody { display: block; overflow: visible; }
    table.members tr.head { display: none; }
    table.members tbody tr { display: block; padding: 12px var(--s4); border-bottom: 1px solid var(--border); }
    table.members tbody tr:last-child { border-bottom: 0; }
    table.members td { display: block; padding: 2px 0; border: 0; text-align: left; white-space: normal; }
    table.members td.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s2); }
    table.members td.row-actions > * { margin-left: 0; }
    table.members td.narrow-hide { display: none; }
    table.members tr.load-more td { padding: 0; }
}
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .topbar {
        display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 var(--s4);
        position: sticky; top: var(--strip-h); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .sidebar { display: none; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); grid-row: 2; }
    .nav-toggle:checked ~ .shell .sidebar { display: flex; }
    .nav-toggle:checked ~ .shell .main { display: none; }
    .nav-toggle:focus-visible ~ .shell .menu-btn { outline: 2px solid var(--accent); }
    .main { padding: var(--s5) var(--s4) var(--s8); grid-row: 2; }
    .sidebar { grid-row: 2; }
    h1, h2 { font-size: 26px; }
    table { display: block; overflow-x: auto; }
}
@media (max-width: 520px) { .stats { grid-template-columns: 1fr; } }

/* ---------- Additions ---------- */
form.inline { display: inline-block; margin: 0 var(--s2) var(--s3) 0; padding: 0; border: 0; background: none; }
form.inline > button { margin-top: 0 !important; }
.page-head.sub { margin: var(--s8) 0 var(--s3); }
.page-head.sub h3 { margin: 0; }
.logo { max-height: 80px; border-radius: var(--r-input); border: 1px solid var(--border); background: var(--surface); }
.presets button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.chain-note { display: flex; gap: var(--s2); align-items: flex-start; margin: var(--s2) 0 var(--s3); color: var(--accent-text); font-weight: 600; }
.preview { padding: var(--s3) var(--s4); background: var(--surface-2); border-radius: var(--r-input); }
.main > form.row.card { max-width: none; }
.actions form { margin: 0; }
.actions form > button { margin-top: 0 !important; }
.auth-card form > button { width: 100%; }
form > .row:not(:first-child), form > select + .row { margin-top: var(--s4); }
form.row > select:only-of-type, form.row > select:first-child:nth-last-child(2) { flex: 0 1 280px; }

/* ---------- Load more (history lists) ---------- */
.load-more { text-align: center; padding: var(--s3) 0; }
tr.load-more td { text-align: center !important; color: var(--text-3); }
tbody tr.load-more:hover td { background: none; }
.load-more .caption { color: var(--text-3); font-size: 13px; font-weight: 600; }
button.htmx-request { opacity: .6; cursor: progress; }
.voided td { color: var(--text-3); text-decoration: line-through; }
.voided td:last-child { text-decoration: none; }

/* Candidate picker + "add new person" hint (groups) */
#cand-area { display: flex; flex-direction: column; gap: var(--s2); flex: 1 1 220px; min-width: 0; }
#cand-area .np-hint { margin: 0; color: var(--text-3); font-size: 13px; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }

/* Reports */
[hidden] { display: none !important; }
.report-form { max-width: 880px; margin-bottom: var(--s6); }
.report-form select { max-width: 100%; }
.table-wrap { overflow-x: auto; margin-top: var(--s3); }
#preview { margin-bottom: var(--s6); }

/* Reports 2: catalogue cards, tiles, charts (plain SVG; fills come from tokens, never inline styles) */
.rep-group { margin: var(--s6) 0 var(--s3); font-size: 18px; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.rep-card { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; color: var(--text); font-weight: 500; }
.rep-card:hover { border-color: var(--accent); }
.rep-card strong { font-size: 15px; font-weight: 700; }
.rep-tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat .delta { display: block; margin-top: var(--s1); font-size: 13px; font-weight: 700; color: var(--text-2); }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--warn); }
.stat .hint { display: block; margin: var(--s1) 0 0; font-size: 12px; }
.rep-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
figure.chart { margin: 0; padding: var(--s5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); min-width: 0; }
figure.chart figcaption { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--s3); }
.chart svg.bars, .chart svg.heat { width: 100%; height: auto; display: block; }
.chart .ax { font-size: 10px; fill: var(--text-3); font-weight: 600; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .s0 { fill: var(--accent); } .chart .s1 { fill: var(--ok); } .chart .s2 { fill: var(--danger); } .chart .s3 { fill: var(--text-3); }
.chart .cell { fill: var(--accent); }
.chart .track { fill: var(--surface-2); }
.hbars { display: flex; flex-direction: column; gap: var(--s2); }
.hb-row { display: grid; grid-template-columns: minmax(70px, 28%) 1fr minmax(60px, auto); gap: var(--s3); align-items: center; font-size: 13px; }
.hb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-weight: 600; }
.hb-val { text-align: right; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
svg.hb { width: 100%; height: 12px; border-radius: 4px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s4); margin: var(--s3) 0 0; font-size: 12px; color: var(--text-2); font-weight: 600; }
.legend svg { width: 10px; height: 10px; vertical-align: -1px; }
.chart-data { margin-top: var(--s3); font-size: 13px; }
.chart-data summary { cursor: pointer; color: var(--accent-text); font-weight: 600; }
.rep-table th, .rep-table td { white-space: nowrap; }
@media print {
    .sidebar, .topbar, .menu-btn, .nav-toggle, .rolestrip, .no-print, .load-more, #toasts, #flash, .chart-data { display: none !important; }
    html, body, .shell, .main { background: #fff !important; color: #000 !important; display: block !important; }
    .card, .stat, figure.chart { break-inside: avoid; }
    * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* Plan form: sections with a hint under every field, a unit suffix, the group note and the live summary. */
.plan-form fieldset small { display: block; margin: var(--s1) 0 var(--s3); }
.plan-form .row small { margin-bottom: 0; }
.unit-field { position: relative; }
.unit-field input { padding-right: 44px; }
.unit-field .unit { position: absolute; right: var(--s3); top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 700; color: var(--text-3); pointer-events: none; }
.plan-note { display: flex; gap: var(--s2); align-items: flex-start; margin: var(--s2) 0 0; padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 600; }
.plan-note svg { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--accent-text); }
.group-note { display: none; }
.plan-form:has(#Type option[value=Group]:checked) .group-note { display: flex; }
.plan-form:has(input[name="Form.SingleVisit"]:checked) .not-single { display: none; }
.plan-summary { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.plan-summary p { margin: var(--s1) 0 0; font-size: 15px; font-weight: 700; color: var(--text); }
