/* =====================================================================
   App shell: sidebar, top bar and logo (light + dark mode).
   Loaded after main.css. Colours come only from the theme variables in
   main.css (:root / body.dark), so light and dark mode follow the theme.
   ===================================================================== */

:root {
    --shell-sidebar-w: 264px;
    --shell-sidebar-w-collapsed: 78px;
    --shell-topbar-h: 72px;
    --shell-gap: 28px;
    --shell-radius: 12px;
    --shell-ease: cubic-bezier(.4, 0, .2, 1);

    /* surfaces: white in light mode, deep navy in dark mode */
    --shell-surface: var(--header-bg);
    --shell-surface-glass: color-mix(in srgb, var(--header-bg) 86%, transparent);
    --shell-border: var(--border-color);
    --shell-text: var(--text-color);
    --shell-muted: var(--nav-icon-color);
    --shell-hover-bg: color-mix(in srgb, var(--text-color) 6%, transparent);
    --shell-active-bg: var(--primary-color-light);
    --shell-active-text: var(--primary-strong);  /* readable blue for text and icons */
    --shell-accent: var(--primary-color);
    --shell-on-accent: var(--active-text-color);
    --shell-shadow: 0 1px 2px color-mix(in srgb, var(--sidebar-color) 6%, transparent),
                    0 8px 24px color-mix(in srgb, var(--sidebar-color) 6%, transparent);
    --shell-backdrop: color-mix(in srgb, var(--sidebar-color) 55%, transparent);
}

/* ---------------------------------------------------------------- logo */
.brand-logo--dark,
.brand-mark {
    display: none !important;
}
body.dark .brand-logo--light {
    display: none !important;
}
body.dark .brand-logo--dark {
    display: block !important;
}

/* The logo lives at the top of the sidebar; the separate top-left logo box
   is only used on small screens (inside the top bar). */
html body #wrapper .admin-topbar__logo--collapsed.admin-logo-box {
    display: none !important;
}
html body #wrapper .admin-logo-box::before,
html body #wrapper .admin-logo-box::after,
html body #wrapper #nav-sidebar::before,
html body #wrapper #nav-sidebar::after {
    content: none !important;
    display: none !important;
}

/* ---------------------------------------------------------------- page frame */
html body #wrapper:not(.login) {
    padding: calc(var(--shell-topbar-h) + var(--shell-gap)) var(--shell-gap) var(--shell-gap) calc(var(--shell-sidebar-w) + var(--shell-gap)) !important;
    transition: padding .3s var(--shell-ease);
}
html body #wrapper:not(.login).wrapper-toggle {
    padding-left: calc(var(--shell-sidebar-w-collapsed) + var(--shell-gap)) !important;
}
html body #wrapper:not(.login) > #main {
    margin: 0 !important;
}

/* ---------------------------------------------------------------- sidebar */
html body #wrapper #nav-sidebar.sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: var(--shell-sidebar-w) !important;
    padding: 0 14px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--shell-surface) !important;
    border-right: 1px solid var(--shell-border) !important;
    box-shadow: none !important;
    overflow: hidden !important;
    z-index: 1002 !important;
    transition: width .3s var(--shell-ease), transform .3s var(--shell-ease) !important;
}

html body #wrapper #nav-sidebar .sidebar-logo.admin-logo-box {
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    width: auto !important;
    height: var(--shell-topbar-h) !important;
    min-height: var(--shell-topbar-h) !important;
    max-height: none !important;
    margin: 0 -14px 10px !important;
    padding: 0 22px !important;
    background: transparent !important;
    border: 0 !important;
    border-bottom: 1px solid var(--shell-border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    z-index: 1 !important;
}
html body #wrapper #nav-sidebar .sidebar-logo.admin-logo-box a {
    display: flex !important;
    align-items: center !important;
    max-width: none !important;
    width: auto !important;
}
html body #wrapper #nav-sidebar .sidebar-logo.admin-logo-box img.brand-logo {
    width: auto !important;
    height: 46px !important;
    max-height: 46px !important;
    max-width: 214px !important;
    object-fit: contain;
}
html body #wrapper #nav-sidebar .sidebar-logo.admin-logo-box img.brand-mark {
    width: 38px !important;
    height: 38px !important;
    max-height: 38px !important;
}

html body #wrapper #nav-sidebar .navbar-header {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
}
html body #wrapper #nav-sidebar .navbar-header > ul:first-child {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
    /* Theme colours, so the menu scroll bar matches light and dark mode */
    scrollbar-color: color-mix(in srgb, var(--shell-muted) 45%, transparent) transparent;
    margin: 0 !important;
    padding: 6px 0 0 !important;
}
html body #wrapper #nav-sidebar .navbar-header > ul:first-child::-webkit-scrollbar { width: 6px; }
html body #wrapper #nav-sidebar .navbar-header > ul:first-child::-webkit-scrollbar-track { background: transparent; }
html body #wrapper #nav-sidebar .navbar-header > ul:first-child::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--shell-muted) 45%, transparent);
    border-radius: 999px;
}
html body #wrapper #nav-sidebar .navbar-header > ul:first-child::before {
    content: "Menu";
    display: block;
    padding: 6px 12px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--shell-muted);
    opacity: .75;
}

