/* Shared palette. Keep the existing light appearance as the default. */
:root {
    color-scheme: light;
    --page-bg: #ffffff;
    --surface: #ffffff;
    --text: #000000;
    --widget-text: #333333;
    --muted: #666666;
    --sidebar-text: #555555;
    --heading: #1e2751;
    --link: #1e2751;
    --border: #dddddd;
    --stripe: #eeeeee;
    --hover: #e8edf7;
    --hover-text: #1e2751;
    --warning-bg: #fff7df;
    --warning-border: #c58a00;
    --warning-text: #654b00;
    --disabled-bg: #cccccc;
    --usable: #1f77b4;
    --short: #bd2900;
    --past: #526952;
    --success: #00aa00;
    --success-bg: #edf8f0;
    --success-border: #3e8e58;
    --success-text: #185d31;
    --danger: #aa0000;
    --danger-bg: #fff0f0;
    --danger-border: #c74b50;
    --danger-text: #741d22;
    --caution: #aaaa00;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page-bg: #111827;
    --surface: #1e293b;
    --text: #e5e7eb;
    --widget-text: #e5e7eb;
    --muted: #b6c2d2;
    --sidebar-text: #cbd5e1;
    --heading: #c5dcff;
    --link: #9ac6ff;
    --border: #475569;
    --stripe: #1b2638;
    --hover: #334768;
    --hover-text: #ffffff;
    --warning-bg: #392d19;
    --warning-border: #d6a345;
    --warning-text: #fde68a;
    --disabled-bg: #334155;
    --usable: #93c5fd;
    --short: #fdba74;
    --past: #afc8af;
    --success: #86efac;
    --success-bg: #14392b;
    --success-border: #4ade80;
    --success-text: #bbf7d0;
    --danger: #fca5a5;
    --danger-bg: #3b202a;
    --danger-border: #fb7185;
    --danger-text: #fecdd3;
    --caution: #fde68a;
}

:root[data-theme="dark"][data-dark-palette="graphite"] {
    --page-bg: #18181b;
    --surface: #27272a;
    --text: #f4f4f5;
    --widget-text: #e4e4e7;
    --muted: #a1a1aa;
    --sidebar-text: #d4d4d8;
    --heading: #f4f4f5;
    --link: #b8c4d4;
    --border: #52525b;
    --stripe: #202024;
    --hover: #3f3f46;
    --hover-text: #ffffff;
    --warning-bg: #3b321f;
    --warning-border: #d6a84f;
    --warning-text: #fde68a;
    --disabled-bg: #3f3f46;
    --usable: #7dd3fc;
    --short: #fdba74;
    --past: #c4c4c8;
    --success: #86efac;
    --success-bg: #1f3528;
    --success-border: #4ade80;
    --success-text: #bbf7d0;
    --danger: #fca5a5;
    --danger-bg: #3a2328;
    --danger-border: #f87171;
    --danger-text: #fecaca;
    --caution: #fde68a;
}

