/* Remout blue is a light-only color layer. Dark inherits the qualified Squad assets unchanged. */
/* Shared portals receive these colors only while their owner is in an included surface. */
:where(:root:not([data-theme="dark"])) .login-page,
:where(:root:not([data-theme="dark"])) .topbar.remout-palette,
:where(:root:not([data-theme="dark"])) .sticky-workbar,
:where(:root:not([data-theme="dark"])) #kanban,
:where(:root:not([data-theme="dark"])) #parts-search-dialog,
:where(:root:not([data-theme="dark"])) #schedule,
:where(:root:not([data-theme="dark"])) #payroll,
:where(:root:not([data-theme="dark"])) #settings,
:where(:root:not([data-theme="dark"])) #active-summary-dialog,
:where(:root:not([data-theme="dark"])) [data-dashboard-metric-dialog],
:where(:root:not([data-theme="dark"])) #sync-health-dialog,
:where(:root:not([data-theme="dark"])) [data-pricing-calculator],
:where(:root:not([data-theme="dark"])) [data-team-wizard],
:where(:root:not([data-theme="dark"])) #team-chat-inbox-dialog,
:where(:root:not([data-theme="dark"])) .kanban-note-dialog,
:where(:root:not([data-theme="dark"])) .kanban-note-tooltip,
:where(:root:not([data-theme="dark"])) .kanban-note-toast,
:where(:root:not([data-theme="dark"])) [data-master-assignment-confirm-dialog],
:where(:root:not([data-theme="dark"])) [data-remout-chat-notice],
:where(:root:not([data-theme="dark"])) body:has(.topbar.remout-palette .ui-select-shell.is-open) > .ui-select-menu,
:where(:root:not([data-theme="dark"])) body:has(:is(.sticky-workbar, #kanban) .ui-select-shell.is-open) > #ui-select-menu,
:where(:root:not([data-theme="dark"])) body:has(:is(#schedule, #payroll, #settings) .ui-select-shell.is-open) > #ui-select-menu,
:where(:root:not([data-theme="dark"])) body:has(#kanban .deal-master-button[aria-expanded="true"]) > #kanban-master-assignment-menu,
:where(:root:not([data-theme="dark"])) body:has(#kanban .deal-urgency-button[aria-expanded="true"]) > #kanban-urgency-menu {
    --rm-bg: #f7f9fc;
    --rm-surface: #ffffff;
    --rm-surface-subtle: #f0f3f8;
    --rm-text: #152238;
    --rm-text-muted: #52627a;
    --rm-border: #dbe2ec;
    --rm-border-control: #78879c;
    --rm-action: #175cde;
    --rm-action-hover: #104bb7;
    --rm-action-pressed: #103d91;
    --rm-on-action: #ffffff;
    --rm-link: #104bb7;
    --rm-selected: #edf4ff;
    --rm-focus: #175cde;

    --bg: var(--rm-bg);
    --panel: var(--rm-surface);
    --panel-soft: var(--rm-surface-subtle);
    --panel-strong: var(--rm-selected);
    --ink: var(--rm-text);
    --text: var(--rm-text);
    --muted: var(--rm-text-muted);
    --line: var(--rm-border);
    --line-strong: var(--rm-border-control);
    --input-bg: var(--rm-surface);
    --topbar-bg: var(--rm-surface);
    --accent: var(--rm-action);
    --accent-hover: var(--rm-action-hover);
    --accent-contrast: var(--rm-on-action);
    --accent-soft: var(--rm-selected);
    --accent-2: var(--rm-link);

    --ui-focus: var(--rm-focus);
    --ui-text-focus: var(--rm-focus);
    --ui-select-surface: var(--rm-surface);
    --ui-select-hover: var(--rm-selected);
    --ui-select-border: var(--rm-border-control);
    --ui-select-focus: var(--rm-focus);
    --ui-select-icon: var(--rm-text-muted);
    --ui-select-divider: var(--rm-border);
    --ui-select-option-hover: var(--rm-surface-subtle);
    --ui-select-option-selected: var(--rm-selected);
    --ui-select-option-selected-hover: var(--rm-selected);
    --ui-select-radio-idle: var(--rm-border-control);
    --ui-select-radio: var(--rm-action);
    --ui-choice-mark: var(--rm-action);
    --ui-choice-check: var(--rm-on-action);
}

:where(:root:not([data-theme="dark"])) .login-page {
    background: var(--rm-bg);
    color: var(--rm-text);
}

:where(:root:not([data-theme="dark"])) .login-page input,
:where(:root:not([data-theme="dark"])) .topbar.remout-palette input {
    border-color: var(--rm-border-control);
}

:where(:root:not([data-theme="dark"])) .login-page input::placeholder,
:where(:root:not([data-theme="dark"])) .topbar.remout-palette input::placeholder {
    color: var(--rm-text-muted);
}

:where(:root:not([data-theme="dark"])) .topbar.remout-palette .brand-home {
    color: var(--rm-link);
}

:where(:root:not([data-theme="dark"])) .topbar.remout-palette .brand-home:hover,
:where(:root:not([data-theme="dark"])) .topbar.remout-palette .brand-home:focus-visible {
    color: var(--rm-action-hover);
}

:where(:root:not([data-theme="dark"])) .topbar.remout-palette .theme-toggle-track {
    background: var(--rm-selected);
}

:where(:root:not([data-theme="dark"])) .topbar.remout-palette .theme-toggle-knob {
    background: var(--rm-action);
}

:where(:root:not([data-theme="dark"])) .login-page button[type="submit"]:active,
:where(:root:not([data-theme="dark"])) .topbar.remout-palette .top-filter-grid > button[type="submit"]:active {
    background: var(--rm-action-pressed);
}

@media (forced-colors: active) {
    :where(:root:not([data-theme="dark"])) .login-page,
    :where(:root:not([data-theme="dark"])) .topbar.remout-palette,
    :where(:root:not([data-theme="dark"])) .sticky-workbar,
    :where(:root:not([data-theme="dark"])) #kanban,
    :where(:root:not([data-theme="dark"])) #parts-search-dialog,
    :where(:root:not([data-theme="dark"])) #schedule,
    :where(:root:not([data-theme="dark"])) #payroll,
    :where(:root:not([data-theme="dark"])) #settings,
    :where(:root:not([data-theme="dark"])) #active-summary-dialog,
    :where(:root:not([data-theme="dark"])) [data-dashboard-metric-dialog],
    :where(:root:not([data-theme="dark"])) #sync-health-dialog,
    :where(:root:not([data-theme="dark"])) [data-pricing-calculator],
    :where(:root:not([data-theme="dark"])) [data-team-wizard],
    :where(:root:not([data-theme="dark"])) #team-chat-inbox-dialog,
    :where(:root:not([data-theme="dark"])) .kanban-note-dialog,
    :where(:root:not([data-theme="dark"])) .kanban-note-tooltip,
    :where(:root:not([data-theme="dark"])) .kanban-note-toast,
    :where(:root:not([data-theme="dark"])) [data-master-assignment-confirm-dialog],
    :where(:root:not([data-theme="dark"])) [data-remout-chat-notice],
    :where(:root:not([data-theme="dark"])) body:has(.topbar.remout-palette .ui-select-shell.is-open) > .ui-select-menu,
    :where(:root:not([data-theme="dark"])) body:has(:is(.sticky-workbar, #kanban) .ui-select-shell.is-open) > #ui-select-menu,
    :where(:root:not([data-theme="dark"])) body:has(:is(#schedule, #payroll, #settings) .ui-select-shell.is-open) > #ui-select-menu,
    :where(:root:not([data-theme="dark"])) body:has(#kanban .deal-master-button[aria-expanded="true"]) > #kanban-master-assignment-menu,
    :where(:root:not([data-theme="dark"])) body:has(#kanban .deal-urgency-button[aria-expanded="true"]) > #kanban-urgency-menu {
        --ui-focus: Highlight;
        --ui-text-focus: Highlight;
        --ui-select-focus: Highlight;
    }
}

/* Scoped light-theme aliases for content and dialogs. */
:where(:root:not([data-theme="dark"])) .sticky-workbar,
:where(:root:not([data-theme="dark"])) #kanban,
:where(:root:not([data-theme="dark"])) #parts-search-dialog,
:where(:root:not([data-theme="dark"])) #schedule,
:where(:root:not([data-theme="dark"])) #payroll,
:where(:root:not([data-theme="dark"])) #settings,
:where(:root:not([data-theme="dark"])) #active-summary-dialog,
:where(:root:not([data-theme="dark"])) [data-dashboard-metric-dialog],
:where(:root:not([data-theme="dark"])) #sync-health-dialog,
:where(:root:not([data-theme="dark"])) [data-pricing-calculator],
:where(:root:not([data-theme="dark"])) [data-team-wizard],
:where(:root:not([data-theme="dark"])) #team-chat-inbox-dialog,
:where(:root:not([data-theme="dark"])) .kanban-note-dialog,
:where(:root:not([data-theme="dark"])) .kanban-note-tooltip,
:where(:root:not([data-theme="dark"])) .kanban-note-toast,
:where(:root:not([data-theme="dark"])) [data-master-assignment-confirm-dialog],
:where(:root:not([data-theme="dark"])) [data-remout-chat-notice] {
    --rm-surface-raised: #ffffff;
    --rm-status-line: #dce4e1;
    --panel-strong: var(--rm-surface-raised);
    --sticky-bg: var(--rm-bg);
    --column-bg: var(--rm-surface-subtle);
    --card-bg: var(--rm-surface);
    --table-bg: var(--rm-surface);
    --table-head-bg: var(--rm-surface-subtle);
    --chip-bg: var(--rm-surface);
    --storage-bg: var(--rm-selected);
    --storage-text: var(--rm-link);
    --ui-control-rest: var(--rm-surface-subtle);
    --ui-control-hover: var(--rm-selected);
    --ui-control-pressed: var(--rm-selected);
    --ui-control-selected: var(--rm-selected);
    --ui-control-selected-border: var(--rm-action);
    --ui-control-track: var(--rm-surface-subtle);
    color: var(--rm-text);
}

/* Keep the accepted blue selection paint in the light theme only. */
:where(:root:not([data-theme="dark"])) #kanban :is(.master-chip, .type-chip).active {
    border-color: var(--rm-action);
    background: var(--rm-action);
    color: var(--rm-on-action);
}

/* Preserve the original warning/urgency border blends, including their animation colors. */
:where(:root:not([data-theme="dark"])) #kanban .kanban-column.constraint {
    --state-border-rest: color-mix(in srgb, var(--warn) 58%, var(--rm-status-line));
}

:where(:root:not([data-theme="dark"])) #kanban .deal-card.is-urgent,
:where(:root:not([data-theme="dark"])) #kanban .deal-card.is-urgent:hover {
    --state-border-rest: color-mix(in srgb, var(--danger) 58%, var(--rm-status-line));
}

:where(:root:not([data-theme="dark"])) #parts-search-dialog :is(input, textarea)::placeholder {
    color: var(--rm-text-muted);
}

/* ALE-16: preserve the original semantic shift/short/zero/day-off/vacation colors. */
:where(:root:not([data-theme="dark"])) #schedule .schedule-person {
    --accent-2: #1e5f8a;
    --panel: #ffffff;
    --panel-soft: #eef3f1;
    --line: #dce4e1;
    --line-strong: #b8c5c1;
    --input-bg: #ffffff;
    --ink: #18211f;
    --text: #18211f;
    --muted: #64706d;
    --ui-select-surface: #ffffff;
    --ui-select-hover: #f7faf9;
    --ui-select-border: #cbd6d2;
    --ui-select-focus: #71817b;
    --ui-select-icon: #64706d;
}

/* Strengthen native field boundaries without overriding copied/invalid/checked states. */
:where(:root:not([data-theme="dark"])) #settings :is(input, textarea) {
    --line: var(--rm-border-control);
}

:where(:root:not([data-theme="dark"])) :is(#schedule, #payroll, #settings) :is(input, textarea)::placeholder {
    color: var(--rm-text-muted);
}

/* Keep the original unassigned-direction warning border mix. */
:where(:root:not([data-theme="dark"])) #settings .tech-team-token.is-unassigned {
    --line: var(--rm-status-line);
}

/* Neutral name contrast only; vacation fill, borders and control colors stay preserved. */
:root:not([data-theme="dark"]) #schedule .schedule-person.is-vacation .schedule-person-name {
    color: var(--rm-text-muted);
}

/* ALE-17: preserve chart series, guides, axes and queue-share paint from the source. */
:where(:root:not([data-theme="dark"])) :is(#active-summary-dialog, [data-dashboard-metric-dialog]) :is(.metric-bar-chart, .metric-line-chart, .active-summary-tech-row) {
    --accent-2: #1e5f8a;
    --accent-soft: #e4f1ed;
    --panel: #ffffff;
    --panel-soft: #eef3f1;
    --panel-strong: #f7faf9;
    --input-bg: #ffffff;
    --line: #dce4e1;
    --line-strong: #b8c5c1;
    --ink: #18211f;
    --text: #18211f;
    --muted: #64706d;
}

/* Keep existing warning/red result gradients over their original neutral base. */
:where(:root:not([data-theme="dark"])) [data-pricing-calculator] .pricing-result:is(.warning, .danger) {
    --panel: #ffffff;
    --line: #dce4e1;
}

:where(:root:not([data-theme="dark"])) #active-summary-dialog .active-summary-totals .is-today {
    --line: var(--rm-status-line);
}

:where(:root:not([data-theme="dark"])) :is([data-pricing-calculator], [data-team-wizard]) :is(input, textarea) {
    --line: var(--rm-border-control);
}

:where(:root:not([data-theme="dark"])) :is([data-pricing-calculator], [data-team-wizard], #team-chat-inbox-dialog, .kanban-note-dialog) :is(input, textarea)::placeholder {
    color: var(--rm-text-muted);
}