html body #wrapper #nav-sidebar .navbar-header ul > li {
    margin: 0 0 4px !important;
    padding: 0 !important;
    height: auto !important;
    list-style: none !important;
    background: transparent !important;
    border: 0 !important;
    position: relative;
}
html body #wrapper #nav-sidebar .navbar-header ul > li > a {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    height: 46px !important;
    width: 100% !important;
    padding: 0 10px !important;
    margin: 0 !important;
    border-radius: var(--shell-radius) !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--shell-muted) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    transition: background-color .18s ease, color .18s ease !important;
}
html body #wrapper #nav-sidebar .navbar-header ul > li > a > i[class*="fa"] {
    flex: 0 0 34px !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    display: grid !important;
    place-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 10px !important;
    font-size: 16px !important;
    line-height: 1 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: inherit !important;
    transition: background-color .18s ease, color .18s ease !important;
}
html body #wrapper #nav-sidebar .navbar-header ul > li > a .text {
    display: inline-block !important;
    opacity: 1 !important;
    max-width: 180px !important;
    overflow: hidden !important;
    color: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    transition: opacity .2s ease, max-width .3s var(--shell-ease) !important;
}
html body #wrapper #nav-sidebar .navbar-header ul > li > a:hover {
    background: var(--shell-hover-bg) !important;
    color: var(--shell-text) !important;
}
html body #wrapper #nav-sidebar .navbar-header ul > li.active > a {
    background: var(--shell-active-bg) !important;
    color: var(--shell-active-text) !important;
    font-weight: 600 !important;
}
html body #wrapper #nav-sidebar .navbar-header ul > li.active > a > i[class*="fa"] {
    background: var(--shell-accent) !important;
    color: var(--shell-on-accent) !important;
    box-shadow: 0 6px 14px color-mix(in srgb, var(--primary-color) 35%, transparent) !important;
}
html body #wrapper #nav-sidebar .navbar-header ul > li.active > a::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--shell-accent);
}

/* ---------------------------------------------------------------- top bar */
html body #wrapper .admin-topbar.profile-view {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: var(--shell-sidebar-w) !important;
    width: auto !important;
    height: var(--shell-topbar-h) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 var(--shell-gap) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    background: var(--shell-surface-glass) !important;
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    backdrop-filter: saturate(160%) blur(12px);
    border: 0 !important;
    border-bottom: 1px solid var(--shell-border) !important;
    box-shadow: none !important;
    z-index: 1001 !important;
    transition: left .3s var(--shell-ease) !important;
}
html body #wrapper.wrapper-toggle .admin-topbar.profile-view {
    left: var(--shell-sidebar-w-collapsed) !important;
}

html body #wrapper .admin-topbar .sidebar-hamburger {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border: 1px solid var(--shell-border) !important;
    border-radius: 10px !important;
    background: var(--shell-surface) !important;
    color: var(--shell-muted) !important;
    box-shadow: none !important;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease !important;
}
html body #wrapper .admin-topbar .sidebar-hamburger:hover,
html body #wrapper .admin-topbar .sidebar-hamburger:focus-visible {
    background: var(--shell-active-bg) !important;
    border-color: color-mix(in srgb, var(--primary-color) 40%, transparent) !important;
    color: var(--shell-active-text) !important;
}
html body #wrapper .admin-topbar .sidebar-hamburger .ham-icon {
    grid-area: 1 / 1;
}
html body #wrapper .admin-topbar .sidebar-hamburger .icon-collapsed,
html body #wrapper.wrapper-toggle .admin-topbar .sidebar-hamburger .icon-expanded {
    display: none !important;
}
html body #wrapper.wrapper-toggle .admin-topbar .sidebar-hamburger .icon-collapsed {
    display: block !important;
}

/* profile chip */
html body #wrapper .admin-topbar .admin-topbar__end {
    margin-left: auto !important;
}
html body #wrapper .admin-topbar .profile-chip {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    height: 44px !important;
    padding: 4px 12px 4px 4px !important;
    border: 1px solid var(--shell-border) !important;
    border-radius: 999px !important;
    background: var(--shell-surface) !important;
    color: var(--shell-text) !important;
    box-shadow: none !important;
    text-decoration: none !important;
    transition: background-color .18s ease, border-color .18s ease !important;
}
html body #wrapper .admin-topbar .profile-chip:hover {
    background: var(--shell-hover-bg) !important;
}
html body #wrapper .admin-topbar .profile-chip .profile-img {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    border: 2px solid var(--shell-active-bg) !important;
    box-shadow: none !important;
}
html body #wrapper .admin-topbar .profile-chip .profile-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}
html body #wrapper .admin-topbar .profile-chip .profile-img--initials {
    display: grid !important;
    place-items: center !important;
    background: var(--shell-accent) !important;
    color: var(--shell-on-accent) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
}
html body #wrapper .admin-topbar .profile-chip .profile-img--initials span {
    color: var(--shell-on-accent) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
}
html body #wrapper .admin-topbar .profile-chip .profile-role-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--shell-text) !important;
}
html body #wrapper .admin-topbar .profile-chip .profile-caret {
    font-size: 12px !important;
    color: var(--shell-muted) !important;
}

/* ---------------------------------------------------------------- collapsed sidebar (desktop) */
@media (min-width: 992px) {
    html body #wrapper.wrapper-toggle #nav-sidebar.sidebar {
        width: var(--shell-sidebar-w-collapsed) !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .sidebar-logo.admin-logo-box,
    html body #wrapper.wrapper-toggle #nav-sidebar .sidebar-logo.admin-logo-box a {
        justify-content: center !important;
        padding: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .sidebar-logo img.brand-logo {
        display: none !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .sidebar-logo img.brand-mark {
        display: block !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header > ul:first-child::before {
        content: "";
        height: 1px;
        padding: 0;
        margin: 4px 10px 12px;
        background: var(--shell-border);
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a {
        justify-content: center !important;
        padding: 0 !important;
        gap: 0 !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a .text {
        opacity: 0 !important;
        max-width: 0 !important;
        width: 0 !important;
    }
}

/* ---------------------------------------------------------------- small screens */
@media (max-width: 991.98px) {
    :root {
        --shell-gap: 16px;
        --shell-topbar-h: 64px;
    }
    html body #wrapper:not(.login),
    html body #wrapper:not(.login).wrapper-toggle {
        padding-left: var(--shell-gap) !important;
    }
    /* the sidebar slides in over the page */
    html body #wrapper #nav-sidebar.sidebar,
    html body #wrapper.wrapper-toggle #nav-sidebar.sidebar {
        width: 280px !important;
        transform: translateX(-100%) !important;
        box-shadow: none !important;
        z-index: 1040 !important;
    }
    html body.sidebar-open #wrapper #nav-sidebar.sidebar {
        transform: translateX(0) !important;
        box-shadow: 0 0 40px color-mix(in srgb, var(--sidebar-color) 30%, transparent) !important;
    }
    html body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 1035;
        background: var(--shell-backdrop);
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a .text {
        opacity: 1 !important;
        max-width: 180px !important;
        width: auto !important;
    }
    html body #wrapper .admin-topbar.profile-view,
    html body #wrapper.wrapper-toggle .admin-topbar.profile-view {
        left: 0 !important;
        padding: 0 var(--shell-gap) !important;
    }
    /* logo mark next to the menu button */
    html body #wrapper .admin-topbar__logo--collapsed.admin-logo-box,
    html body #wrapper:not(.wrapper-toggle) .admin-topbar__logo--collapsed.admin-logo-box {
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        display: flex !important;
        align-items: center !important;
        position: fixed !important;
        top: 0 !important;
        left: calc(var(--shell-gap) + 52px) !important;
        width: auto !important;
        height: var(--shell-topbar-h) !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        z-index: 1002 !important;
    }
    html body #wrapper .admin-topbar__logo--collapsed.admin-logo-box a {
        display: flex !important;
        align-items: center !important;
        max-width: none !important;
        width: auto !important;
    }
    html body #wrapper .admin-topbar__logo--collapsed.admin-logo-box img.brand-logo {
        width: auto !important;
        height: 30px !important;
        max-height: 30px !important;
        max-width: 150px !important;
    }
    html body #wrapper .admin-topbar .sidebar-hamburger .icon-collapsed {
        display: none !important;
    }
    html body #wrapper .admin-topbar .sidebar-hamburger .icon-expanded {
        display: block !important;
    }
    html body #wrapper .admin-topbar .profile-chip {
        padding: 3px !important;
        gap: 0 !important;
    }
    html body #wrapper .admin-topbar .profile-chip .profile-role-name,
    html body #wrapper .admin-topbar .profile-chip .profile-caret {
        display: none !important;
    }
}

