/* One screen palette. Loaded after module styles; module geometry stays with each module. */
:root {
    --gccja-background: #0C1925;
    --gccja-panel: #132B3E;
    --gccja-emphasis: #1D3D55;
    --gccja-text: #E1EBF3;
    --gccja-gold: #D4A64D;
    --gccja-border: #30475B;
    --gccja-secondary: #AEBFCE;
    --gccja-link: #9BCBFA;
    --gccja-positive: #9AD9B0;
    --gccja-warning: #F0CE83;
    --gccja-negative: #F3ABAF;
    --gccja-info: #AAD1FA;
}

@media screen {
    html[data-theme="dark"], html[data-theme="dark"] body {
        color-scheme: dark;
        color: var(--gccja-text);
        background: var(--gccja-background);
        --panel: var(--gccja-panel);
        --surface: var(--gccja-background);
        --surface-muted: var(--gccja-emphasis);
        --border: var(--gccja-border);
        --line: var(--gccja-border);
        --gold: var(--gccja-gold);
        --green: var(--gccja-positive);
    }
    html[data-theme="dark"] body :is(.app-content, .app-content > main, .employee-administration .app-content, .dashboard-main, .login-page) {
        background: var(--gccja-background);
        color: var(--gccja-text);
    }
    html[data-theme="dark"] body :is(.sidebar, .core-values-footer, .dashboard-masthead) {
        background: var(--gccja-panel);
        color: var(--gccja-text);
        border-color: var(--gccja-border);
    }
    html[data-theme="dark"] body .core-values-footer { border-top-color: var(--gccja-gold); }
    html[data-theme="dark"] body .nav-group > summary { color: var(--gccja-gold); }
    html[data-theme="dark"] body .sidebar nav a { color: var(--gccja-text); }
    html[data-theme="dark"] body .sidebar nav a:is(:hover, :focus-visible, .active) { background: var(--gccja-emphasis); color: var(--gccja-text); }
    html[data-theme="dark"] body .sidebar nav a.active { box-shadow: inset 3px 0 var(--gccja-gold); }
    html[data-theme="dark"] body :is(.nav-placeholder, .nav-placeholder small, .sidebar-footer > span) { color: var(--gccja-secondary); }

    /* Shared module cards, schedules, reports, editors and dialogs. */
    html[data-theme="dark"] body :is(.panel, .operation-card, .primary-operation-card, .secondary-indicator,
        .hospital-movement-panel, .hospital-event-actions form, .admin-section-grid article, .admin-workspace,
        .admin-directory, .record-form section, .equipment-list article, .reference-list article,
        .employee-card, .employee-profile-card, .profile-card, .profile-section, .employee-detail-card,
        .post-table-wrap, .post-accountability, .post-medical, .assignment-card, .assignment-support,
        .assignment-slot, .support-panel, .support-leave, .support-training, .support-medical,
        .range-summary, .mission-card, .editor-grid, .mission-editor summary, .range-nav a,
        .matrix-corner, .mission-label, .medical-corner, .medical-label, .calendar-day,
        .calendar-editors, .calendar-editors form, .medical-summary article, .today-priorities,
        .count-workflow-card, .count-next-action div, .count-summary, .head-count-panel,
        .running-count-panel, .count-panel, .count-card, .workflow-card, .search-panel,
        .running-summary > div, .movement-entry, .location-balances, .custody-panel, .journal,
        .head-count-totals div, .count-group, .count-approval-bar div, .scenario-nav a,
        .locked-route, .paper-slip-form, .slip-values label, .finalization-confirmation > div:not(.confirmation-actions),
        .medical-day-editor, .medical-assignment-editors form, .calendar-editor, .summary-cards article,
        .assignment-command-bar, .person-card, .destination-card, .workflow-panel, .briefing-display,
        .briefing-identification > div, .briefing-leadership, .briefing-building, .briefing-support > section,
        .assignment-support-panel, .assignment-staffing-overview, .assignment-facility-training,
        .search-results, .search-filters, .record-card, .floor-timer-card, .floor-card,
        .operations-panel, .operations-clock, .completed-count > div, .login-card, dialog, [role="dialog"]) {
        background: var(--gccja-panel);
        color: var(--gccja-text);
        border-color: var(--gccja-border);
    }
    html[data-theme="dark"] body :is(table, th, td, .post-row, .assignment-row, .mission-cell, .medical-cell,
        .info-cell, .calendar-day, .editor-grid, .directory-filters, .count-next-action, .post-support-grid,
        .assignment-command-bar, .person-card, .briefing-post, .count-group, .running-summary > div) {
        border-color: var(--gccja-border);
    }
    html[data-theme="dark"] body :is(thead, thead th, .post-section th, .date-head, .board-head,
        .medical-date, .operations-table thead, .count-lifecycle-banner, .record-step,
        .operation-card dl, .primary-operation-card footer, .department-heading,
        .post-table tbody > tr > th, .employee-administration table thead th,
        .detention-briefing h3, .briefing-groups h2, .balance-groups h3, .count-group > header,
        .support-leave > h2, .support-overtime > h2, .support-training > h2, .support-medical > h2) {
        background: var(--gccja-emphasis) !important;
        color: var(--gccja-text) !important;
    }
    html[data-theme="dark"] body :is(.mission-cell, .medical-cell, .movement span, .dashboard-unavailable,
        .locked-action, .count-workflow-card.locked, .count-next-action, .assigned-people > span,
        .accountability-selected > span, .not-applicable, .card-path, .info-cell,
        .detention-briefing, .briefing-post:nth-child(even), .round-gate, .initiate-required,
        .history-row > td, .secondary-indicator li, .operation-card header > span,
        .overtime-structure, .board-action, .interaction-hint, .secondary-workflow-action,
        .post-row, .post-row.not-applicable, .calendar-on-call, .finalization-state) {
        background: var(--gccja-background);
        color: var(--gccja-secondary);
    }
    html[data-theme="dark"] body :is(.today, .date-head.today, .medical-date.today, .medical-cell.today) {
        background: var(--gccja-emphasis) !important;
        box-shadow: inset 0 3px var(--gccja-gold);
    }
    html[data-theme="dark"] body :is(.operations-table tr[data-module-url]:hover, .admin-table tbody tr:hover,
        .employee-administration tbody tr:hover, .calendar-day:hover) { background: var(--gccja-emphasis); }
    html[data-theme="dark"] body :is(h1, h2, h3, h4, .operations-dashboard, .department-name, .module-arrow,
        .primary-metric strong, .split-metrics strong, .count-primary strong, .out-count strong,
        .post-name span, .accountability-list strong, .count-workflow-card strong, .count-workflow-card dd,
        .detention-briefing, .briefing-post, .person-name, .destination-card, .workflow-panel,
        .medical-label, .medical-cell, .medical-summary strong, .summary-cards strong,
        .running-summary strong, .head-count-totals strong, .movement-card > div) {
        color: var(--gccja-text);
    }
    html[data-theme="dark"] body :is(.muted, .eyebrow, .dashboard-context, .operations-table tbody th small,
        .dashboard-refresh, .pending-table td, .directory-count, .record-grid small, .profile-label,
        .admin-table td small, .reference-list small, .count-workflow-card p, .count-workflow-card dt,
        .count-next-action p, .count-next-action small, .post-name small, .assigned-people small,
        .primary-card-metric span, .count-summary p, .count-summary small, .info-label) { color: var(--gccja-secondary); }
    html[data-theme="dark"] body a { color: var(--gccja-link); }
    html[data-theme="dark"] body a:hover { color: var(--gccja-text); }
    html[data-theme="dark"] body :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea, option) {
        background: var(--gccja-background) !important;
        color: var(--gccja-text) !important;
        border-color: var(--gccja-border) !important;
    }
    html[data-theme="dark"] body input::placeholder, html[data-theme="dark"] body textarea::placeholder { color: var(--gccja-secondary); opacity: 1; }
    html[data-theme="dark"] body :is(button, .primary-action, .secondary-action, .dashboard-button,
        .transport-actions a, .count-workflow-card a, .employee-administration button) {
        background: var(--gccja-emphasis);
        color: var(--gccja-text);
        border-color: var(--gccja-border);
    }
    html[data-theme="dark"] body :is(button, .primary-action, .secondary-action, .dashboard-button):hover { border-color: var(--gccja-gold); }
    html[data-theme="dark"] body :focus-visible { outline: 2px solid var(--gccja-gold); outline-offset: 3px; }
    html[data-theme="dark"] body :is(button:disabled, input:disabled, select:disabled, textarea:disabled,
        .dashboard-disabled, [aria-disabled="true"]) { color: var(--gccja-secondary); background-color: var(--gccja-background); border-color: var(--gccja-border); opacity: 1; }
    html[data-theme="dark"] body .operations-table .neutral { background: var(--gccja-emphasis); color: var(--gccja-text); }
    html[data-theme="dark"] body :is(.green, .reconciled, .dashboard-badge, .post-manning.ready, .record-status.active,
        .position-state:not(.unassigned):not(.not-applicable), .count-complete-transition, .workflow-message,
        .destination-card.staffed, .review-result.ready, .assignment-readiness-summary.ready, .journal tr.replacement) {
        background: #183D36; color: var(--gccja-positive); border-color: #3D7164;
    }
    html[data-theme="dark"] body :is(.amber, .warning, .review-attention, .disclaimer, .post-manning:not(.ready),
        .position-state.unassigned, .transfer-block, .finalization-confirmation, .journal tr.amended,
        .calendar-leave, .assignment-readiness-summary:not(.ready), .briefing-callout, .review-result:not(.ready),
        .post-row.unassigned, .person-card.unresolved-person, .staffing-badge.added,
        .qualification-taser, .badge-taser, .briefing-totals .leave,
        .shakedown-badge.duesoon) {
        background: #433922; color: var(--gccja-warning); border-color: #8A733D;
    }
    html[data-theme="dark"] body :is(.danger, .validation-summary-errors, .field-validation-error, .record-status.inactive,
        .login-error, .conflict, .mission-card.cancelled) { color: var(--gccja-negative); }
    html[data-theme="dark"] body :is(.assignment-ot, .shakedown-badge.pastdue) { background: #452B35; color: var(--gccja-negative); }
    html[data-theme="dark"] body :is(.blue, .movement-card, .alert.info) { background: #193B59; color: var(--gccja-info); }
    html[data-theme="dark"] body :is(.purple, .qualification-gun, .badge-gun, .badge-ot, .briefing-totals .overtime) { background: #352F50; color: #D5C0EE; }
    html[data-theme="dark"] body :is(.cleared, .record-status.active, .hospital-event-history li b) { color: var(--gccja-positive); }
    html[data-theme="dark"] body .mission-card:is(.conflict, .rescheduled) summary::after { background: #433922; color: var(--gccja-warning); }
    html[data-theme="dark"] body .mission-card.cancelled summary::after { background: #452B35; color: var(--gccja-negative); }
    html[data-theme="dark"] body .login-card { border-color: var(--gccja-gold); }
    html[data-theme="dark"] body .login-card button { background: var(--gccja-gold); color: var(--gccja-background); }
    html[data-theme="dark"] body :is(.login-card p, .login-card label, .login-brand span) { color: var(--gccja-secondary); }

    /* Post-102 component refinements: presentation only; leave report print geometry intact. */
    html[data-theme="dark"] body .detention-briefing .briefing-totals .eligible {
        background: #183D36; color: var(--gccja-positive); border: 1px solid #3D7164;
    }
    html[data-theme="dark"] body .detention-briefing .briefing-totals .assigned {
        background: #193B59; color: var(--gccja-info); border: 1px solid #527C9F;
    }
    html[data-theme="dark"] body .detention-briefing .briefing-post { column-gap: 1rem; padding-block: .4rem; }
    html[data-theme="dark"] body .detention-briefing .briefing-post h4 { line-height: 1.4; font-weight: 600; }
    html[data-theme="dark"] body .detention-briefing .briefing-person { gap: .3rem .6rem; line-height: 1.45; }
    html[data-theme="dark"] body .detention-briefing .briefing-person + .briefing-person { margin-top: .45rem; }
    html[data-theme="dark"] body .detention-briefing .briefing-person small { color: var(--gccja-secondary); }
    html[data-theme="dark"] body .detention-briefing .briefing-equipment { margin-top: .1rem; }
    html[data-theme="dark"] body .detention-briefing .briefing-badges { gap: .3rem; }
    html[data-theme="dark"] body .detention-briefing .briefing-badges > span { padding: .08rem .35rem; line-height: 1.35; }
    html[data-theme="dark"] body .detention-briefing .badge-fto { background: #183D36; color: var(--gccja-positive); }
    html[data-theme="dark"] body .detention-briefing .briefing-status.final { background: #183D36; color: var(--gccja-positive); border-color: var(--gccja-positive); }
    html[data-theme="dark"] body .detention-briefing .briefing-status.draft { background: #433922; color: var(--gccja-warning); border-color: var(--gccja-warning); }
    html[data-theme="dark"] body .detention-briefing :is(.briefing-empty, .briefing-context, .briefing-vacant) { color: var(--gccja-secondary); }
    html[data-theme="dark"] body .detention-entry .assignment-destination { column-gap: .65rem; padding-block: .4rem; }
    html[data-theme="dark"] body .detention-entry .assignment-row-label h3 { line-height: 1.4; margin-block: .2rem; }
    html[data-theme="dark"] body .detention-entry .assignment-slots { row-gap: .5rem; }
    html[data-theme="dark"] body .detention-entry .assignment-slot { column-gap: .6rem; }
    html[data-theme="dark"] body .detention-entry .assignment-qualifications { gap: .3rem; margin-top: .3rem; }
    html[data-theme="dark"] body .detention-entry .qualification-badge { padding: .1rem .3rem; line-height: 1.35; }
    html[data-theme="dark"] body .detention-entry .qualification-fto { background: #183D36; color: var(--gccja-positive); }

    /* Mode and urgency remain driven by the existing timer classes and data commands. */
    html[data-theme="dark"] body .floor-stopwatch .timer-bezel { background: var(--gccja-panel); }
    html[data-theme="dark"] body .floor-stopwatch .timer-display {
        background: var(--gccja-background); color: #D9F1FF; text-shadow: none; opacity: 1;
        border-color: #7898AF; font-variant-numeric: tabular-nums;
    }
    html[data-theme="dark"] body .floor-stopwatch :is(.timer-state, .timer-status) { font-size: 10px; letter-spacing: .06em; }
    html[data-theme="dark"] body .floor-stopwatch .timer-state { color: var(--gccja-secondary); }
    html[data-theme="dark"] body .floor-stopwatch.is-running .timer-state { color: var(--gccja-positive); }
    html[data-theme="dark"] body .floor-stopwatch .timer-controls .start-pause[data-command="start"] {
        background: #1B6348; color: #E1EBF3; border: 1px solid #75C69D;
    }
    html[data-theme="dark"] body .floor-stopwatch .timer-controls .start-pause[data-command="start"]:hover { background: #205A45; }
    html[data-theme="dark"] body .floor-stopwatch .timer-controls .start-pause[data-command="pause"] {
        background: #433922; color: var(--gccja-warning); border-color: #A78B4A;
    }
    html[data-theme="dark"] body .floor-stopwatch .timer-controls .reset {
        background: #30475B; color: var(--gccja-text); border: 1px dashed #AEBFCE;
    }
    html[data-theme="dark"] body .floor-stopwatch .timer-controls .reset:hover { background: #3A5368; }
    html[data-theme="dark"] body .floor-stopwatch .timer-mode button { background: var(--gccja-background); color: var(--gccja-secondary); }
    html[data-theme="dark"] body .floor-stopwatch .timer-mode button[aria-pressed="true"][data-interval-choice="15"] {
        background: #433922; color: var(--gccja-warning); border-color: var(--gccja-gold);
    }
    html[data-theme="dark"] body .floor-stopwatch .timer-mode button[aria-pressed="true"][data-interval-choice="60"] {
        background: #193B59; color: var(--gccja-info); border-color: #86B8DD;
    }
    html[data-theme="dark"] body .floor-stopwatch.mode-15 .timer-bezel { background: #2B291F; border-color: var(--gccja-gold); }
    html[data-theme="dark"] body .floor-stopwatch.mode-15 :is(.timer-display, .mode-readout) { color: var(--gccja-warning); }
    html[data-theme="dark"] body .floor-stopwatch.mode-60 .timer-bezel { border-color: #86B8DD; }
    html[data-theme="dark"] body .floor-stopwatch.mode-60 :is(.timer-display, .mode-readout) { color: var(--gccja-info); }
    html[data-theme="dark"] body .floor-stopwatch.urgency-warning :is(.urgency-readout, .timer-display) { color: var(--gccja-warning); }
    html[data-theme="dark"] body .floor-stopwatch.urgency-overdue :is(.urgency-readout, .timer-display) { color: var(--gccja-negative); }
    html[data-theme="dark"] body .floor-stopwatch.urgency-overdue .timer-display { border-color: var(--gccja-negative); }

    html[data-theme="dark"] body .my-profile .employee-card { background: var(--gccja-panel); color: var(--gccja-text); border-color: var(--gccja-border); }
    html[data-theme="dark"] body .my-profile .employee-card :is(h2, .qualification-line) { color: var(--gccja-text); }
    html[data-theme="dark"] body .my-profile .employee-card :is(p, dt, small, .qualification-name small, .qualification-state) { color: var(--gccja-secondary); }
    html[data-theme="dark"] body .my-profile .employee-icon {
        color: var(--gccja-text); fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round;
    }
}

/* Screen-only theme must never leak dark surfaces or pale text into printed reports. */
@media print {
    :root { color-scheme: light; --panel: #fff; --surface: #fff; --surface-muted: #f3f3f3; --border: #777; --line: #777; --green: #174B2B; }
    html[data-theme="dark"], html[data-theme="dark"] body { background: #fff !important; color: #111 !important; }
    html[data-theme="dark"] body * { background-color: transparent !important; background-image: none !important; color: #111 !important; text-shadow: none !important; box-shadow: none !important; }
    html[data-theme="dark"] body :is(th, td, input, select, textarea) { border-color: #777 !important; }
    html[data-theme="dark"] body .light-surface-icon { display: block !important; }
    html[data-theme="dark"] body .dark-surface-icon { display: none !important; }
    html[data-theme="dark"] body img[src*="_dark_surface"] { filter: grayscale(1) brightness(.25); }
    .operations-dashboard { max-width: none; }
}
