.cosmos-theme-switcher {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: .5rem 1.5rem;
}
.cosmos-theme-options { display: inline-flex; align-items: center; gap: 4px; }
.cosmos-theme-button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: .35rem;
    color: #66758a;
    background: transparent;
    font-size: 1.15rem;
    box-shadow: none;
}
.cosmos-theme-button.btn:hover,
.cosmos-theme-button.btn[aria-pressed="true"] { color: #5c46ba; background: #ece8fa; }
.cosmos-theme-button.btn:focus-visible { outline: 2px solid #6550c7; outline-offset: 2px; }
.cosmos-theme-error:not([hidden]) {
    max-width: 12rem;
    margin-top: .5rem;
    padding: .5rem;
    background: #fff0f0;
    color: #842029;
    border: 1px solid #842029;
    border-radius: .25rem;
}

@media (max-width: 991.98px) {
    .app-header .navbar-brand {
        position: static;
        left: auto;
        flex: 1;
        min-width: 0;
        width: auto;
        margin: 0;
        padding: 0;
        justify-content: flex-start;
        overflow: hidden;
        font-size: .9rem;
    }
    .app-header .navbar-brand .cosmos-version { display: none; }
}
@media screen {
    html[data-cosmos-theme="dark"] {
        --cosmos-page: #111827;
        --cosmos-surface: #1f2937;
        --cosmos-raised: #293548;
        --cosmos-border: #526078;
        --cosmos-text: #e5eaf3;
        --cosmos-muted: #b4c0d2;
        --cosmos-link: #b5a7ff;
        background: var(--cosmos-page);
    }
    [data-cosmos-theme="dark"] body,
    [data-cosmos-theme="dark"] .app-body,
    [data-cosmos-theme="dark"] main.main {
        background: var(--cosmos-page);
        color: var(--cosmos-text);
    }
    [data-cosmos-theme="dark"] :is(.app-header, .app-footer, .sidebar, .card,
        .modal-content, .dropdown-menu, .list-group-item, .popover, .breadcrumb,
        .select2-dropdown, .select2-selection, .note-editor, .note-toolbar,
        .note-editable, .note-statusbar, .swal-modal) {
        background-color: var(--cosmos-surface);
        color: var(--cosmos-text);
        border-color: var(--cosmos-border);
    }
    [data-cosmos-theme="dark"] :is(.bg-white, .bg-light, .card-header,
        .card-footer, .table thead th, .table tfoot th) {
        background-color: var(--cosmos-surface) !important;
        color: var(--cosmos-text);
        border-color: var(--cosmos-border);
    }
    [data-cosmos-theme="dark"] :is(h1, h2, h3, h4, h5, h6, label,
        .navbar-brand, .card-title, .swal-title, .swal-text) {
        color: var(--cosmos-text);
    }
    [data-cosmos-theme="dark"] :is(a:not(.btn), .btn-link,
        .sidebar .nav-link, .dropdown-item, .breadcrumb-item a) {
        color: var(--cosmos-link);
    }
    [data-cosmos-theme="dark"] :is(.text-muted, .text-secondary,
        .form-text, small.text-muted, .breadcrumb-item.active) {
        color: var(--cosmos-muted) !important;
    }
    [data-cosmos-theme="dark"] .text-dark { color: var(--cosmos-text) !important; }
    [data-cosmos-theme="dark"] .app-header .navbar-brand {
        color: var(--cosmos-text);
    }
    [data-cosmos-theme="dark"] .sidebar .nav-title {
        color: var(--cosmos-muted) !important;
    }
    [data-cosmos-theme="dark"] .sidebar .nav .nav-link {
        color: var(--cosmos-link);
    }
    [data-cosmos-theme="dark"] :is(.form-control, .custom-select,
        .input-group-text,
        .dataTables_wrapper input, .dataTables_wrapper select) {
        background-color: var(--cosmos-page);
        color: var(--cosmos-text);
        border-color: var(--cosmos-border);
        color-scheme: dark;
    }
    [data-cosmos-theme="dark"] :is(input, textarea)::placeholder {
        color: var(--cosmos-muted);
        opacity: 1;
    }
    [data-cosmos-theme="dark"] :is(.form-control:disabled,
        .form-control[readonly], .page-item.disabled .page-link) {
        background-color: var(--cosmos-raised);
        color: var(--cosmos-muted);
    }
    [data-cosmos-theme="dark"] :is(.form-control, .custom-select,
        .cosmos-theme-button):focus-visible {
        outline: 2px solid var(--cosmos-link);
        outline-offset: 2px;
    }
    [data-cosmos-theme="dark"] .cosmos-theme-button.btn { color: var(--cosmos-muted); }
    [data-cosmos-theme="dark"] .cosmos-theme-button.btn:hover,
    [data-cosmos-theme="dark"] .cosmos-theme-button.btn[aria-pressed="true"] {
        color: var(--cosmos-link);
        background: var(--cosmos-raised);
    }
    [data-cosmos-theme="dark"] .table {
        color: var(--cosmos-text);
        background-color: var(--cosmos-surface);
    }
    [data-cosmos-theme="dark"] :is(.table td, .table th, .modal-header,
        .modal-footer, .dropdown-divider, .border, hr) {
        border-color: var(--cosmos-border) !important;
    }
    [data-cosmos-theme="dark"] :is(.table-striped tbody tr:nth-of-type(odd),
        .table-hover tbody tr:hover, .dropdown-item:hover, .dropdown-item:focus,
        .sidebar .nav-link:hover, .list-group-item-action:hover,
        .select2-results__option--highlighted) {
        background-color: var(--cosmos-raised);
        color: var(--cosmos-text);
    }
    [data-cosmos-theme="dark"] .page-link {
        background-color: var(--cosmos-surface);
        color: var(--cosmos-link);
        border-color: var(--cosmos-border);
    }
    [data-cosmos-theme="dark"] .page-item.active .page-link {
        background-color: #6550c7;
        color: #fff;
    }
    [data-cosmos-theme="dark"] :is(.btn-light, .btn-secondary, .note-btn) {
        background-color: var(--cosmos-raised);
        color: var(--cosmos-text);
        border-color: var(--cosmos-border);
    }
    [data-cosmos-theme="dark"] .alert-info {
        background: #15394c;
        color: #c4efff;
        border-color: #4083a1;
    }
    [data-cosmos-theme="dark"] .alert-warning {
        background: #493916;
        color: #ffe5a0;
        border-color: #a78331;
    }
    [data-cosmos-theme="dark"] .alert-danger {
        background: #491f2d;
        color: #ffd4df;
        border-color: #b8627b;
    }
    [data-cosmos-theme="dark"] .alert-success {
        background: #173c30;
        color: #c5f2dc;
        border-color: #4c9c79;
    }
}

@media print {
    :root { color-scheme: light !important; }
    .cosmos-theme-switcher { display: none !important; }
}