/* =====================================================================
   Top bar details: greeting, theme button, profile name
   ===================================================================== */
html body #wrapper .admin-topbar .admin-topbar__start {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    margin-right: auto;
    padding-left: 4px;
}
html body #wrapper .admin-topbar .topbar-greeting {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.25;
    color: var(--shell-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
html body #wrapper .admin-topbar .topbar-greeting strong {
    font-weight: 700;
}
html body #wrapper .admin-topbar .topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 1.2;
    color: var(--shell-muted);
    white-space: nowrap;
}
html body #wrapper .admin-topbar .admin-topbar__end {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin-left: 0 !important;
}
html body #wrapper .admin-topbar .toggle-btn {
    margin: 0 !important;
}

/* round icon button (theme) */
html body #wrapper .admin-topbar .topbar-icon-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--shell-border);
    border-radius: 50%;
    background: var(--shell-surface);
    color: var(--shell-muted);
    font-size: 16px;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
html body #wrapper .admin-topbar .topbar-icon-btn:hover {
    background: var(--shell-active-bg);
    border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
    color: var(--shell-active-text);
}
html body #wrapper .admin-topbar .topbar-icon-btn:active {
    transform: scale(.94);
}
html body #wrapper .admin-topbar .topbar-icon-btn i {
    grid-area: 1 / 1;
}
.topbar-theme-btn__to-light,
body.dark .topbar-theme-btn__to-dark {
    display: none;
}
body.dark .topbar-theme-btn__to-light {
    display: inline-block;
}

/* profile: name and role on two lines */
html body #wrapper .admin-topbar .profile-chip .profile-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    line-height: 1.15;
}
html body #wrapper .admin-topbar .profile-chip .profile-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    color: var(--shell-text);
}
html body #wrapper .admin-topbar .profile-chip .profile-meta .profile-role-name {
    font-size: 11px !important;
    font-weight: 500 !important;
    color: var(--shell-muted) !important;
}

/* =====================================================================
   Collapsed sidebar: item name shows as a tooltip on hover/focus
   ===================================================================== */
@media (min-width: 992px) {
    html body #wrapper.wrapper-toggle #nav-sidebar.sidebar,
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header,
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header > ul:first-child,
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a {
        overflow: visible !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a:hover .text,
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a:focus-visible .text {
        position: absolute !important;
        left: calc(100% + 14px) !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: auto !important;
        max-width: none !important;
        opacity: 1 !important;
        padding: 6px 10px !important;
        border-radius: 8px !important;
        background: var(--text-color) !important;
        color: var(--card-inner-bg) !important;
        font-size: 12px !important;
        font-weight: 500 !important;
        white-space: nowrap !important;
        pointer-events: none !important;
        box-shadow: var(--shell-shadow) !important;
        z-index: 20 !important;
    }
}

/* =====================================================================
   Keyboard focus and reduced motion
   ===================================================================== */
html body #wrapper #nav-sidebar a:focus-visible,
html body #wrapper #nav-sidebar .toggle-switch:focus-visible,
html body #wrapper .admin-topbar button:focus-visible,
html body #wrapper .admin-topbar a:focus-visible {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
}
@media (prefers-reduced-motion: reduce) {
    html body #wrapper #nav-sidebar.sidebar,
    html body #wrapper .admin-topbar.profile-view,
    html body #wrapper:not(.login),
    html body #wrapper #nav-sidebar *,
    html body #wrapper .admin-topbar * {
        transition: none !important;
    }
}

/* small screens: keep the top bar light */
@media (max-width: 991.98px) {
    html body #wrapper .admin-topbar .admin-topbar__start,
    html body #wrapper .admin-topbar .profile-chip .profile-meta {
        display: none !important;
    }
    html body #wrapper .admin-topbar .admin-topbar__end {
        margin-left: auto !important;
    }
}

/* =====================================================================
   Sidebar footer: Light / Dark segment and the signed-in user
   ===================================================================== */
html body #wrapper #nav-sidebar ul.bottom-mode {
    display: none !important;            /* replaced by the footer below (kept for the theme script) */
}
html body #wrapper #nav-sidebar .sidebar-footer {
    flex: 0 0 auto;
    padding-top: 12px;
    margin-top: 8px;
}

/* ---------------------------------------------------------------- dock card */
.sidebar-dock {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--shell-border);
    background:
        radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--primary-color) 14%, transparent), transparent 60%),
        var(--shell-surface);
    box-shadow: var(--shell-shadow);
}

