:root {
    color-scheme: light;
    --ui-canvas: #f3f6f8;
    --ui-canvas-accent: #e7f0f5;
    --ui-surface: #ffffff;
    --ui-surface-muted: #edf2f5;
    --ui-text: #10243e;
    --ui-muted: #52677e;
    --ui-primary: #123f68;
    --ui-primary-strong: #0c3255;
    --ui-accent: #1b6b73;
    --ui-accent-soft: #dceff0;
    --ui-border: #d2dde5;
    --ui-control-border: #aebfcd;
    --ui-focus: #2c7fbe;
    --ui-success: #18794e;
    --ui-success-soft: #e9f7ef;
    --ui-info: #205f98;
    --ui-info-soft: #e9f3fb;
    --ui-warning: #8a4b08;
    --ui-warning-soft: #fff8ec;
    --ui-danger: #b42318;
    --ui-danger-soft: #fff0ee;
    --ui-shadow: 0 12px 32px rgba(16, 36, 62, .08);
    --ui-shadow-soft: 0 3px 12px rgba(16, 36, 62, .06);
    --ui-radius: .9rem;
    --ui-radius-small: .58rem;
    --ui-font-body: "Segoe UI Variable Text", "Aptos", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --ui-font-display: "Segoe UI Variable Display", "Aptos Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --ui-weight-regular: 400;
    --ui-weight-medium: 500;
    --ui-weight-semibold: 600;
    --ui-weight-bold: 600;
    --ui-motion-fast: 150ms;
    --ui-motion-standard: 220ms;
    --ui-ease: cubic-bezier(.2, .8, .2, 1);
    font-family: var(--ui-font-body);
    font-size: 16px;
    background: var(--ui-canvas);
    color: var(--ui-text);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --ui-canvas: #0d1722;
    --ui-canvas-accent: #122735;
    --ui-surface: #162330;
    --ui-surface-muted: #1c2c3a;
    --ui-text: #eef5f9;
    --ui-muted: #afc0cd;
    --ui-primary: #8fc5ef;
    --ui-primary-strong: #b8dcf7;
    --ui-accent: #66c7c2;
    --ui-accent-soft: #183f43;
    --ui-border: #334858;
    --ui-control-border: #536b7d;
    --ui-focus: #74c3ff;
    --ui-success: #72d69a;
    --ui-success-soft: #163b2c;
    --ui-info: #9bcff5;
    --ui-info-soft: #17354b;
    --ui-warning: #ffd08a;
    --ui-warning-soft: #402f19;
    --ui-danger: #ff9b92;
    --ui-danger-soft: #482520;
    --ui-shadow: 0 14px 34px rgba(0, 0, 0, .28);
    --ui-shadow-soft: 0 4px 14px rgba(0, 0, 0, .22);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --ui-canvas: #0d1722;
        --ui-canvas-accent: #122735;
        --ui-surface: #162330;
        --ui-surface-muted: #1c2c3a;
        --ui-text: #eef5f9;
        --ui-muted: #afc0cd;
        --ui-primary: #8fc5ef;
        --ui-primary-strong: #b8dcf7;
        --ui-accent: #66c7c2;
        --ui-accent-soft: #183f43;
        --ui-border: #334858;
        --ui-control-border: #536b7d;
        --ui-focus: #74c3ff;
        --ui-success: #72d69a;
        --ui-success-soft: #163b2c;
        --ui-info: #9bcff5;
        --ui-info-soft: #17354b;
        --ui-warning: #ffd08a;
        --ui-warning-soft: #402f19;
        --ui-danger: #ff9b92;
        --ui-danger-soft: #482520;
        --ui-shadow: 0 14px 34px rgba(0, 0, 0, .28);
        --ui-shadow-soft: 0 4px 14px rgba(0, 0, 0, .22);
    }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 92% 0, var(--ui-canvas-accent), transparent 32rem), var(--ui-canvas); color: var(--ui-text); font-weight: var(--ui-weight-regular); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; }
a { color: var(--ui-primary); }
:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }

