/* Light mode retains the existing application styling. */
.test-session-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 24px; margin-left: 60px; background: #fff3cd; color: #594512; border-bottom: 1px solid #d8bc64; }
.test-session-banner form { margin: 0; }
.test-account-option { display: flex !important; align-items: center; gap: 8px; margin: 16px 0; }
.test-account-option input[type="checkbox"] { width: auto !important; margin: 0 !important; flex: 0 0 auto; }
html[data-theme="dark"] .test-session-banner { background: #413a20; color: #ffe4a0; border-color: #9e8441; }
button.theme-toggle {
    display: inline-grid !important;
    place-items: center;
    flex: 0 0 52px;
    width: 52px;
    min-width: 52px;
    height: 52px;
    padding: 0 !important;
    border: 1px solid #cbd5df !important;
    border-radius: 8px;
    background: rgba(255, 255, 255, .78) !important;
    color: #405263 !important;
    box-shadow: 0 6px 18px rgba(31, 45, 58, .08) !important;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
button.theme-toggle:hover {
    background: #edf2f4 !important;
    border-color: #778da9 !important;
    transform: translateY(-2px);
}
button.theme-toggle:focus-visible {
    outline: 3px solid #778da9 !important;
    outline-offset: 3px;
}
.theme-icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
.auth-theme-toggle { position: fixed; top: 18px; right: 18px; z-index: 1500; }

html[data-theme="dark"] {
    color-scheme: dark;
    --theme-page: #151b18;
    --theme-panel: #202823;
    --theme-soft: #29332d;
    --theme-line: #435047;
    --theme-text: #e7ece8;
    --theme-muted: #b4c0b8;
    --ui-text: #e7ece8;
    --ui-border-strong: #6f8276;
}
html[data-theme="dark"] body,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .login-shell,
html[data-theme="dark"] .login-panel {
    background: var(--theme-page) !important;
    color: var(--theme-text) !important;
}
html[data-theme="dark"] :is(.header, .sidebar) {
    background: #252e29 !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-line) !important;
}
html[data-theme="dark"] :is(.header-eyebrow, .header-title, .header-user-name, .login-brand-title) { color: var(--theme-text) !important; }
html[data-theme="dark"] :is(.header-user-detail, .header-brand-subtitle, .login-brand-subtitle, .sidebar-header) { color: var(--theme-muted) !important; }
html[data-theme="dark"] :is(.header-user-card, .notif-dropdown, .notif-item, .breadcrumb, .global-breadcrumb-list, .global-breadcrumb-item a, .global-breadcrumb-item span) {
    background: var(--theme-panel) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-line) !important;
}
html[data-theme="dark"] button.theme-toggle { background: var(--theme-panel) !important; color: var(--theme-text) !important; border-color: var(--theme-line) !important; }
html[data-theme="dark"] button.theme-toggle:hover { background: var(--theme-soft) !important; border-color: #778da9 !important; }
html[data-theme="dark"] #pageHeader button.theme-toggle { background: var(--theme-panel) !important; color: var(--theme-text) !important; }
html[data-theme="dark"] body .main-content input[type="search"] { background: #18211b !important; color: var(--theme-text) !important; }
html[data-theme="dark"] .muted { color: var(--theme-muted) !important; }
html[data-theme="dark"] .sidebar .menu-link { color: var(--theme-muted) !important; }
html[data-theme="dark"] .sidebar .menu-link:is(:hover, .active) { color: var(--theme-text) !important; background: var(--theme-soft) !important; border-color: var(--theme-line) !important; }
html[data-theme="dark"] .sidebar-icon { filter: brightness(0) invert(1); }
html[data-theme="dark"] :is(.card, .form-card, .section-card, .upload-card, .container, .login-card, .login-brand, .tracking-detail-panel, .modal-content, .modal-box, .popup-content, .task-accordion-item, .task-body, .task-pane, .notes-history-block, .chat-box, .msg, .message-card, .activity-item, .tile, .farm-filter-panel, .farm-drawer-panel, .eudr-farm-drawer-panel, .eudr-toolbar, .filters, .filter-panel) {
    background: var(--theme-panel) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-line) !important;
}
html[data-theme="dark"] :is(h1, h2, h3, h4, h5, h6, label, .contract-info, .contract-info strong, .progress-title, .progress-title strong, .contract-progress-meta, .contract-progress-foot, .notes-text, .msg-meta, .task-title) { color: var(--theme-text) !important; }
html[data-theme="dark"] :is(.notes-meta, .msg-time, .contracts-year-subtext, .application-copy, .login-links, .farm-drawer-count, .notif-empty, .tracking-card p) { color: var(--theme-muted) !important; }
html[data-theme="dark"] :is(.login-links a, .main-content a:not(.btn):not(.menu-link):not(.file-slot)) { color: #b9d7a7; }
html[data-theme="dark"] :is(.table-scroll, table, tbody, td) { background: var(--theme-panel) !important; color: var(--theme-text) !important; border-color: var(--theme-line) !important; }
html[data-theme="dark"] th { background: #465e7b !important; color: #fff !important; border-color: #657a91 !important; }
html[data-theme="dark"] tbody tr:nth-child(even) td { background: #242e28 !important; }
html[data-theme="dark"] tbody tr:hover td { background: var(--theme-soft) !important; }
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]), select, textarea) {
    background: #18211b !important;
    color: var(--theme-text) !important;
    border-color: #617369 !important;
}
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #a9b7ae !important; opacity: 1; }
html[data-theme="dark"] :is(input, select, textarea):focus { border-color: #8bb86d !important; }
html[data-theme="dark"] :is(.outstanding-tab-list label, .contracts-tabs label, .tab-btn, .tab-button, .tab, .task-header, .task-accordion-header, .farm-drawer-tab, .eudr-farm-drawer-tab, .file-slot, .notes-entry, .activity-row, .progress-bar-wrap, .contract-progress-track) {
    background: var(--theme-soft) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-line) !important;
}
html[data-theme="dark"] :is(.outstanding-tab-count, .pill, .progress-percent, .contract-progress-percent) { background: #34492c !important; color: #d5edc9 !important; }
html[data-theme="dark"] .outstanding-tab-radio:checked + label,
html[data-theme="dark"] #outstanding-tab-active:checked ~ .outstanding-tab-list label[for="outstanding-tab-active"],
html[data-theme="dark"] #outstanding-tab-sailed:checked ~ .outstanding-tab-list label[for="outstanding-tab-sailed"],
html[data-theme="dark"] #outstanding-tab-documents:checked ~ .outstanding-tab-list label[for="outstanding-tab-documents"],
html[data-theme="dark"] #outstanding-tab-completed:checked ~ .outstanding-tab-list label[for="outstanding-tab-completed"] { background: #364a3c !important; border-color: #89ab73 !important; }
html[data-theme="dark"] .tracking-card.is-selected { background: #2b3b2a !important; border-color: #8bb86d !important; }
html[data-theme="dark"] :is(.notes-entry.is-latest, .notes-entry.latest, .notes-entry.notes-latest) { background: #443e23 !important; border-color: #aa9447 !important; }
html[data-theme="dark"] .priority-high-tile { background: #432a2d !important; }
html[data-theme="dark"] .priority-medium-tile { background: #3c3628 !important; }
html[data-theme="dark"] .priority-low-tile { background: #28392b !important; }
html[data-theme="dark"] :is(.alert-warning, .legacy-alerts .alert-warning) { background: #413a20 !important; color: #ffe4a0 !important; border-color: #9e8441 !important; }
html[data-theme="dark"] :is(.alert-danger, .legacy-alerts .alert-danger) { background: #452529 !important; color: #ffc2c8 !important; border-color: #98515b !important; }
html[data-theme="dark"] :is(.alert-success, .legacy-alerts .alert-success) { background: #243d2c !important; color: #c4edc9 !important; border-color: #527858 !important; }
html[data-theme="dark"] :is(.alert-info, .legacy-alerts .alert-info) { background: #243849 !important; color: #c3e0fc !important; border-color: #53799c !important; }
html[data-theme="dark"] :is(.leaflet-popup-content-wrapper, .leaflet-popup-tip, .leaflet-control-layers) { background: var(--theme-panel) !important; color: var(--theme-text) !important; }
html[data-theme="dark"] .leaflet-popup-content { color: var(--theme-text) !important; }
html[data-theme="dark"] .password-toggle { color: var(--theme-muted) !important; background: var(--theme-soft) !important; }
html[data-theme="dark"] :is(.login-brand, .login-card):hover { background: var(--theme-soft) !important; }
html[data-theme="dark"] :is(.file-slot-name, .file-slot-icon, .file-slot-download) { color: var(--theme-text) !important; }
html[data-theme="dark"] hr { border-color: var(--theme-line) !important; }
html[data-theme="dark"] :is(.table-scroll, .card, .sidebar, textarea) { scrollbar-color: #6a7f6e var(--theme-panel); }
@media (max-width: 768px) {
    #pageHeader .header-content {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "brand" "title" "actions";
        gap: 12px;
    }
    #pageHeader .header-actions { width: 100%; justify-content: center; }
    #pageHeader .header-left { width: 100%; min-width: 0; }
    #pageHeader .header-user-card { min-width: 0; flex: 1 1 auto; }
    button.theme-toggle { flex-basis: 40px; width: 40px; min-width: 40px; height: 40px; }
    .auth-theme-toggle { top: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    button.theme-toggle { transition: none; }
}