/* ---------------------------------------------------------------- user */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--shell-border);
}
/* round photo with a brand-coloured ring and an online dot */
html body #wrapper .sidebar-user .sidebar-user__avatar {
    position: relative;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 2px;
    border-radius: 50%;
    background: conic-gradient(from 210deg, var(--primary-color), var(--success-color), var(--primary-color));
    text-decoration: none !important;
    transition: transform .18s ease;
}
html body #wrapper .sidebar-user .sidebar-user__avatar:hover {
    transform: scale(1.04);
}
html body #wrapper .sidebar-user .sidebar-user__photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--shell-surface);
    background: var(--shell-accent);
}
html body #wrapper .sidebar-user .sidebar-user__photo img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: cover;
}
.sidebar-user__initials {
    color: var(--shell-on-accent);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
}
.sidebar-user__status {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success-color);
    border: 2px solid var(--shell-surface);
}
.sidebar-user__info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.2;
    text-decoration: none !important;
}
.sidebar-user__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--shell-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
}
.sidebar-user__role {
    font-size: 12px;
    font-weight: 500;
    color: var(--shell-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* small icon buttons (logout, collapse) */
.sidebar-dock__icon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--shell-muted);
    font-size: 15px;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.sidebar-dock__icon:hover {
    background: var(--shell-active-bg);
    color: var(--shell-active-text);
}
.sidebar-dock__icon i {
    grid-area: 1 / 1;
}
.sidebar-user__logout:hover {
    background: color-mix(in srgb, var(--error-color) 12%, transparent);
    color: var(--error-color);
}

/* ---------------------------------------------------------------- theme + collapse */
.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.theme-segment {
    position: relative;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    padding: 3px;
    border-radius: 11px;
    border: 1px solid var(--shell-border);
    background: var(--shell-hover-bg);
}
.theme-segment__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--shell-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.theme-segment__btn:hover {
    color: var(--shell-text);
}
body:not(.dark) .theme-segment__btn--light,
body.dark .theme-segment__btn--dark {
    background: var(--shell-accent);
    color: var(--shell-on-accent);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

/* ---------------------------------------------------------------- large screens */
@media (min-width: 992px) {
    /* the top bar is gone; the page starts at the top */
    html body #wrapper .admin-topbar.profile-view {
        display: none !important;
    }

    /* collapsed sidebar: icons only, stacked */
    html body #wrapper.wrapper-toggle .sidebar-dock {
        align-items: center;
        padding: 10px 0;
        gap: 10px;
    }
    html body #wrapper.wrapper-toggle .sidebar-user {
        flex-direction: column;
        gap: 8px;
        padding-bottom: 10px;
    }
    html body #wrapper.wrapper-toggle .sidebar-user__info {
        display: none;
    }
    html body #wrapper.wrapper-toggle .sidebar-user .sidebar-user__avatar {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }
    html body #wrapper.wrapper-toggle .sidebar-actions {
        flex-direction: column;
    }
    html body #wrapper.wrapper-toggle .theme-segment {
        grid-template-columns: 1fr;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn {
        width: 30px;
        padding: 0;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn span {
        display: none;
    }
}

/* ---------------------------------------------------------------- small screens */
/* the top bar stays (menu button, search and theme are there) */
@media (max-width: 991.98px) {
    .sidebar-actions {
        display: none;
    }
    .sidebar-user {
        padding-bottom: 0;
        border-bottom: 0;
    }
}

/* =====================================================================
   Top bar: search button
   ===================================================================== */
html body #wrapper .admin-topbar .topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    min-width: 240px;
    padding: 0 8px 0 14px;
    border: 1px solid var(--shell-border);
    border-radius: 10px;
    background: var(--shell-hover-bg);
    color: var(--shell-muted);
    font-size: 13px;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}
html body #wrapper .admin-topbar .topbar-search:hover {
    border-color: color-mix(in srgb, var(--primary-color) 45%, transparent);
    background: var(--shell-surface);
}
html body #wrapper .admin-topbar .topbar-search__text {
    flex: 1 1 auto;
    text-align: left;
}
.topbar-search__kbd,
.cmd-palette kbd {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid var(--shell-border);
    background: var(--shell-surface);
    color: var(--shell-muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    box-shadow: none;
}
/* the sidebar has Light / Dark, so the top-bar theme button is for small screens */
@media (min-width: 992px) {
    html body #wrapper .admin-topbar .topbar-theme-btn {
        display: none;
    }
}

/* =====================================================================
   Quick search window (Ctrl / Cmd + K)
   ===================================================================== */
.cmd-palette {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 16px 16px;
    background: var(--shell-backdrop);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s ease;
}
.cmd-palette.is-open {
    opacity: 1;
    visibility: visible;
}
.cmd-palette__panel {
    width: 560px;
    max-width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-inner-bg);
    border: 1px solid var(--shell-border);
    box-shadow: 0 24px 60px color-mix(in srgb, var(--sidebar-color) 35%, transparent);
    transform: translateY(-8px) scale(.98);
    transition: transform .18s var(--shell-ease);
}
.cmd-palette.is-open .cmd-palette__panel {
    transform: none;
}
.cmd-palette__search {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 56px;
    border-bottom: 1px solid var(--shell-border);
    color: var(--shell-muted);
}
.cmd-palette__input {
    flex: 1 1 auto;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--shell-text);
    font-size: 15px;
}
.cmd-palette__input::placeholder {
    color: var(--shell-muted);
}
.cmd-palette__list {
    list-style: none;
    margin: 0;
    padding: 8px;
    max-height: 320px;
    overflow-y: auto;
}
.cmd-palette__item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--shell-text);
    font-size: 14px;
    cursor: pointer;
}
.cmd-palette__item i {
    width: 20px;
    text-align: center;
    color: var(--shell-muted);
}
.cmd-palette__item.is-active {
    background: var(--shell-active-bg);
    color: var(--shell-active-text);
}
.cmd-palette__item.is-active i {
    color: var(--shell-active-text);
}
.cmd-palette__empty {
    padding: 18px 12px;
    text-align: center;
    color: var(--shell-muted);
    font-size: 13px;
}
.cmd-palette__hint {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    border-top: 1px solid var(--shell-border);
    color: var(--shell-muted);
    font-size: 12px;
}
.cmd-palette__hint kbd {
    margin-right: 4px;
}