.app-header { background: #103f68; color: #fff; min-height: 4rem; padding: .72rem clamp(1rem, 3vw, 2.5rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: 0 3px 16px rgba(0, 0, 0, .16); }
.app-header a { color: #fff; }
.app-header-tools { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; }
.app-header-name { font-weight: var(--ui-weight-bold); white-space: nowrap; }
.nav-links { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav-links a { min-height: 2.5rem; display: inline-flex; align-items: center; padding: .45rem .62rem; border-radius: .5rem; color: #fff; font-size: .9rem; font-weight: var(--ui-weight-semibold); text-decoration: none; }
.nav-links a:hover { background: rgba(255, 255, 255, .13); }
.theme-control { display: inline-flex; align-items: center; gap: .4rem; color: #fff; font-size: .82rem; font-weight: var(--ui-weight-semibold); }
.theme-control select { width: auto; min-height: 2.35rem; margin: 0; padding: .35rem 1.9rem .35rem .55rem; border-color: rgba(255, 255, 255, .5); background: #fff; color: #10243e; }
.theme-control-floating { position: fixed; z-index: 20; top: .75rem; right: .75rem; padding: .38rem .5rem; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-small); background: var(--ui-surface); color: var(--ui-text); box-shadow: var(--ui-shadow-soft); }
.theme-control-floating select { border-color: var(--ui-control-border); background: var(--ui-surface); color: var(--ui-text); }

.page { width: min(100%, 88rem); margin: 0 auto; padding: clamp(1.2rem, 2.7vw, 2.4rem); }
.page-narrow { width: min(100%, 72rem); }
.page-heading { margin-bottom: 1.25rem; }
.page-heading h1 { margin: 0 0 .3rem; font-size: clamp(1.8rem, 3vw, 2.3rem); line-height: 1.15; letter-spacing: -.025em; }
.lede, .muted { color: var(--ui-muted); line-height: 1.5; }
.lede { margin: 0; }
.hero { padding: clamp(1.25rem, 2.5vw, 2rem); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: linear-gradient(125deg, #103f68, #17606a); color: #fff; box-shadow: var(--ui-shadow); }
.hero h1 { margin: 0 0 .35rem; font-size: clamp(1.8rem, 3vw, 2.25rem); }
.hero p { margin: 0; color: #dcebf2; }

.panel, .card, .metric, .filters, .tools, .table-wrap { border: 1px solid var(--ui-border); background: var(--ui-surface); box-shadow: var(--ui-shadow-soft); }
.panel, .card, .metric, .filters, .tools { border-radius: var(--ui-radius); }
.panel, .card { padding: 1.15rem; }
.card h2, .panel h2 { margin: 0 0 .7rem; font-size: 1.05rem; }
.card p { margin: 0 0 1.1rem; color: var(--ui-muted); line-height: 1.5; }
.card-status { border-left: .3rem solid var(--ui-success); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }

.button, button { min-height: 2.75rem; border: 1px solid transparent; border-radius: var(--ui-radius-small); padding: .55rem .9rem; background: #1769a7; color: #fff; font-weight: var(--ui-weight-semibold); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.button:hover, button:hover { background: #0f568b; }
.button-secondary { border-color: var(--ui-border); background: var(--ui-surface-muted); color: var(--ui-text); }
.button-secondary:hover { background: var(--ui-border); }
.button-light { border-color: #bed4e7; background: #fff; color: #123f68; }
.button-light:hover { background: #edf5fa; }
.tag { display: inline-block; margin: .15rem .25rem .15rem 0; padding: .28rem .58rem; border-radius: 999px; background: var(--ui-accent-soft); color: var(--ui-accent); font-size: .82rem; font-weight: 800; }

label { display: block; color: var(--ui-text); font-size: .86rem; font-weight: var(--ui-weight-semibold); }
input, select, textarea { display: block; width: 100%; min-width: 0; min-height: 2.75rem; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid var(--ui-control-border); border-radius: var(--ui-radius-small); background: var(--ui-surface); color: var(--ui-text); }
input[type="checkbox"], input[type="radio"] {
    display: inline-block;
    width: 1.125rem !important;
    min-width: 1.125rem;
    height: 1.125rem;
    min-height: 1.125rem !important;
    margin: .08rem 0 0;
    padding: 0;
    flex: 0 0 1.125rem;
    vertical-align: -.15em;
}
fieldset > label,
.permission > label,
.programs > label,
.program-row > label,
.contact-checks > label,
.staff > label,
.checks > label,
.choice,
.ack,
.schedule-head,
label.day {
    align-items: flex-start !important;
    gap: .5rem !important;
}
fieldset > label,
.permission > label,
.contact-checks > label,
.staff > label,
.checks > label,
.choice,
.ack,
.schedule-head { display: inline-flex !important; }
input:focus, select:focus, textarea:focus { border-color: var(--ui-focus); outline: 3px solid color-mix(in srgb, var(--ui-focus) 28%, transparent); }
.filters { display: grid; grid-template-columns: repeat(6, minmax(9rem, 1fr)) auto; gap: .75rem; align-items: end; margin-top: 1rem; padding: 1rem; }
.filters button { width: 100%; }
.tools { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; margin: 1rem 0; padding: .75rem 1rem; }
.tools strong { margin-right: auto; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; margin: 1rem 0; }
.metric { padding: 1rem; border-top: .28rem solid var(--ui-accent); }
.metric span { color: var(--ui-muted); font-size: .8rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.metric strong { display: block; margin-top: .22rem; color: var(--ui-primary); font-size: 1.8rem; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.bar-row { display: grid; grid-template-columns: minmax(8rem, 11rem) 1fr 3.5rem; gap: .6rem; align-items: center; margin: .7rem 0; }
.bar-row strong { text-align: right; }
.bar { height: .8rem; overflow: hidden; border-radius: 999px; background: var(--ui-surface-muted); }
.fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ui-accent), #4ba9a0); }
.hours .fill { background: linear-gradient(90deg, #2678b5, #69aee0); }

.table-wrap { overflow: auto; border-radius: var(--ui-radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .72rem .75rem; border-bottom: 1px solid var(--ui-border); text-align: left; vertical-align: top; }
th { background: var(--ui-surface-muted); color: var(--ui-text); font-size: .8rem; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--ui-surface-muted) 52%, transparent); }
.name { font-weight: 800; }
.status-pill { display: inline-block; border-radius: 999px; padding: .22rem .5rem; background: var(--ui-surface-muted); font-size: .76rem; font-weight: 800; }
.status-pill.open { background: var(--ui-success-soft); color: var(--ui-success); }
.status-pill.entered_in_error { background: var(--ui-danger-soft); color: var(--ui-danger); }
.state, .count {
    display: inline-flex !important;
    min-width: 1.45rem;
    min-height: 1.45rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ui-border);
    border-radius: 999px;
    background: var(--ui-surface-muted) !important;
    color: var(--ui-text) !important;
    font-size: .72rem;
    font-weight: var(--ui-weight-semibold) !important;
    line-height: 1;
    vertical-align: middle;
}
.state.here { border-color: color-mix(in srgb, var(--ui-success) 45%, var(--ui-border)); background: var(--ui-success-soft) !important; color: var(--ui-success) !important; }
.attendance-history > summary { justify-content: flex-start !important; }
.attendance-history > summary .state { margin-left: .4rem; }
.attendance-history > summary::after { margin-left: auto; }
.comment { max-width: 22rem; white-space: normal; }
.empty { padding: 1.5rem; color: var(--ui-muted); text-align: center; }
.notice { margin-top: 1rem; padding: .8rem 1rem; border-left: .3rem solid var(--ui-primary); border-radius: .4rem; background: var(--ui-surface-muted); }
.notice-error { border-color: var(--ui-danger); background: var(--ui-danger-soft); color: var(--ui-danger); }
.notice-success { border-color: var(--ui-success); background: var(--ui-success-soft); color: var(--ui-success); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1.5rem; }
.login-shell { width: min(100%, 29rem); }
.login-theme { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.login-theme .theme-control { color: var(--ui-text); }
.login-theme .theme-control select { border-color: var(--ui-control-border); background: var(--ui-surface); color: var(--ui-text); }
.login-card { padding: clamp(1.5rem, 5vw, 2.25rem); border: 1px solid var(--ui-border); border-radius: 1rem; background: var(--ui-surface); box-shadow: var(--ui-shadow); }
.login-card h1 { margin: .45rem 0 .35rem; font-size: 1.9rem; }
.login-card p { margin: 0 0 1.4rem; color: var(--ui-muted); line-height: 1.5; }
.login-card label { margin-top: 1rem; }
.login-card button { width: 100%; margin-top: 1.3rem; }
.eyebrow { color: var(--ui-accent); font-size: .78rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.support { margin-top: 1.2rem; color: var(--ui-muted); font-size: .88rem; }

@media (max-width: 70rem) {
    .filters { grid-template-columns: repeat(3, minmax(9rem, 1fr)); }
    .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 48rem) {
    .app-header { align-items: flex-start; flex-direction: column; }
    .app-header-tools { width: 100%; justify-content: space-between; }
    .nav-links { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; }
    .nav-links a { flex: 0 0 auto; }
    .filters, .metrics, .charts { grid-template-columns: 1fr; }
    .tools > button { width: 100%; }
    .bar-row { grid-template-columns: minmax(6rem, 9rem) 1fr 3rem; }
}

@media print {
    :root, :root[data-theme] { color-scheme: light; --ui-canvas: #fff; --ui-surface: #fff; --ui-surface-muted: #eef2f4; --ui-text: #000; --ui-muted: #333; --ui-border: #777; }
    body { min-height: 0; background: #fff; color: #000; }
    .app-header, .filters, .tools, .theme-control, .no-print { display: none !important; }
    .page { width: 100%; max-width: none; padding: 0; }
    .hero, .panel, .metric, .table-wrap { box-shadow: none; }
    .hero { border: 0; padding: 0; background: #fff; color: #000; }
    .hero p { color: #333; }
}

/* Shared compatibility layer for operational screens migrated from the
   original page-local styles. Local layout rules remain intact; these rules
   standardize typography, surfaces, controls, navigation and both themes. */
html, body, button, input, select, textarea { font-family: var(--ui-font-body) !important; }
body { font-weight: var(--ui-weight-regular) !important; }
h1, h2, h3, h4, h5, h6 { font-family: var(--ui-font-display) !important; font-weight: var(--ui-weight-bold) !important; }
strong, b, th, summary, .name, .status-pill, .tag { font-weight: var(--ui-weight-semibold) !important; }
label, button, .button, .nav-links a, .app-header-name, .theme-control { font-weight: var(--ui-weight-semibold) !important; }
body:not(.login-page) > main { width: min(100%, 88rem); margin-inline: auto; padding: clamp(1.2rem, 2.7vw, 2.4rem); }
body > header:not(.app-header), .app-ribbon, .top {
    background: #103f68 !important;
    color: #fff !important;
    min-height: 4rem;
    padding: .72rem clamp(1rem, 3vw, 2.5rem) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    box-shadow: 0 3px 16px rgba(0, 0, 0, .16);
}
body > header:not(.app-header) a:not(.secondary):not(.button-secondary),
.app-ribbon a:not(.secondary):not(.button-secondary),
.top a:not(.secondary):not(.button-secondary) { color: #fff !important; text-decoration: none; }
body > header .theme-control, .app-ribbon .theme-control, .top .theme-control { margin-left: auto; }
.top h1, .top label { color: #fff !important; }
.top .lede, .top .muted { color: #dcebf2 !important; }
.panel, section, details.expected, .analytics, .contact-card, .schedule-day, fieldset {
    border-color: var(--ui-border) !important;
    background-color: var(--ui-surface) !important;
    color: var(--ui-text) !important;
}
.panel, .analytics, details.expected { box-shadow: var(--ui-shadow-soft) !important; }
.muted, .lede, .audit, .permission small { color: var(--ui-muted) !important; }
.grid > .card p { color: inherit; }

/* Attendance cards deliberately use saturated service colours. Keep their
   operational text high-contrast even though the shared card defaults use
   muted body copy on neutral surfaces. */
.cards > .card,
.cards > .card h3,
.cards > .card p,
.cards > .card .muted,
.cards > .card summary { color: #fff; }
input, select, textarea { border-color: var(--ui-control-border) !important; background: var(--ui-surface) !important; color: var(--ui-text) !important; }
.secondary, .button-secondary { border-color: var(--ui-border) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
:is(.secondary, .button-secondary):not(:disabled):not([aria-disabled="true"]):hover {
    background: color-mix(in srgb, var(--ui-text) 10%, var(--ui-surface-muted)) !important;
}
:is(.secondary, .button-secondary):focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
button:disabled, .button[aria-disabled="true"] { border-color: var(--ui-border) !important; background: #e5edf3 !important; color: #52677e !important; opacity: 1; cursor: not-allowed; }
th { border-color: var(--ui-border) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
td { border-color: var(--ui-border) !important; }

/* One motion language for the application. Static depth remains in place;
   interactions animate compositor-friendly movement and colour rather than
   broad filter effects that can make long pages feel smeared while scrolling. */
.button, button, .nav-links a, summary, input, select, textarea {
    transition: transform var(--ui-motion-fast) var(--ui-ease),
                background-color var(--ui-motion-standard) var(--ui-ease),
                border-color var(--ui-motion-standard) var(--ui-ease),
                color var(--ui-motion-standard) var(--ui-ease),
                box-shadow var(--ui-motion-standard) var(--ui-ease) !important;
}
.button:hover:not(:disabled), button:hover:not(:disabled) { transform: translateY(-1px); filter: none !important; }
.button:active:not(:disabled), button:active:not(:disabled) { transform: translateY(0); }

/* Attendance corrections are an editor panel, not a single horizontal line.
   The grid prevents comment and audit-reason fields from collapsing inside the
   final table column while preserving the existing form and audit workflow. */
.correction {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(9rem, 1fr));
    gap: .65rem !important;
    width: clamp(22rem, 30vw, 32rem);
    min-width: 0 !important;
    align-items: end;
    padding: .75rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-small);
    background: var(--ui-surface-muted);
}
.correction > select,
.correction > .programs,
.correction > input:not([type="hidden"]) { grid-column: 1 / -1; width: 100%; }
.correction > label { min-width: 0; }
.correction > button { justify-self: start; }

/* Expanded attendance actions must remain usable inside narrow operational
   cards and the final column of the attendance table. */
.cards > .card details {
    margin-top: .55rem;
    border: 1px solid rgba(255, 255, 255, .42);
    border-radius: var(--ui-radius-small);
    background: rgba(11, 28, 44, .32);
    overflow: hidden;
}
.cards > .card details > summary { padding: .55rem .65rem; }
.cards > .card details[open] > summary { border-bottom: 1px solid rgba(255, 255, 255, .3); }
.cards > .card details > form { margin: 0; padding: .7rem; }
.cards > .card details label + label { margin-top: .55rem; }
.cards > .card details input,
.cards > .card details select { margin-top: .25rem; }

/* The correction form cannot fit inside a table cell. Present the editor as
   a viewport-contained work surface while retaining the existing audited
   form, route, and table context. */
.correction-column details[open] > .correction {
    position: fixed;
    z-index: 1001;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(42rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 1rem;
    border-color: var(--ui-control-border);
    background: var(--ui-surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.correction-column details:has(> .correction)[open]::before {
    content: "";
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(4, 12, 20, .62);
    pointer-events: none;
}
.correction-column details:has(> .correction)[open] > summary {
    position: fixed;
    z-index: 1002;
    top: 1rem;
    right: 1rem;
    padding: .65rem .8rem;
    border: 1px solid var(--ui-control-border);
    border-radius: var(--ui-radius-small);
    background: var(--ui-surface);
    color: var(--ui-text) !important;
    box-shadow: var(--ui-shadow);
}
.correction-column details:has(> .correction)[open] > summary::after { content: " — close"; }
.correction-column details[open] > .correction::before {
    content: "Edit today’s attendance";
    grid-column: 1 / -1;
    color: var(--ui-text);
    font-family: var(--ui-font-display);
    font-size: 1.15rem;
    font-weight: var(--ui-weight-bold);
}
.correction-column details[open] .programs { min-width: 0; }
.correction-column details[open] .programs label { white-space: normal; }

@media (max-width: 48rem) {
    .correction,
    .correction-column details[open] > .correction { grid-template-columns: 1fr; width: min(28rem, calc(100vw - 2rem)); }
    .correction > * { grid-column: 1 !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] main { background-color: transparent !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] h4,
:root[data-theme="dark"] summary,
:root[data-theme="dark"] .label,
:root[data-theme="dark"] .value { color: var(--ui-text) !important; }
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] section,
:root[data-theme="dark"] .analytics,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] details,
:root[data-theme="dark"] fieldset,
:root[data-theme="dark"] .schedule-day,
:root[data-theme="dark"] .contact-card,
:root[data-theme="dark"] .calendar-day,
:root[data-theme="dark"] .day,
:root[data-theme="dark"] .staff label,
:root[data-theme="dark"] .program-row label,
:root[data-theme="dark"] .tag,
:root[data-theme="dark"] .dates span,
:root[data-theme="dark"] .invite {
    border-color: var(--ui-border) !important;
    background: var(--ui-surface) !important;
    color: var(--ui-text) !important;
}
:root[data-theme="dark"] tbody tr:nth-child(even),
:root[data-theme="dark"] .weekday,
:root[data-theme="dark"] .outside { background: var(--ui-surface-muted) !important; }
:root[data-theme="dark"] .note,
:root[data-theme="dark"] .hint,
:root[data-theme="dark"] .privacy-note { border-color: var(--ui-focus) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] .note,
:root[data-theme="dark"] .privacy-note { border-left-color: var(--ui-info) !important; background: var(--ui-info-soft) !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] .review-card { border-color: var(--ui-warning) !important; background: var(--ui-warning-soft) !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] .review-card .muted { color: var(--ui-muted) !important; }
:root[data-theme="dark"] .count,
:root[data-theme="dark"] .badge { background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] .filters .filter { border-color: var(--ui-control-border) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] .filters .filter.current { border-color: var(--ui-focus) !important; background: var(--ui-primary) !important; color: #10243e !important; }
:root[data-theme="dark"] .attendance-tools,
:root[data-theme="dark"] .monthly-tools { border-color: var(--ui-border) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
:root[data-theme="dark"] .calendar-day.selected { outline-color: var(--ui-focus) !important; background: color-mix(in srgb, var(--ui-focus) 14%, var(--ui-surface)) !important; }
:root[data-theme="dark"] .paid-count { color: var(--ui-primary) !important; }
:root[data-theme="dark"] .day-statuses { color: var(--ui-muted) !important; }
:root[data-theme="dark"] .success,
:root[data-theme="dark"] .status-good,
:root[data-theme="dark"] .notice { background: var(--ui-success-soft) !important; color: var(--ui-success) !important; }
:root[data-theme="dark"] .error,
:root[data-theme="dark"] .errors,
:root[data-theme="dark"] .status-bad,
:root[data-theme="dark"] .danger,
:root[data-theme="dark"] .problem { background: var(--ui-danger-soft) !important; color: var(--ui-danger) !important; }
:root[data-theme="dark"] button:disabled,
:root[data-theme="dark"] .button[aria-disabled="true"] { background: var(--ui-surface-muted) !important; color: var(--ui-muted) !important; }
:root[data-theme="dark"] main a:not(.button):not(.action) { color: var(--ui-primary) !important; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body,
    :root:not([data-theme="light"]) main { background-color: transparent !important; color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) h1,
    :root:not([data-theme="light"]) h2,
    :root:not([data-theme="light"]) h3,
    :root:not([data-theme="light"]) h4,
    :root:not([data-theme="light"]) summary { color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) .card,
    :root:not([data-theme="light"]) .panel,
    :root:not([data-theme="light"]) section,
    :root:not([data-theme="light"]) .analytics,
    :root:not([data-theme="light"]) .table-wrap,
    :root:not([data-theme="light"]) details,
    :root:not([data-theme="light"]) fieldset,
    :root:not([data-theme="light"]) .schedule-day,
    :root:not([data-theme="light"]) .contact-card,
    :root:not([data-theme="light"]) .calendar-day,
    :root:not([data-theme="light"]) .day,
    :root:not([data-theme="light"]) .staff label,
    :root:not([data-theme="light"]) .program-row label,
    :root:not([data-theme="light"]) .dates span,
    :root:not([data-theme="light"]) .invite {
        border-color: var(--ui-border) !important;
        background: var(--ui-surface) !important;
        color: var(--ui-text) !important;
    }
    :root:not([data-theme="light"]) button:disabled,
    :root:not([data-theme="light"]) .button[aria-disabled="true"] { background: var(--ui-surface-muted) !important; color: var(--ui-muted) !important; }
    :root:not([data-theme="light"]) main a:not(.button):not(.action) { color: var(--ui-primary) !important; }
    :root:not([data-theme="light"]) .note,
    :root:not([data-theme="light"]) .privacy-note { border-color: var(--ui-info) !important; background: var(--ui-info-soft) !important; color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) .review-card { border-color: var(--ui-warning) !important; background: var(--ui-warning-soft) !important; color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) .review-card .muted { color: var(--ui-muted) !important; }
    :root:not([data-theme="light"]) .success,
    :root:not([data-theme="light"]) .status-good,
    :root:not([data-theme="light"]) .notice { background: var(--ui-success-soft) !important; color: var(--ui-success) !important; }
    :root:not([data-theme="light"]) .error,
    :root:not([data-theme="light"]) .errors,
    :root:not([data-theme="light"]) .status-bad,
    :root:not([data-theme="light"]) .danger,
    :root:not([data-theme="light"]) .problem { background: var(--ui-danger-soft) !important; color: var(--ui-danger) !important; }
    :root:not([data-theme="light"]) .count,
    :root:not([data-theme="light"]) .badge { background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) .filters .filter { border-color: var(--ui-control-border) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) .filters .filter.current { border-color: var(--ui-focus) !important; background: var(--ui-primary) !important; color: #10243e !important; }
    :root:not([data-theme="light"]) .attendance-tools,
    :root:not([data-theme="light"]) .monthly-tools { border-color: var(--ui-border) !important; background: var(--ui-surface-muted) !important; color: var(--ui-text) !important; }
    :root:not([data-theme="light"]) .calendar-day.selected { outline-color: var(--ui-focus) !important; background: color-mix(in srgb, var(--ui-focus) 14%, var(--ui-surface)) !important; }
    :root:not([data-theme="light"]) .paid-count { color: var(--ui-primary) !important; }
    :root:not([data-theme="light"]) .day-statuses { color: var(--ui-muted) !important; }
}

/* Attendance service colours are operational cues, not decorative surfaces.
   Restore them after the generic dark-surface rules so Dark and System modes
   remain as easy to scan as Light mode. */
:root[data-theme="dark"] .cards > .card.service-half { background: linear-gradient(145deg, #3f8fe2 0%, #2455a4 100%) !important; }
:root[data-theme="dark"] .cards > .card.service-full { background: linear-gradient(145deg, #8f67cf 0%, #51359a 100%) !important; }
:root[data-theme="dark"] .cards > .card.service-combined { background: linear-gradient(145deg, #ef8a45 0%, #b94a22 100%) !important; }
:root[data-theme="dark"] .cards > .card.service-community { background: linear-gradient(145deg, #35b69b 0%, #14736f 100%) !important; }
:root[data-theme="dark"] .cards > .card.service-respite { background: linear-gradient(145deg, #df5988 0%, #9e285e 100%) !important; }
:root[data-theme="dark"] .cards > .card.service-other { background: linear-gradient(145deg, #73869b 0%, #405268 100%) !important; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .cards > .card.service-half { background: linear-gradient(145deg, #3f8fe2 0%, #2455a4 100%) !important; }
    :root:not([data-theme="light"]) .cards > .card.service-full { background: linear-gradient(145deg, #8f67cf 0%, #51359a 100%) !important; }
    :root:not([data-theme="light"]) .cards > .card.service-combined { background: linear-gradient(145deg, #ef8a45 0%, #b94a22 100%) !important; }
    :root:not([data-theme="light"]) .cards > .card.service-community { background: linear-gradient(145deg, #35b69b 0%, #14736f 100%) !important; }
    :root:not([data-theme="light"]) .cards > .card.service-respite { background: linear-gradient(145deg, #df5988 0%, #9e285e 100%) !important; }
    :root:not([data-theme="light"]) .cards > .card.service-other { background: linear-gradient(145deg, #73869b 0%, #405268 100%) !important; }
}
