/* Theme values are shared with the admin sign-in page. Light mode retains admin-ui.css. */
html[data-admin-theme] {
    --admin-bg: #f4f7f5;
    --admin-surface: #ffffff;
    --admin-surface-raised: #f8faf9;
    --admin-input-bg: #ffffff;
    --admin-text: #263d31;
    --admin-muted: #687b71;
    --admin-border: #e2e9e5;
    --admin-accent: #147d51;
    --admin-hover: #edf5ef;
    color-scheme: light;
}
html[data-admin-theme='dark'] {
    --admin-bg: #0e1915;
    --admin-surface: #17271f;
    --admin-surface-raised: #1d3026;
    --admin-input-bg: #102018;
    --admin-text: #e1ede5;
    --admin-muted: #a1b7aa;
    --admin-border: #30473b;
    --admin-accent: #83d8ac;
    --admin-hover: #263e30;
    color-scheme: dark;
    background: var(--admin-bg);
}
[data-admin-theme-toggle] {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-width: 40px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--admin-border);
    border-radius: 9px; background: var(--admin-surface); color: var(--admin-text); cursor: pointer;
}
[data-admin-theme-toggle]:hover { background: var(--admin-hover); }
[data-admin-theme-toggle]:focus-visible { outline: 3px solid #dc9c38; outline-offset: 3px; }
[data-admin-theme-toggle] [data-admin-theme-icon] { width: 18px; text-align: center; }
.admin-ui .main-header [data-admin-theme-toggle] { height: 40px; margin: 2px 4px; }

/* Shell, navigation, and content surfaces. */
html[data-admin-theme='dark'] body.admin-ui {
    --admin-border: #30473b;
    --admin-muted: #a1b7aa;
    background: var(--admin-bg); color: var(--admin-text);
}
html[data-admin-theme='dark'] .admin-ui .content-wrapper,
html[data-admin-theme='dark'] .admin-auth { background: var(--admin-bg); color: var(--admin-text); }
html[data-admin-theme='dark'] body.admin-ui nav.main-header.admin-dashboard-top,
html[data-admin-theme='dark'] .admin-ui .main-footer { background: var(--admin-surface); border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .main-header.navbar-light .navbar-nav .nav-link { color: var(--admin-text) !important; }
html[data-admin-theme='dark'] .admin-ui .main-header .nav-link:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .admin-dashboard-sidebar { background: #102e20; }
html[data-admin-theme='dark'] .admin-ui .main-footer a,
html[data-admin-theme='dark'] .admin-ui .content-header .breadcrumb a { color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-footer-brand,
html[data-admin-theme='dark'] .admin-ui .breadcrumb-item.active,
html[data-admin-theme='dark'] .admin-ui .breadcrumb-item + .breadcrumb-item::before { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .card,
html[data-admin-theme='dark'] .admin-ui .info-box,
html[data-admin-theme='dark'] .admin-ui .modal-content,
html[data-admin-theme='dark'] .admin-ui .dropdown-menu,
html[data-admin-theme='dark'] .admin-ui .list-group-item,
html[data-admin-theme='dark'] .admin-ui .popover,
html[data-admin-theme='dark'] .admin-ui .toast { background: var(--admin-surface); color: var(--admin-text); border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .card,
html[data-admin-theme='dark'] .admin-ui .small-box { box-shadow: 0 3px 18px #00000025; }
html[data-admin-theme='dark'] .admin-ui .card-header,
html[data-admin-theme='dark'] .admin-ui .card-footer,
html[data-admin-theme='dark'] .admin-ui .modal-header,
html[data-admin-theme='dark'] .admin-ui .modal-footer,
html[data-admin-theme='dark'] .admin-ui .popover-header,
html[data-admin-theme='dark'] .admin-ui .toast-header { border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .card-footer,
html[data-admin-theme='dark'] .admin-ui .modal-header,
html[data-admin-theme='dark'] .admin-ui .popover-header,
html[data-admin-theme='dark'] .admin-ui .toast-header { background: var(--admin-surface-raised); color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .popover-body { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .bg-white,
html[data-admin-theme='dark'] .admin-ui .bg-light { background: var(--admin-surface-raised) !important; color: var(--admin-text) !important; }
html[data-admin-theme='dark'] .admin-ui .text-dark,
html[data-admin-theme='dark'] .admin-ui .text-body { color: var(--admin-text) !important; }
html[data-admin-theme='dark'] .admin-ui .text-muted,
html[data-admin-theme='dark'] .admin-ui .text-secondary { color: var(--admin-muted) !important; }
html[data-admin-theme='dark'] .admin-ui .text-primary,
html[data-admin-theme='dark'] .admin-ui .text-success { color: var(--admin-accent) !important; }
html[data-admin-theme='dark'] .admin-ui .text-danger { color: #ff9b9b !important; }
html[data-admin-theme='dark'] .admin-ui .text-info,
html[data-admin-theme='dark'] .admin-ui .text-navy { color: #8bcfe4 !important; }
html[data-admin-theme='dark'] .admin-ui .text-maroon { color: #f39fbe !important; }
html[data-admin-theme='dark'] .admin-ui .border,
html[data-admin-theme='dark'] .admin-ui .border-top,
html[data-admin-theme='dark'] .admin-ui .border-bottom,
html[data-admin-theme='dark'] .admin-ui .border-left,
html[data-admin-theme='dark'] .admin-ui .border-right { border-color: var(--admin-border) !important; }
html[data-admin-theme='dark'] .admin-ui hr { border-color: var(--admin-border); }

/* Inputs, filters, validation, and editor controls. */
html[data-admin-theme='dark'] .admin-ui label:not(.form-check-label):not(.custom-file-label) { color: #c1d7c9; }
html[data-admin-theme='dark'] .admin-ui .form-control,
html[data-admin-theme='dark'] .admin-ui .custom-select,
html[data-admin-theme='dark'] .admin-ui .custom-file-label,
html[data-admin-theme='dark'] .admin-ui .select2-search__field {
    background-color: var(--admin-input-bg); color: var(--admin-text); border-color: #415c4c;
}
html[data-admin-theme='dark'] .admin-ui .form-control::placeholder { color: #93ad9e; opacity: 1; }
html[data-admin-theme='dark'] .admin-ui .form-control:focus,
html[data-admin-theme='dark'] .admin-ui .custom-select:focus { border-color: #80c49d; box-shadow: 0 0 0 3px #83d8ac20; }
html[data-admin-theme='dark'] .admin-ui .form-control:disabled,
html[data-admin-theme='dark'] .admin-ui .form-control[readonly],
html[data-admin-theme='dark'] .admin-ui .custom-select:disabled,
html[data-admin-theme='dark'] .admin-ui .input-group-text,
html[data-admin-theme='dark'] .admin-ui .custom-file-label::after { background: var(--admin-surface-raised); color: var(--admin-muted); border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .custom-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23c1d7c9' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E");
}
html[data-admin-theme='dark'] .admin-ui .custom-control-label::before { background-color: var(--admin-input-bg); border-color: #789985; }
html[data-admin-theme='dark'] .admin-ui .custom-control-input:checked ~ .custom-control-label::before { background-color: #147d51; border-color: #6cbb8d; }
html[data-admin-theme='dark'] .admin-ui input[type='checkbox'],
html[data-admin-theme='dark'] .admin-ui input[type='radio'] { accent-color: #42a773; }
html[data-admin-theme='dark'] .admin-ui .form-control.is-invalid,
html[data-admin-theme='dark'] .admin-ui .was-validated .form-control:invalid { border-color: #f58c95; }
html[data-admin-theme='dark'] .admin-ui .invalid-feedback { color: #ff9b9b; }
html[data-admin-theme='dark'] .admin-ui .valid-feedback { color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .btn-secondary,
html[data-admin-theme='dark'] .admin-ui .btn-default,
html[data-admin-theme='dark'] .admin-ui .btn-light { background: var(--admin-surface-raised); border-color: #415c4c; color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .btn-secondary:hover,
html[data-admin-theme='dark'] .admin-ui .btn-default:hover,
html[data-admin-theme='dark'] .admin-ui .btn-light:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .btn-outline-primary,
html[data-admin-theme='dark'] .admin-ui .btn-outline-success { border-color: #4a8b65; color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .btn-outline-secondary { color: #cfddd4; border-color: #658471; }
html[data-admin-theme='dark'] .admin-ui .btn-outline-danger { color: #ffaaaa; border-color: #c16a73; }
html[data-admin-theme='dark'] .admin-ui .btn-outline-primary:hover,
html[data-admin-theme='dark'] .admin-ui .btn-outline-success:hover,
html[data-admin-theme='dark'] .admin-ui .btn-outline-danger:hover { color: #fff; }
html[data-admin-theme='dark'] .admin-ui .btn-link { color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .nav-tabs { border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .nav-tabs .nav-link { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .nav-tabs .nav-link.active,
html[data-admin-theme='dark'] .admin-ui .nav-tabs .nav-link:hover { color: var(--admin-text); background: var(--admin-surface); border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .note-editor.note-frame,
html[data-admin-theme='dark'] .admin-ui .note-editor .note-editing-area .note-editable { background: var(--admin-input-bg); color: var(--admin-text); border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .note-toolbar,
html[data-admin-theme='dark'] .admin-ui .note-statusbar { background: var(--admin-surface-raised); border-color: var(--admin-border); }

/* Tables and DataTables menus. Preserve the green header and sizing-only hidden header. */
html[data-admin-theme='dark'] .admin-ui .table { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .table td,
html[data-admin-theme='dark'] .admin-ui .table-bordered,
html[data-admin-theme='dark'] .admin-ui .table-bordered th,
html[data-admin-theme='dark'] .admin-ui .dataTables_scroll { border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .table-striped tbody tr:nth-of-type(odd) { background: #1b2d23; }
html[data-admin-theme='dark'] .admin-ui .table tbody tr:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .table td a:not(.btn):not(.badge) { color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .dataTables_processing { background: var(--admin-surface); color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .dataTables_scrollBody { scrollbar-color: #4c6b59 transparent; }
html[data-admin-theme='dark'] .admin-ui .dataTables_scrollBody::-webkit-scrollbar-thumb { background: #4c6b59; }
html[data-admin-theme='dark'] .admin-ui .page-link { background: var(--admin-surface); border-color: #415c4c; color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .page-link:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .page-item.active .page-link { background: #147d51; border-color: #147d51; color: #fff; }
html[data-admin-theme='dark'] .admin-ui .page-item.disabled .page-link { background: var(--admin-surface-raised); border-color: var(--admin-border); color: #91a799; }
html[data-admin-theme='dark'] .admin-ui div.dt-button-collection { background: var(--admin-surface); }
html[data-admin-theme='dark'] .admin-ui div.dt-button-collection .dropdown-item { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui div.dt-button-collection .dropdown-item.active { background: transparent; color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui div.dt-button-collection .dropdown-item::before { border-color: #789985; background-color: var(--admin-input-bg); }
html[data-admin-theme='dark'] .admin-ui div.dt-button-collection .dropdown-item.active::before { background-color: #147d51; border-color: #68b58a; }
html[data-admin-theme='dark'] .admin-ui div.dt-button-collection .dropdown-item:hover { background: var(--admin-hover); }

/* Select2 is appended to the body, including selections opened from a modal. */
html[data-admin-theme='dark'] .admin-ui .select2-container .select2-selection,
html[data-admin-theme='dark'] .admin-ui .select2-dropdown { background: var(--admin-input-bg); color: var(--admin-text); border-color: #415c4c; }
html[data-admin-theme='dark'] .admin-ui .select2-container .select2-selection__rendered { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .select2-container .select2-selection__placeholder { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .select2-container--default .select2-selection--multiple .select2-selection__choice { background: #294b35; color: #d5f0df; border-color: #477754; }
html[data-admin-theme='dark'] .admin-ui .select2-container--default .select2-selection--multiple .select2-selection__choice__remove,
html[data-admin-theme='dark'] .admin-ui .select2-selection__clear { color: #d5f0df; }
html[data-admin-theme='dark'] .admin-ui .select2-container--default .select2-results__option[aria-selected='true'] { background: #294b35; }
html[data-admin-theme='dark'] .admin-ui .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-admin-theme='dark'] .admin-ui .select2-container--bootstrap4 .select2-results__option--highlighted { background: #147d51; color: #fff; }
html[data-admin-theme='dark'] .admin-ui .select2-container--default.select2-container--disabled .select2-selection { background: var(--admin-surface-raised); }
html[data-admin-theme='dark'] .admin-ui .select2-container--default .select2-selection__arrow b { border-top-color: #c1d7c9; }
html[data-admin-theme='dark'] .admin-ui .select2-container--open .select2-selection__arrow b { border-bottom-color: #c1d7c9; }

/* Dialogs, notifications, account menu, and feedback. */
html[data-admin-theme='dark'] .admin-ui .close,
html[data-admin-theme='dark'] .admin-ui .modal-header .close { color: #e1ede5; text-shadow: none; }
html[data-admin-theme='dark'] .admin-ui .modal-header .close:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .dropdown-item,
html[data-admin-theme='dark'] .admin-ui .admin-profile-menu .dropdown-item { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .dropdown-item:hover,
html[data-admin-theme='dark'] .admin-ui .dropdown-item:focus,
html[data-admin-theme='dark'] .admin-ui .admin-profile-menu .dropdown-item:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .dropdown-divider { border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui .dropdown-header { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .dropdown-footer,
html[data-admin-theme='dark'] .admin-ui .admin-profile-menu .dropdown-item i,
html[data-admin-theme='dark'] .admin-ui .admin-notification-empty i { color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-profile-head strong { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .admin-profile-head small { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .admin-profile-menu .admin-logout,
html[data-admin-theme='dark'] .admin-ui .admin-profile-menu .admin-logout i { color: #ffaaaa; }
html[data-admin-theme='dark'] .admin-ui .admin-avatar { border-color: #415c4c; background: var(--admin-surface-raised); }
html[data-admin-theme='dark'] .admin-ui .badge-light { background: #2d4636; color: #deeee3; }
html[data-admin-theme='dark'] .admin-ui .alert-success { background: #183f2a; border-color: #3c7553; color: #b9edca; }
html[data-admin-theme='dark'] .admin-ui .alert-danger { background: #47272c; border-color: #83515b; color: #ffd0d0; }
html[data-admin-theme='dark'] .admin-ui .alert-warning { background: #42391e; border-color: #7f6c37; color: #f5e4ac; }
html[data-admin-theme='dark'] .admin-ui .alert-info { background: #183a42; border-color: #386c7b; color: #bde7f2; }
html[data-admin-theme='dark'] .admin-ui .alert-light,
html[data-admin-theme='dark'] .admin-ui .alert-secondary { background: var(--admin-surface-raised); border-color: #415c4c; color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .alert .alert-link { color: inherit; }
html[data-admin-theme='dark'] .admin-ui .swal2-popup { background: var(--admin-surface); color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .swal2-title,
html[data-admin-theme='dark'] .admin-ui .swal2-content,
html[data-admin-theme='dark'] .admin-ui .swal2-html-container { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .swal2-input,
html[data-admin-theme='dark'] .admin-ui .swal2-textarea { background: var(--admin-input-bg); color: var(--admin-text); border-color: #415c4c; }

/* Shared tools: loader, export options, upload preview, and image viewer. */
html[data-admin-theme='dark'] .admin-ui .admin-loading-overlay { background: #0e1915d9; color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .admin-spinner { border-color: #304e3b; border-top-color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-export-option,
html[data-admin-theme='dark'] .admin-ui .admin-upload { background: var(--admin-input-bg); border-color: #415c4c; }
html[data-admin-theme='dark'] .admin-ui .admin-export-option strong,
html[data-admin-theme='dark'] .admin-ui .admin-upload-name { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .admin-export-option small,
html[data-admin-theme='dark'] .admin-ui .admin-export-label,
html[data-admin-theme='dark'] .admin-ui .admin-export-note,
html[data-admin-theme='dark'] .admin-ui .admin-upload-detail { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .admin-export-option i { color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-export-option[data-type='pdf'] i { color: #ff9b9b; }
html[data-admin-theme='dark'] .admin-ui .admin-export-option[data-type='csv'] i { color: #8bd6dd; }
html[data-admin-theme='dark'] .admin-ui .admin-export-option:hover:not(:disabled),
html[data-admin-theme='dark'] .admin-ui .admin-export-option:focus-visible,
html[data-admin-theme='dark'] .admin-ui .admin-export-option.is-busy { border-color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-upload:hover,
html[data-admin-theme='dark'] .admin-ui .admin-upload.is-dragover,
html[data-admin-theme='dark'] .admin-ui .admin-upload:focus-within { background: var(--admin-surface-raised); border-color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-upload-preview { background: #294b35; color: var(--admin-accent); }
html[data-admin-theme='dark'] .admin-ui .admin-upload-clear { color: #ffaaaa; }
html[data-admin-theme='dark'] .admin-ui img.img-missing { background: var(--admin-surface-raised); }
html[data-admin-theme='dark'] .admin-ui .admin-image-modal .modal-body { background: #08110c; }

/* Dashboard card content and chat, without changing the established statistic card palette. */
html[data-admin-theme='dark'] .admin-ui .admin-chart-range,
html[data-admin-theme='dark'] .admin-ui .admin-activity small,
html[data-admin-theme='dark'] .admin-ui .admin-activity span { color: var(--admin-muted); }
html[data-admin-theme='dark'] .admin-ui .admin-attention a,
html[data-admin-theme='dark'] .admin-ui .admin-activity strong { color: var(--admin-text); }
html[data-admin-theme='dark'] .admin-ui .admin-attention li,
html[data-admin-theme='dark'] .admin-ui .admin-activity li { border-color: var(--admin-border); }
html[data-admin-theme='dark'] .admin-ui #chat-box { background: var(--admin-input-bg) !important; }
html[data-admin-theme='dark'] .admin-ui .list-group-item-action:hover { background: var(--admin-hover); }
html[data-admin-theme='dark'] .admin-ui .list-group-item.active { background: #175b3d; border-color: #4a8b65; color: #fff; }

@media print {
    html[data-admin-theme='dark'] { color-scheme: light; background: #fff; }
    html[data-admin-theme='dark'] body.admin-ui,
    html[data-admin-theme='dark'] .admin-ui .content-wrapper,
    html[data-admin-theme='dark'] .admin-ui .card,
    html[data-admin-theme='dark'] .admin-ui .table,
    html[data-admin-theme='dark'] .admin-ui .table tr,
    html[data-admin-theme='dark'] .admin-ui .table td { background: #fff !important; color: #111 !important; }
    [data-admin-theme-toggle] { display: none !important; }
}