/* =====================================================================
   Large screens: sidebar and top bar float as rounded panels
   ===================================================================== */
@media (min-width: 992px) {
    :root {
        --shell-inset: 12px;
        --shell-topbar-h: 64px;
    }
    html body #wrapper:not(.login) {
        padding: calc(var(--shell-inset) + var(--shell-topbar-h) + var(--shell-gap)) var(--shell-gap) var(--shell-gap) calc(var(--shell-inset) + var(--shell-sidebar-w) + var(--shell-gap)) !important;
    }
    html body #wrapper:not(.login).wrapper-toggle {
        padding-left: calc(var(--shell-inset) + var(--shell-sidebar-w-collapsed) + var(--shell-gap)) !important;
    }
    html body #wrapper #nav-sidebar.sidebar {
        top: var(--shell-inset) !important;
        left: var(--shell-inset) !important;
        bottom: var(--shell-inset) !important;
        height: calc(100vh - 2 * var(--shell-inset)) !important;
        border: 1px solid var(--shell-border) !important;
        border-radius: 18px !important;
        box-shadow: var(--shell-shadow) !important;
    }
    html body #wrapper #nav-sidebar .sidebar-logo.admin-logo-box {
        border-radius: 18px 18px 0 0 !important;
    }
    html body #wrapper .admin-topbar.profile-view {
        top: var(--shell-inset) !important;
        right: var(--shell-inset) !important;
        left: calc(var(--shell-inset) * 2 + var(--shell-sidebar-w)) !important;
        border: 1px solid var(--shell-border) !important;
        border-radius: 16px !important;
        box-shadow: var(--shell-shadow) !important;
        padding: 0 14px 0 12px !important;
    }
    html body #wrapper.wrapper-toggle .admin-topbar.profile-view {
        left: calc(var(--shell-inset) * 2 + var(--shell-sidebar-w-collapsed)) !important;
    }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
    html body #wrapper .admin-topbar .topbar-search {
        min-width: 0;
    }
    html body #wrapper .admin-topbar .topbar-search__text,
    html body #wrapper .admin-topbar .topbar-search__kbd {
        display: none;
    }
}
@media (max-width: 991.98px) {
    html body #wrapper .admin-topbar .topbar-search {
        min-width: 0;
        width: 40px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }
    html body #wrapper .admin-topbar .topbar-search__text,
    html body #wrapper .admin-topbar .topbar-search__kbd {
        display: none;
    }
}
html body #wrapper #nav-sidebar.sidebar ul.bottom-mode,
html body #wrapper.wrapper-toggle #nav-sidebar.sidebar ul.bottom-mode,
html body #wrapper.wrapper-toggle #nav-sidebar.sidebar.close ul.bottom-mode {
    display: none !important;
}

/* no top bar on large screens: the page starts near the top (after the floating-panel rules) */
@media (min-width: 992px) {
    html body #wrapper:not(.login) {
        padding-top: calc(var(--shell-inset) + var(--shell-gap)) !important;
    }
}
/* the user photo fills its circle (older sidebar rules set img sizes) */
html body #wrapper #nav-sidebar .sidebar-user .sidebar-user__photo img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
}

/* =====================================================================
   Collapse button: round, on the sidebar edge next to the logo
   ===================================================================== */
.sidebar-edge-toggle {
    display: none;
}
@media (min-width: 992px) {
    html body #wrapper .sidebar-edge-toggle {
        position: fixed;
        top: calc(var(--shell-inset) + 22px);
        left: calc(var(--shell-inset) + var(--shell-sidebar-w) - 14px);
        z-index: 1003;
        width: 28px;
        height: 28px;
        display: grid;
        place-items: center;
        padding: 0;
        border: 1px solid var(--shell-border);
        border-radius: 50%;
        background: var(--shell-surface);
        color: var(--shell-muted);
        font-size: 12px;
        box-shadow: var(--shell-shadow);
        cursor: pointer;
        transition: left .3s var(--shell-ease), background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
    }
    html body #wrapper .sidebar-edge-toggle:hover {
        background: var(--shell-accent);
        border-color: var(--shell-accent);
        color: var(--shell-on-accent);
    }
    html body #wrapper .sidebar-edge-toggle:active {
        transform: scale(.92);
    }
    html body #wrapper .sidebar-edge-toggle i {
        transition: transform .3s var(--shell-ease);
    }
    html body #wrapper.wrapper-toggle .sidebar-edge-toggle {
        left: calc(var(--shell-inset) + var(--shell-sidebar-w-collapsed) - 14px);
    }
    html body #wrapper.wrapper-toggle .sidebar-edge-toggle i {
        transform: rotate(180deg);
    }
    html body #wrapper .sidebar-edge-toggle:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    /* reader book-only mode hides the sidebar, so hide its button too */
    body.book-only-active #wrapper .sidebar-edge-toggle {
        display: none;
    }
}

/* =====================================================================
   Collapsed sidebar (large screens): clean icon rail
   ===================================================================== */