/* Header stays visible even when legacy content is wider than the viewport. */
.header2 {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 20px;
    align-items: center;
    box-sizing: border-box;
    max-width: 100vw;
}
.header2 .logo_mur {
    text-align: center;
    font-size: clamp(22px, 2.8vw, 40px);
    line-height: 1.1;
}
.header-tools { display: flex; gap: 20px; align-items: center; }
.theme-selector { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid #687496; border-radius: 10px; background: rgba(255, 255, 255, .06); vertical-align: middle; }
.theme-selector[hidden] { display: none; }
.theme-selector .theme-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #c8d4ef;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s, color .15s;
}
.theme-selector .theme-choice:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.theme-selector .theme-choice[aria-pressed="true"] { background: #edf2ff; color: #1e2751; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.theme-selector .theme-choice:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; }
.theme-choice svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-dark-picker { position: relative; display: flex; }
.theme-dark-menu {
    position: absolute;
    z-index: 2000;
    top: calc(100% + 9px);
    right: -35px;
    width: 146px;
    box-sizing: border-box;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .32);
}
.theme-dark-menu[hidden] { display: none; }
.theme-selector .theme-dark-menu .theme-palette-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 34px;
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.theme-selector .theme-dark-menu .theme-palette-option:hover,
.theme-selector .theme-dark-menu .theme-palette-option:focus-visible { background: var(--stripe); outline: none; }
.theme-selector .theme-dark-menu .theme-palette-option[aria-checked="true"] { background: var(--hover); color: var(--hover-text); }
.theme-selector .theme-dark-menu .theme-palette-option[aria-checked="true"]::after { content: '\2713'; margin-left: auto; font-weight: bold; }
.theme-palette-swatch { width: 16px; height: 16px; flex: 0 0 16px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; box-shadow: inset 7px 0 0 rgba(255, 255, 255, .2); }
.theme-palette-classic { background: #1e293b; }
.theme-palette-graphite { background: #3f3f46; }
.content-theme-selector { padding: 15px 30px 0; text-align: right; }
.content-theme-selector .theme-selector { background: var(--surface); border-color: var(--border); }
.content-theme-selector .theme-choice { color: var(--muted); }
.content-theme-selector .theme-choice:hover { background: var(--stripe); color: var(--text); }
.content-theme-selector .theme-choice[aria-pressed="true"] { background: var(--link); color: var(--surface); }
.content2b, .menu2b { height: calc(100vh - var(--mur-header-height, 72px)); }
@media (max-width: 680px) {
    .header2 { padding: 8px 12px; gap: 8px; grid-template-columns: auto 1fr; }
    .header2 .logo_ieec, .header2 .logo_oadm { height: 32px; }
    .header-tools { justify-content: flex-end; gap: 10px; }
    .header2 .logo_mur { grid-row: 2; grid-column: 1 / -1; font-size: 20px; }
}
@media (max-width: 400px) {
    .header2 .logo_ieec, .header2 .logo_oadm { height: 26px; }
    .header-tools { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    .theme-selector .theme-choice { transition: none; }
}

/* Vendor widgets are overridden here, leaving their bundled files intact. */
:root:not([data-theme="dark"]) .ui-state-hover,
:root:not([data-theme="dark"]) .ui-widget-content .ui-state-hover,
:root:not([data-theme="dark"]) .ui-widget-header .ui-state-hover,
:root:not([data-theme="dark"]) .ui-state-focus,
:root:not([data-theme="dark"]) .ui-button:hover,
:root:not([data-theme="dark"]) .ui-button:focus {
    background: var(--hover);
    color: var(--hover-text);
    border-color: #687496;
}
:root:not([data-theme="dark"]) .ui-state-hover a,
:root:not([data-theme="dark"]) .ui-state-focus a { color: var(--hover-text); }
:root:not([data-theme="dark"]) .ui-state-highlight,
:root:not([data-theme="dark"]) .ui-widget-content .ui-state-highlight,
:root:not([data-theme="dark"]) .ui-state-checked {
    background: var(--hover);
    color: var(--hover-text);
    border-color: #9aa8c8;
}
[data-theme="dark"] .ui-widget-content,
[data-theme="dark"] .ui-widget-header {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .ui-widget-content a { color: var(--link); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] button,
[data-theme="dark"] .ui-state-default,
[data-theme="dark"] .ui-widget-content .ui-state-default,
[data-theme="dark"] .ui-widget-header .ui-state-default,
[data-theme="dark"] .ui-button {
    background: #263449;
    color: var(--text);
    border-color: #94a3b8;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--muted); opacity: 1; }
[data-theme="dark"] .ui-state-default a { color: var(--link); }
[data-theme="dark"] .ui-state-hover,
[data-theme="dark"] .ui-widget-content .ui-state-hover,
[data-theme="dark"] .ui-widget-header .ui-state-hover,
[data-theme="dark"] .ui-state-focus,
[data-theme="dark"] .ui-button:hover,
[data-theme="dark"] .ui-button:focus {
    background: var(--hover);
    color: var(--hover-text);
    border-color: #93c5fd;
}
[data-theme="dark"] .ui-state-active,
[data-theme="dark"] .ui-widget-content .ui-state-active,
[data-theme="dark"] .ui-widget-header .ui-state-active {
    background: #334e76;
    color: #ffffff;
    border-color: #93c5fd;
}
[data-theme="dark"] .ui-state-active a,
[data-theme="dark"] .ui-state-hover a,
[data-theme="dark"] .ui-state-focus a { color: #ffffff; }
[data-theme="dark"] .ui-state-highlight,
[data-theme="dark"] .ui-widget-content .ui-state-highlight,
[data-theme="dark"] .ui-state-checked {
    background: var(--hover);
    color: var(--hover-text);
    border-color: var(--link);
}
[data-theme="dark"] .ui-state-highlight a,
[data-theme="dark"] .ui-widget-content .ui-state-highlight a { color: var(--hover-text); }
[data-theme="dark"] .ui-state-error,
[data-theme="dark"] .ui-widget-content .ui-state-error,
[data-theme="dark"] .ui-widget-header .ui-state-error {
    background: #4b202b;
    color: #fecdd3;
    border-color: #fb7185;
}
[data-theme="dark"] .ui-state-error a,
[data-theme="dark"] .ui-state-error-text { color: #fecdd3; }
[data-theme="dark"] :focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
[data-theme="dark"] .ui-widget-overlay { background: #000; opacity: .65; }
[data-theme="dark"] .ui-icon,
[data-theme="dark"] .ui-state-default .ui-icon,
[data-theme="dark"] .ui-state-hover .ui-icon,
[data-theme="dark"] .ui-state-active .ui-icon,
[data-theme="dark"] .ui-state-focus .ui-icon,
[data-theme="dark"] .ui-button .ui-icon { background-image: url('../img/ui-icons_ffffff_256x240.png'); }
[data-theme="dark"] .blue { background: #1e2751 url('../img/background2.jpg') center center; }
[data-theme="dark"] .gray { background: #334155; border-color: #475569 !important; }
[data-theme="dark"] .orange,
[data-theme="dark"] #tabs > ul { background: #7c351b; border-color: #b66a39 !important; }
[data-theme="dark"] .listado .green { color: var(--success); }
[data-theme="dark"] .listado .red { color: var(--danger); }
[data-theme="dark"] .listado .orange { background: transparent; color: var(--caution) !important; }

[data-theme="dark"] .select2-container--default .select2-selection--single,
[data-theme="dark"] .login .select2-container,
[data-theme="dark"] .select2-container--default .select2-selection--multiple,
[data-theme="dark"] .select2-dropdown,
[data-theme="dark"] .select2-search__field {
    background: #263449;
    color: var(--text);
    border-color: #94a3b8;
}
[data-theme="dark"] .select2-container--default .select2-selection__rendered,
[data-theme="dark"] .select2-container--default .select2-results > .select2-results__options { color: var(--text); }
[data-theme="dark"] .select2-container--default .select2-selection__placeholder { color: var(--muted); }
[data-theme="dark"] .select2-container--default .select2-selection__choice,
[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] { background: #334768; color: #ffffff; }
[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] { background: #3d5e8a; color: #ffffff; }
[data-theme="dark"] .select2-container--default .select2-selection__arrow b { border-top-color: #e5e7eb; }
[data-theme="dark"] .select2-container--default .select2-selection__choice__remove { color: var(--text); }

[data-theme="dark"][data-dark-palette="graphite"] input,
[data-theme="dark"][data-dark-palette="graphite"] select,
[data-theme="dark"][data-dark-palette="graphite"] textarea,
[data-theme="dark"][data-dark-palette="graphite"] button,
[data-theme="dark"][data-dark-palette="graphite"] .ui-state-default,
[data-theme="dark"][data-dark-palette="graphite"] .ui-button,
[data-theme="dark"][data-dark-palette="graphite"] .select2-container--default .select2-selection--single,
[data-theme="dark"][data-dark-palette="graphite"] .login .select2-container,
[data-theme="dark"][data-dark-palette="graphite"] .select2-container--default .select2-selection--multiple,
[data-theme="dark"][data-dark-palette="graphite"] .select2-dropdown,
[data-theme="dark"][data-dark-palette="graphite"] .select2-search__field { background: #303033; border-color: #71717a; }
[data-theme="dark"][data-dark-palette="graphite"] .ui-state-hover,
[data-theme="dark"][data-dark-palette="graphite"] .ui-state-focus,
[data-theme="dark"][data-dark-palette="graphite"] .ui-button:hover,
[data-theme="dark"][data-dark-palette="graphite"] .ui-button:focus { background: #3f3f46; border-color: #a1a1aa; }
[data-theme="dark"][data-dark-palette="graphite"] .ui-state-active { background: #48484f; border-color: #a1a1aa; }
[data-theme="dark"][data-dark-palette="graphite"] .gray { background: #3f3f46; border-color: #52525b !important; }
[data-theme="dark"][data-dark-palette="graphite"] .blue {
    background-color: #34343a;
    background-blend-mode: luminosity;
    border-color: #52525b !important;
}
[data-theme="dark"][data-dark-palette="graphite"] .select2-container--default .select2-selection__choice,
[data-theme="dark"][data-dark-palette="graphite"] .select2-container--default .select2-results__option[aria-selected="true"] { background: #3f3f46; }
[data-theme="dark"][data-dark-palette="graphite"] .select2-container--default .select2-results__option--highlighted[aria-selected] { background: #52525b; }
[data-theme="dark"][data-dark-palette="graphite"] .content2 a:hover,
[data-theme="dark"][data-dark-palette="graphite"] .content2 a:focus-visible,
[data-theme="dark"][data-dark-palette="graphite"] .menu2 a:hover,
[data-theme="dark"][data-dark-palette="graphite"] .menu2 a:focus-visible {
    color: #f8fafc;
    text-decoration: underline;
}

/* Weather status colors retain their meaning. Photographs are never filtered. */
[data-theme="dark"] #weather-data .green { background: #166534; }
[data-theme="dark"] #weather-data .red { background: #991b1b; }
[data-theme="dark"] #weather-data .orange,
[data-theme="dark"] #weather-data .meteoorange { background: #854d0e; }
[data-theme="dark"] .hljs { background: var(--surface); color: var(--text); }
[data-theme="dark"] .hljs-comment,
[data-theme="dark"] .hljs-quote { color: var(--muted); }
[data-theme="dark"] .hljs-keyword,
[data-theme="dark"] .hljs-selector-tag,
[data-theme="dark"] .hljs-literal,
[data-theme="dark"] .hljs-number { color: #c4b5fd; }
[data-theme="dark"] .hljs-string,
[data-theme="dark"] .hljs-doctag { color: #86efac; }
[data-theme="dark"] .hljs-title,
[data-theme="dark"] .hljs-section,
[data-theme="dark"] .hljs-built_in,
[data-theme="dark"] .hljs-name,
[data-theme="dark"] .hljs-attr { color: #93c5fd; }
[data-theme="dark"] .bk-root .bk-toolbar,
[data-theme="dark"] .bk-root .bk-toolbar-button { background-color: var(--surface); }
[data-theme="dark"] .bk-root .bk-toolbar-button:hover { background-color: var(--hover); }
[data-theme="dark"] .bk-root .bk-toolbar-button > .bk { filter: brightness(0) invert(1); }
[data-theme="dark"] .bk-root .bk-tooltip { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .bk-root .bk-tooltip-row-label,
[data-theme="dark"] .bk-root .bk-tooltip-row-value { color: var(--text); }

@media print {
    .theme-selector, .content-theme-selector { display: none !important; }
    .content2b, .menu2b { height: auto; overflow: visible; }
    body, .content, .content2, .menu2, .ui-widget-content { background: #fff !important; color: #000 !important; }
    .content h2, .content h3, .content h4, .content2 a, .menu2 a { color: #000 !important; }
}