@media (min-width: 992px) {
    /* menu: one rounded button per item */
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li {
        margin: 0 0 6px !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a {
        width: 44px !important;
        height: 44px !important;
        margin: 0 auto !important;
        border-radius: 12px !important;
        background: transparent !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a > i[class*="fa"] {
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        border-radius: 12px !important;
        font-size: 18px !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a:hover {
        background: transparent !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li:not(.active) > a:hover > i[class*="fa"] {
        background: var(--shell-hover-bg) !important;
        color: var(--shell-text) !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li.active > a {
        background: transparent !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li.active > a::before {
        content: none;
    }

    /* bottom: no card, just icons — theme, logout, then the avatar */
    html body #wrapper.wrapper-toggle .sidebar-dock {
        padding: 0;
        gap: 6px;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    html body #wrapper.wrapper-toggle .sidebar-actions {
        order: 1;
    }
    html body #wrapper.wrapper-toggle .sidebar-user {
        order: 2;
        flex-direction: column-reverse;
        gap: 10px;
        padding: 10px 0 0;
        border-bottom: 0;
        border-top: 1px solid var(--shell-border);
    }
    html body #wrapper.wrapper-toggle .sidebar-user__logout {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        border-radius: 12px;
        font-size: 17px;
    }

    /* theme: one button that switches to the other mode */
    html body #wrapper.wrapper-toggle .theme-segment {
        padding: 0;
        border: 0;
        background: transparent;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 17px;
        background: transparent;
        color: var(--shell-muted);
        box-shadow: none;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn:hover {
        background: var(--shell-hover-bg);
        color: var(--shell-text);
    }
    body:not(.dark) #wrapper.wrapper-toggle .theme-segment__btn--light,
    body.dark #wrapper.wrapper-toggle .theme-segment__btn--dark {
        display: none;
    }
}

/* =====================================================================
   Collapsed sidebar: menu and account each sit in a rounded track
   ===================================================================== */
@media (min-width: 992px) {
    /* menu track */
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header > ul:first-child {
        flex: 0 0 auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
        width: 56px !important;
        margin: 4px auto 0 !important;
        padding: 6px !important;
        border: 1px solid var(--shell-border) !important;
        border-radius: 18px !important;
        background: var(--shell-hover-bg) !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header > ul:first-child::before {
        content: none !important;
        display: none !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li {
        margin: 0 !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a > i[class*="fa"] {
        font-size: 17px !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li:not(.active) > a:hover > i[class*="fa"] {
        background: var(--shell-surface) !important;
        color: var(--shell-active-text) !important;
        box-shadow: var(--shell-shadow) !important;
    }

    /* account track at the bottom: theme, logout, avatar */
    html body #wrapper.wrapper-toggle #nav-sidebar .sidebar-footer {
        margin-top: auto;
        padding-top: 12px;
    }
    html body #wrapper.wrapper-toggle .sidebar-dock {
        width: 56px;
        margin: 0 auto;
        padding: 6px;
        gap: 4px;
        border: 1px solid var(--shell-border);
        border-radius: 18px;
        background: var(--shell-hover-bg);
        box-shadow: none;
    }
    html body #wrapper.wrapper-toggle .sidebar-user {
        gap: 4px;
        padding: 0;
        border-top: 0;
    }
    html body #wrapper.wrapper-toggle .sidebar-user .sidebar-user__avatar {
        margin-top: 6px;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn,
    html body #wrapper.wrapper-toggle .sidebar-user__logout {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 16px;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn:hover {
        background: var(--shell-surface);
        color: var(--shell-active-text);
        box-shadow: var(--shell-shadow);
    }
    html body #wrapper.wrapper-toggle .sidebar-user__logout:hover {
        background: color-mix(in srgb, var(--error-color) 12%, transparent);
        color: var(--error-color);
    }
}

/* collapsed sidebar: no track background, larger icons */
@media (min-width: 992px) {
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header > ul:first-child {
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        gap: 6px !important;
    }
    html body #wrapper.wrapper-toggle #nav-sidebar .navbar-header ul > li > a > i[class*="fa"] {
        font-size: 20px !important;
    }
    html body #wrapper.wrapper-toggle .sidebar-dock {
        padding: 0;
        gap: 6px;
        border: 0;
        background: transparent;
    }
    html body #wrapper.wrapper-toggle .theme-segment__btn,
    html body #wrapper.wrapper-toggle .sidebar-user__logout {
        font-size: 19px;
    }
}

/* =====================================================================
   Row action icons and role pills: readable in light and dark mode
   (colours from the theme variables; text is mixed toward the text
   colour so it is darker in light mode and lighter in dark mode)
   ===================================================================== */
html body #wrapper .btn.action-edit,
html body #wrapper .btn.action-view,
html body #wrapper .btn.action-key,
html body #wrapper .btn.action-books,
html body #wrapper .btn.action-courses,
html body #wrapper .btn.action-clone {
    color: var(--primary-strong) !important;
    background: color-mix(in srgb, var(--primary-color) 12%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--primary-color) 30%, transparent) !important;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease !important;
}
html body #wrapper .btn.action-edit:hover,
html body #wrapper .btn.action-view:hover,
html body #wrapper .btn.action-key:hover,
html body #wrapper .btn.action-books:hover,
html body #wrapper .btn.action-courses:hover,
html body #wrapper .btn.action-clone:hover {
    color: var(--active-text-color) !important;
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
html body #wrapper .btn.action-danger {
    color: color-mix(in srgb, var(--error-color) 80%, var(--text-color)) !important;
    background: color-mix(in srgb, var(--error-color) 10%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--error-color) 30%, transparent) !important;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease !important;
}
html body #wrapper .btn.action-danger:hover {
    color: var(--active-text-color) !important;
    background: var(--error-color) !important;
    border-color: var(--error-color) !important;
}

html body #wrapper .user-role-pill--admin {
    color: var(--primary-strong) !important;
    background: color-mix(in srgb, var(--primary-color) 14%, transparent) !important;
    border-color: color-mix(in srgb, var(--primary-color) 35%, transparent) !important;
}
html body #wrapper .user-role-pill--trainer {
    color: color-mix(in srgb, var(--warning-color) 70%, var(--text-color)) !important;
    background: color-mix(in srgb, var(--warning-color) 14%, transparent) !important;
    border-color: color-mix(in srgb, var(--warning-color) 35%, transparent) !important;
}
html body #wrapper .user-role-pill--customer {
    color: color-mix(in srgb, var(--success-color) 70%, var(--text-color)) !important;
    background: color-mix(in srgb, var(--success-color) 14%, transparent) !important;
    border-color: color-mix(in srgb, var(--success-color) 35%, transparent) !important;
}
/* the delete icon takes its button's red, and icons turn white on hover */
html body #wrapper .btn.action-danger i,
html body #wrapper .btn.action-danger:hover i,
html body #wrapper .btn.action-edit:hover i,
html body #wrapper .btn.action-view:hover i,
html body #wrapper .btn.action-key:hover i,
html body #wrapper .btn.action-books:hover i,
html body #wrapper .btn.action-courses:hover i,
html body #wrapper .btn.action-clone:hover i {
    color: inherit !important;
}

/* book cards: the title sits on the cover image (dark overlay), so it is light in both modes */
html body #wrapper .book-card .book-card__name {
    color: var(--active-text-color) !important;
    text-shadow: 0 1px 3px color-mix(in srgb, var(--sidebar-color) 70%, transparent);
}
html body #wrapper .book-card .book-card__author {
    color: color-mix(in srgb, var(--active-text-color) 80%, transparent) !important;
    text-shadow: 0 1px 3px color-mix(in srgb, var(--sidebar-color) 70%, transparent);
}
/* "PDF ready" in tables: readable blue text (the badge on cover images stays white on blue) */
html body #wrapper td .badge-pdf-ready {
    color: var(--primary-strong) !important;
}

/* Soft surfaces: no pure-white boxes in light mode (easier on the eyes) */
html body:not(.dark) #wrapper select,
html body:not(.dark) .modal select.form-control {
    background-color: var(--fields-bg) !important;
}
html body:not(.dark) .modal .modal-content,
html body:not(.dark) .modal .modal-header,
html body:not(.dark) .modal .modal-body,
html body:not(.dark) .modal .modal-footer {
    background-color: var(--card-inner-bg) !important;
}
html body:not(.dark) .modal .form-control,
html body:not(.dark) #wrapper .form-control:not([readonly]):not(:disabled) {
    background-color: var(--fields-bg) !important;
}

/* Read-only fields (Email, Registration # on the profile): clearly not editable */
html body #wrapper .form-control.profile-input-readonly,
html body #wrapper .form-control.profile-input-readonly:focus {
    background-color: var(--shell-hover-bg) !important;
    color: var(--shell-muted) !important;
    border-style: dashed !important;
    box-shadow: none !important;
    cursor: not-allowed;
}

/* Light mode: calm table headers and soft card depth */
html body:not(.dark) #wrapper table.dataTable thead th,
html body:not(.dark) #wrapper .table thead th {
    background-color: var(--table-head) !important;
    color: var(--stat-muted) !important;
}
html body:not(.dark) #wrapper .card,
html body:not(.dark) #wrapper .stat-card {
    border-color: var(--border-color) !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 16px -8px rgba(15, 23, 42, .10) !important;
}

/* Light mode sidebar: calm blue-grey panel instead of a bright white one */
html body:not(.dark) {
    --shell-side-bg: linear-gradient(180deg, #f6f8fb 0%, #f0f3f7 100%);
    --shell-side-raise: #fafbfd;
}
html body:not(.dark) #wrapper #nav-sidebar.sidebar {
    background: var(--shell-side-bg) !important;
    border-right-color: #d0d9e5 !important;
}
html body:not(.dark) #wrapper #nav-sidebar .sidebar-logo.admin-logo-box {
    background: transparent !important;
    border-bottom-color: #d0d9e5 !important;
}
html body:not(.dark) #wrapper #nav-sidebar .sidebar-dock {
    background: var(--shell-side-raise);
    border-color: #d0d9e5;
}
html body:not(.dark) #wrapper .sidebar-edge-toggle {
    background: var(--shell-side-raise) !important;
}

/* Tablet / phone: list tables keep readable columns and scroll sideways
   inside their card instead of squeezing columns over each other. */
@media (max-width: 1499px) {
    /* Courses: the fixed column widths only fit wide screens */
    html body #wrapper .courses-page table.courses-data-table {
        table-layout: auto;
    }
    html body #wrapper .courses-page table.courses-data-table thead th,
    html body #wrapper .courses-page table.courses-data-table tbody td {
        width: auto !important;
        white-space: nowrap;
    }
    /* Long descriptions are cut with "..." (full text in the tooltip) */
    html body #wrapper .courses-page table.courses-data-table .courses-desc {
        display: block;
        max-width: 220px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    html body #wrapper .courses-page table.courses-data-table tbody td:nth-child(2) {
        padding-left: 16px !important;
    }
}
@media (max-width: 1199px) {
    /* A visible scrollbar shows that more columns are to the right */
    html body #wrapper .table-responsive {
        scrollbar-width: thin;
        scrollbar-color: var(--shell-muted) transparent;
    }
}

/* Phone: search, filters and toolbar buttons wrap onto their own lines */
@media (max-width: 575px) {
    html body #wrapper .os-list-page .os-toolbar,
    html body #wrapper .os-list-page .os-toolbar__left,
    html body #wrapper .os-list-page .os-toolbar__actions {
        flex-wrap: wrap !important;
    }
    html body #wrapper .os-list-page .os-toolbar__left,
    html body #wrapper .os-list-page .os-toolbar__actions {
        flex: 1 1 100% !important;
    }
    html body #wrapper .os-list-page .os-search {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: none !important;
    }
}

/* Primary buttons and the active page number: a deeper blue so the white
   text is readable (at least 4.5:1). */
html body .btn-admin-add,
html body .btn-admin-save,
html body .btn-course-save,
html body #default_modal .btn-admin-save,
html body #default_modal .btn-course-save,
html body #default_modal .field-label.file,
html body .qb-question-badge,
html body #wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html body #wrapper .dataTables_paginate a.paginate_button.current,
html body #wrapper .os-pagination .pagination .page-item.active .page-link,
html body #wrapper .books-pagination .pagination .page-item.active .page-link,
html body:not(.dark) .admin-form-card label.profile-upload__btn {
    background: #127cb3 !important;
    border-color: #127cb3 !important;
    color: #fff !important;
}
html body .btn-admin-add:hover,
html body .btn-admin-save:hover,
html body .btn-course-save:hover,
html body #default_modal .btn-admin-save:hover,
html body #default_modal .btn-course-save:hover,
html body #default_modal .field-label.file:hover {
    background: #0e6a99 !important;
    border-color: #0e6a99 !important;
    color: #fff !important;
}

/* Light mode: dropdowns keep their arrow (the light background rule above
   in main.css resets it), the same arrow as in dark mode. */
html body:not(.dark) #default_modal select:not([multiple]),
html body:not(.dark) #questionnaireForm select:not([multiple]),
html body:not(.dark) #questionnaireUpdateForm select:not([multiple]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    padding-right: 34px !important;
    -webkit-appearance: none;
    appearance: none;
}

/* Filters panels: use the room on screen so every option shows; a short
   screen still scrolls inside the panel. */
html body .books-page .books-refine,
html body .os-list-page .os-refine {
    max-height: max(360px, calc(100vh - 190px));
}

/* Multi-select lists in pop-ups: the search box covers the top of the open
   list. A transparent top border (not padding) keeps the scrollbar below the
   search box, so the scrollbar is visible and the last option can be reached. */
html body #default_modal [data-control="checkbox-dropdown"].on:not(.dropup) .dropdown-list {
    padding-top: 8px !important;
    border-top: 56px solid transparent !important;
}

/* Toolbar buttons (Filters, sort): a global button:hover rule makes the text
   white !important while the background stays light, so the button looked
   empty when hovered or open. Keep the readable blue text. */
html body .os-list-page .os-tool-btn:hover,
html body .os-list-page .os-tool-btn.is-open,
html body .books-page .books-tool-btn:hover,
html body .books-page .books-tool-btn.is-open {
    color: var(--primary-strong) !important;
}
html body:not(.dark) .os-list-page .os-tool-btn:hover,
html body:not(.dark) .os-list-page .os-tool-btn.is-open,
html body:not(.dark) .books-page .books-tool-btn:hover,
html body:not(.dark) .books-page .books-tool-btn.is-open {
    color: #0e76ab !important;
}

/* Filters panel pills in light mode: the chosen pill had white text on a
   pale blue fill, and the global button:hover rule made hovered pills white. */
html body:not(.dark) .os-list-page .os-refine button:hover,
html body:not(.dark) .os-list-page .os-pill.active,
html body:not(.dark) .os-list-page .os-refine__reset,
html body:not(.dark) .books-page .books-refine button:hover,
html body:not(.dark) .books-page .books-pill.active,
html body:not(.dark) .books-page .books-refine__reset {
    color: #0e76ab !important;
}

/* Assign Books / My Books list view: the Read button keeps room for its icon
   and label (a generic 34px action-button rule was squeezing it). */
html body .books-page .action-list a.btn.btn-read-primary,
html body .books-page .action-list span.btn.btn-read-primary,
html body .admin-page .action-list a.btn.btn-read-primary,
html body .admin-page .action-list span.btn.btn-read-primary {
    width: auto !important;
    min-width: max-content !important;
    padding: 0 12px !important;
}

/* Page buttons: no pale box behind the Books / Assign Books buttons, and
   Previous / Next look the same (only the selected page is filled). */
html body #wrapper .os-pagination nav,
html body #wrapper .books-pagination nav {
    background: transparent !important;
}
html body #wrapper .os-pagination .pagination .page-item:not(.active) .page-link,
html body #wrapper .books-pagination .pagination .page-item:not(.active) .page-link,
html body #wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.next:not(.disabled),
html body #wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.previous:not(.disabled) {
    background: var(--fields-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--nav-icon-color) !important;
}

/* Tablet: list toolbars wrap instead of putting buttons on top of each other
   (sort over Shelf/List, Filters over List/Folder). */
@media (max-width: 1199px) {
    html body #wrapper .os-list-page .os-toolbar,
    html body #wrapper .books-page .books-toolbar {
        flex-wrap: wrap !important;
        row-gap: 12px;
    }
}

/* Delete buttons are red on hover everywhere (not blue like Edit / View). */
html body #wrapper .action-danger:hover,
html body #wrapper .delete-btn:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
}
html body #wrapper .action-danger:hover i,
html body #wrapper .delete-btn:hover i {
    color: #fff !important;
}

/* Questionnaire Text / Image / File tabs: one selected colour on Add and Edit. */
html body .qb-question-tab.is-active,
html body .qb-question-tab[data-mode="image"].is-active,
html body .qb-question-tab[data-mode="file"].is-active {
    background: #127cb3;
    box-shadow: 0 3px 10px rgba(18, 124, 179, .3);
    color: #fff;
}

/* Course form: the Books field looks like the other fields (no extra box). */
html body #default_modal .form-group.course-modal__books {
    border: 0;
    border-radius: 0;
    padding: 0 5px;
    background: none;
}

/* My Questionnaires list: status tag and button sit in fixed columns so
   every row lines up (the buttons have different text lengths). */
@media (min-width: 576px) {
    html body .quiz-row__actions {
        display: grid;
        grid-template-columns: 150px 210px;
        align-items: center;
    }
    html body .quiz-row__actions .q-status {
        justify-self: center;
    }
    html body .quiz-row__actions .btn {
        grid-column: 2;
        justify-content: center;
        width: 100%;
        padding: 0 14px;
        white-space: nowrap;
    }
}

/* Courses: a long course name wraps onto a second line instead of running
   over the description. */
html body #wrapper .courses-page table.courses-data-table tbody td:nth-child(1) {
    white-space: normal !important;
    overflow-wrap: anywhere;
}
@media (max-width: 1499px) {
    html body #wrapper .courses-page table.courses-data-table tbody td:nth-child(1) {
        min-width: 160px;
        max-width: 240px;
    }
}

/* Shelf / List and List / Folder switches in light mode: the selected option
   has dark blue text, the other one a readable grey. */
html body:not(.dark) #wrapper .books-view-toggle .books-view-btn,
html body:not(.dark) #wrapper .os-view-toggle .os-view-btn,
html body:not(.dark) #wrapper .os-view-toggle button {
    color: #64748b !important;
}
html body:not(.dark) #wrapper .books-view-toggle .books-view-btn.active,
html body:not(.dark) #wrapper .os-view-toggle .os-view-btn.active,
html body:not(.dark) #wrapper .os-view-toggle button.active {
    color: #0e5f88 !important;
}
