/**
 * Modern CSS Stylesheet - Mobile First Adaptive Navigation
 * Using CSS Layers, Container Queries, and fluid typography
 *
 * IMPORTANT: This file requires tokens.css to be loaded first.
 * Design tokens (CSS variables) are defined in tokens.css.
 *
 * Navigation pattern:
 * - Mobile (< 768px): Drawer sidebar (hamburger menu)
 * - Tablet (768px - 1024px): Mini sidebar (icons only) + header
 * - Desktop (> 1024px): Full sidebar (icons + labels) + header
 *
 * Browser support:
 * - CSS Layers: 90%+ (2025)
 * - Container Queries: 90%+ (2025)
 * - light-dark(): 87%+ (2025) with fallback in tokens.css
 * - clamp(): 95%+ (2025)
 */

/* ==========================================================================
   CSS Layers - Define cascade order
   ========================================================================== */
@layer base, layout, components, utilities;

/* ==========================================================================
   Base Layer - Reset and typography
   Design tokens are defined in tokens.css
   ========================================================================== */
@layer base {
    /* Reset */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    /* Base typography with fluid sizing */
    html {
        font-size: var(--font-size-base, 16px);
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    body {
        font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
        line-height: 1.5;
        color: var(--color-text);
        background-color: var(--color-bg);
        transition: background-color var(--transition-normal), color var(--transition-normal);
    }

    /* Fluid typography */
    h1 {
        font-size: clamp(1.5rem, 4vw, 2.25rem);
        font-weight: 700;
        line-height: 1.2;
    }

    h2 {
        font-size: clamp(1.25rem, 3vw, 1.5rem);
        font-weight: 600;
        line-height: 1.3;
    }

    h3 {
        font-size: clamp(1rem, 2.5vw, 1.125rem);
        font-weight: 600;
        line-height: 1.4;
    }

    /* Links */
    a {
        color: var(--color-primary);
        text-decoration: none;
    }

    a:hover {
        text-decoration: underline;
    }

    /* Content lists - proper styling for ul/ol in content areas */
    :is(.card-body, .backup-card-body, .alert, .modal-body) :is(ul, ol):not([class]) {
        padding-left: var(--space-lg);
        margin: var(--space-sm) 0;
    }

    :is(.card-body, .backup-card-body, .alert, .modal-body) ul:not([class]) {
        list-style-type: disc;
    }

    :is(.card-body, .backup-card-body, .alert, .modal-body) ol:not([class]) {
        list-style-type: decimal;
    }

    :is(.card-body, .backup-card-body, .alert, .modal-body) :is(ul, ol):not([class]) li {
        margin-bottom: var(--space-xs);
        line-height: 1.5;
    }

    /* Focus styles for accessibility */
    :focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }
}

/* ==========================================================================
   Layout Layer - Page structure and containers (Mobile First)
   ========================================================================== */
@layer layout {
    /* App layout - Mobile first (no sidebar visible) */
    .app-layout {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height — adapts to mobile address bar */
        overflow: hidden;
    }

    /* ==========================================================================
       App Header
       ========================================================================== */
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--header-height);
        background-color: var(--color-bg-elevated);
        border-bottom: 1px solid var(--color-border);
        display: flex;
        align-items: center;
        padding: 0 var(--space-md);
        gap: var(--space-sm);
        z-index: var(--z-sticky);
        box-shadow: var(--shadow-sm);
    }

    .header-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--touch-target);
        height: var(--touch-target);
        background: none;
        border: none;
        color: var(--color-text);
        cursor: pointer;
        border-radius: var(--radius-md);
        transition: background-color var(--transition-fast);
        flex-shrink: 0;
    }

    .header-menu-toggle:hover {
        background-color: var(--color-bg-subtle);
    }

    .header-logo {
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        text-decoration: none;
        color: var(--color-text);
        font-weight: 600;
        font-size: 1rem;
        flex-shrink: 0;
    }

    .header-logo:hover {
        text-decoration: none;
    }

    .header-logo-text {
        white-space: nowrap;
    }

    .header-logo-image {
        height: 32px;
        width: auto;
    }

    /* ==========================================================================
       Sidebar - Hidden on mobile, drawer behavior
       ========================================================================== */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-width-full);
        background-color: var(--sidebar-bg);
        color: var(--sidebar-text);
        display: flex;
        flex-direction: column;
        z-index: var(--z-sidebar);
        transform: translateX(-100%);
        transition: transform var(--transition-normal), width var(--transition-normal);
        overflow: hidden;
    }

    .sidebar.open {
        transform: translateX(0);
        /* Allow dropdowns to overflow sidebar bounds (user menu) */
        overflow: visible;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background-color: rgb(0 0 0 / 0.5);
        z-index: var(--z-sidebar-overlay);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-normal), visibility var(--transition-normal);
    }

    .sidebar.open ~ .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-header {
        padding: var(--space-md) var(--space-lg);
        border-bottom: 1px solid var(--sidebar-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: var(--header-height);
        flex-shrink: 0;
    }

    .sidebar-logo {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        text-decoration: none;
        color: #ffffff;
        overflow: hidden;
    }

    .sidebar-logo:hover {
        text-decoration: none;
    }

    .sidebar-logo-text {
        font-size: 1.125rem;
        font-weight: 600;
        white-space: nowrap;
    }

    /* Sidebar toggle (hamburger) - hidden on mobile (header hamburger handles it) */
    .sidebar-toggle {
        display: none;
    }

    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--touch-target);
        height: var(--touch-target);
        background: none;
        border: none;
        color: var(--sidebar-text);
        cursor: pointer;
        border-radius: var(--radius-md);
        flex-shrink: 0;
    }

    .sidebar-close:hover {
        background-color: var(--sidebar-hover);
        color: #ffffff;
    }

    /* Admin context visual indicator - sidebar left border */
    .sidebar.admin-context {
        border-left: 3px solid var(--color-warning);
    }

    .sidebar-nav {
        flex: 1;
        padding: var(--space-md) 0;
        overflow-y: auto;
        overflow-x: hidden;
        /* Custom scrollbar - Firefox */
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
        /* Ensure workspace dropdown appears above nav items */
        position: relative;
        z-index: 0;
    }

    /* Custom scrollbar - Webkit (Chrome, Safari, Edge) */
    .sidebar-nav::-webkit-scrollbar {
        width: 6px;
    }

    .sidebar-nav::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-nav::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
    }

    .sidebar-nav::-webkit-scrollbar-thumb:hover {
        background-color: rgba(255, 255, 255, 0.35);
    }

    /* Hide scrollbar when not hovering/scrolling (appears on scroll) */
    .sidebar-nav:not(:hover)::-webkit-scrollbar-thumb {
        background-color: transparent;
    }

    .sidebar-nav:hover {
        scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    }

    .sidebar-nav:not(:hover) {
        scrollbar-color: transparent transparent;
    }

    .nav-section {
        margin-bottom: var(--space-md);
    }

    /* Section header button (collapsible) */
    .nav-section-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: var(--space-sm) var(--space-lg);
        background: none;
        border: none;
        cursor: pointer;
        transition: background-color var(--transition-fast);
    }

    .nav-section-header:hover {
        background-color: var(--sidebar-hover);
    }

    .nav-section-header:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: -2px;
    }

    .nav-section-title {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--sidebar-text);
        opacity: 0.6;
        white-space: nowrap;
        overflow: hidden;
        /* Remove padding - now handled by parent button */
        padding: 0;
    }

    .nav-section-chevron {
        flex-shrink: 0;
        color: var(--sidebar-text);
        opacity: 0.5;
        transition: transform var(--transition-fast), opacity var(--transition-fast);
    }

    .nav-section-header:hover .nav-section-chevron {
        opacity: 0.8;
    }

    /* Collapsed state */
    .nav-section.collapsed .nav-section-chevron {
        transform: rotate(-90deg);
    }

    /* Section items container */
    .nav-section-items {
        overflow: hidden;
    }

    .nav-section.collapsed .nav-section-items {
        max-height: 0;
        overflow: hidden;
    }

    .nav-item {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        padding: 0.75rem var(--space-lg);
        color: var(--sidebar-text);
        text-decoration: none;
        font-size: 0.875rem;
        font-weight: 500;
        transition: background-color var(--transition-fast), color var(--transition-fast);
        min-height: var(--touch-target);
        position: relative;
        white-space: nowrap;
        overflow: hidden;
    }

    .nav-item:hover {
        background-color: var(--sidebar-hover);
        color: #ffffff;
        text-decoration: none;
    }

    .nav-item.active {
        background-color: var(--sidebar-active);
        color: #ffffff;
    }

    .nav-item.active::before {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background-color: var(--color-primary);
    }

    .nav-icon {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
    }

    .nav-label {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-footer {
        padding: var(--space-md);
        border-top: 1px solid var(--sidebar-border);
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        flex-shrink: 0;
    }

    /* Sidebar utility zone - items above user menu */
    .sidebar-utility {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-utility-item {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        padding: var(--space-sm);
        color: var(--sidebar-text);
        text-decoration: none;
        border-radius: var(--radius-md);
        transition: background-color var(--transition-fast), color var(--transition-fast);
        position: relative;
        min-height: var(--touch-target);
    }

    .sidebar-utility-item:hover {
        background-color: var(--sidebar-hover);
        color: #ffffff;
    }

    .sidebar-utility-item.active {
        background-color: var(--sidebar-active);
        color: #ffffff;
    }

    .sidebar-utility-item svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .sidebar-utility-label {
        font-size: 0.875rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-utility-badge {
        margin-left: auto;
        background-color: var(--color-primary);
        color: #ffffff;
        font-size: 0.6875rem;
        font-weight: 600;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: var(--radius-full);
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    /* User menu in sidebar footer - mobile styles */
    .sidebar-footer .user-menu {
        width: 100%;
        margin-left: 0;
    }

    .sidebar-footer .user-menu-trigger {
        width: 100%;
        justify-content: flex-start;
        color: var(--sidebar-text);
        padding: var(--space-sm);
    }

    .sidebar-footer .user-menu-trigger:hover {
        background-color: var(--sidebar-hover);
    }

    .sidebar-footer .user-name {
        display: block;
        color: var(--sidebar-text);
    }

    .sidebar-footer .user-menu-chevron {
        display: block;
        margin-left: auto;
        color: var(--sidebar-text);
    }

    .sidebar-footer .user-menu-dropdown {
        bottom: 100%;
        top: auto;
        left: 0;
        right: auto;
        margin-bottom: var(--space-xs);
    }

    /* ==========================================================================
       Main Content
       ========================================================================== */
    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-top: var(--header-height);
        min-width: 0;
        min-height: 0;
    }

    .content-body {
        flex: 1;
        padding: var(--space-md);
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        min-height: 0;
        container-type: inline-size;
    }

    /* ==========================================================================
       Content Top Bar - Slot for in-flow global widgets (e.g. notification bell)
       Rendered above content-body within main-content flex column.
       ========================================================================== */
    .content-top-bar {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: var(--space-sm);
        /* Mobile: overlay on header (right side where user-menu is hidden) */
        position: fixed;
        top: 0;
        right: var(--space-md);
        height: var(--header-height);
        padding: 0;
        z-index: var(--z-sticky);
        background: none;
        pointer-events: none;
    }

    .content-top-bar > * {
        pointer-events: auto;
    }

    /* Logo in content-top-bar - hidden on mobile (header has its own logo) */
    .content-top-bar-logo {
        display: none;
    }

    /* ==========================================================================
       User Menu (Header)
       ========================================================================== */
    .user-menu {
        position: relative;
        margin-left: auto;
    }

    /* User menu in header - hidden on mobile (use sidebar footer menu instead) */
    .app-header .user-menu {
        display: none;
    }

    .user-menu-trigger {
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        padding: var(--space-xs);
        background: none;
        border: none;
        cursor: pointer;
        border-radius: var(--radius-md);
        transition: background-color var(--transition-fast);
        color: var(--color-text);
        min-height: var(--touch-target);
    }

    .user-menu-trigger:hover {
        background-color: var(--color-bg-subtle);
    }

    .user-menu-avatar-wrapper {
        position: relative;
        flex-shrink: 0;
    }

    .user-avatar-badge {
        position: absolute;
        bottom: -2px;
        right: -2px;
        width: 10px;
        height: 10px;
        background-color: var(--color-warning);
        border: 2px solid var(--color-bg-elevated);
        border-radius: 50%;
        z-index: 1;
    }

    .user-name {
        display: none;
        font-size: 0.875rem;
        font-weight: 500;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-menu-chevron {
        display: none;
        flex-shrink: 0;
        transition: transform var(--transition-fast);
    }

    .user-menu.open .user-menu-chevron {
        transform: rotate(180deg);
    }

    .user-menu-dropdown {
        position: absolute;
        top: calc(100% + var(--space-xs));
        right: 0;
        min-width: 240px;
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast);
        z-index: var(--z-dropdown);
    }

    .user-menu.open .user-menu-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .user-menu-header {
        padding: var(--space-md);
        border-bottom: 1px solid var(--color-border);
    }

    .user-menu-name {
        display: block;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: 2px;
    }

    .user-menu-email {
        display: block;
        font-size: 0.75rem;
        color: var(--color-text-muted);
        word-break: break-all;
    }

    .user-menu-role {
        display: block;
        margin-top: var(--space-xs);
    }

    .user-menu-divider {
        height: 1px;
        background-color: var(--color-border);
    }

    .user-menu-item {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
        color: var(--color-text);
        text-decoration: none;
        font-size: 0.875rem;
        min-height: var(--touch-target);
        transition: background-color var(--transition-fast);
        background: none;
        border: none;
        width: 100%;
        cursor: pointer;
        text-align: left;
    }

    .user-menu-item:hover {
        background-color: var(--color-bg-subtle);
        text-decoration: none;
    }

    .user-menu-logout {
        color: var(--color-danger);
    }

    .user-menu-logout:hover {
        background-color: rgba(239, 68, 68, 0.1);
    }

    .user-menu-language {
        padding-right: var(--space-sm);
    }

    .user-menu-language-form {
        flex: 1;
        margin: 0;
    }

    .user-menu-language-select {
        width: 100%;
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.875rem;
        background-color: var(--color-bg-subtle);
        color: var(--color-text);
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius-sm);
        cursor: pointer;
    }

    .user-menu-logout-form {
        width: 100%;
        margin: 0;
    }

    .user-menu-badge {
        margin-left: auto;
        font-size: 0.7rem;
        font-weight: 600;
        background-color: var(--color-primary);
        color: var(--color-on-primary);
        border-radius: var(--radius-full, 9999px);
        padding: 1px 6px;
        min-width: 18px;
        text-align: center;
        line-height: 1.4;
    }

    .user-menu-item .nav-icon {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }
    /* ==========================================================================
       Auth pages layout
       ========================================================================== */
    .auth-page {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        background: light-dark(var(--color-bg), linear-gradient(135deg, #1f2937 0%, #111827 100%));
    }

    .auth-page-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-md) var(--space-lg);
        width: 100%;
    }

    .auth-page-header-logo {
        font-size: 1.25rem;
        font-weight: 700;
        color: light-dark(var(--color-text), #ffffff);
        text-decoration: none;
        transition: opacity var(--transition-fast);
    }

    .auth-page-header-logo-img {
        height: 28px;
        width: auto;
        display: block;
    }

    a.auth-page-header-logo:hover {
        opacity: 0.8;
    }

    a.auth-page-header-logo:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
        border-radius: var(--radius-sm);
    }

    .auth-page-header-controls {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        margin-left: auto;
    }

    .auth-page-header-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background-color: light-dark(var(--color-bg-subtle), rgba(255, 255, 255, 0.1));
        border: 1px solid light-dark(var(--color-border), rgba(255, 255, 255, 0.2));
        border-radius: var(--radius-md);
        color: light-dark(var(--color-text), rgba(255, 255, 255, 0.9));
        cursor: pointer;
        transition: all var(--transition-fast);
    }

    .auth-page-header-btn:hover {
        background-color: light-dark(var(--color-bg-muted), rgba(255, 255, 255, 0.2));
    }

    .auth-page-header-btn:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .auth-page-header-language {
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        background-color: light-dark(var(--color-bg-subtle), rgba(255, 255, 255, 0.1));
        border: 1px solid light-dark(var(--color-border), rgba(255, 255, 255, 0.2));
        border-radius: var(--radius-md);
        padding: 0 var(--space-sm);
        height: 40px;
    }

    .auth-page-header-language-icon {
        color: light-dark(var(--color-text-secondary), rgba(255, 255, 255, 0.9));
        flex-shrink: 0;
    }

    .auth-page-header-language-form {
        margin: 0;
    }

    .auth-page-header-language-select {
        background: transparent;
        border: none;
        color: light-dark(var(--color-text), rgba(255, 255, 255, 0.9));
        font-size: 0.875rem;
        cursor: pointer;
        padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
        min-width: 80px;
    }

    .auth-page-header-language-select:focus {
        outline: none;
    }

    .auth-page-header-language-select option {
        background-color: var(--color-bg-elevated);
        color: var(--color-text);
    }

    .auth-page-content {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--space-md);
    }

    .auth-container {
        width: 100%;
        max-width: 400px;
    }

    /* ==========================================================================
       Error pages layout
       ========================================================================== */
    .error-page {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--color-bg);
        padding: var(--space-md);
    }

    .error-container {
        text-align: center;
        max-width: 400px;
    }

    /* Fallback for auth pages without light-dark() support */
    @supports not (color: light-dark(#000, #fff)) {
        .auth-page {
            background: var(--color-bg);
        }
        .auth-page-header-logo {
            color: var(--color-text);
        }
        .auth-page-header-btn {
            background-color: var(--color-bg-subtle);
            border-color: var(--color-border);
            color: var(--color-text);
        }
        .auth-page-header-btn:hover {
            background-color: var(--color-bg-muted);
        }
        .auth-page-header-language {
            background-color: var(--color-bg-subtle);
            border-color: var(--color-border);
        }
        .auth-page-header-language-icon {
            color: var(--color-text-secondary);
        }
        .auth-page-header-language-select {
            color: var(--color-text);
        }

        [data-theme="dark"] .auth-page {
            background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
        }
        [data-theme="dark"] .auth-page-header-logo {
            color: #ffffff;
        }
        [data-theme="dark"] .auth-page-header-btn {
            background-color: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
            color: rgba(255, 255, 255, 0.9);
        }
        [data-theme="dark"] .auth-page-header-btn:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }
        [data-theme="dark"] .auth-page-header-language {
            background-color: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
        }
        [data-theme="dark"] .auth-page-header-language-icon {
            color: rgba(255, 255, 255, 0.9);
        }
        [data-theme="dark"] .auth-page-header-language-select {
            color: rgba(255, 255, 255, 0.9);
        }
    }
}

/* ==========================================================================
   Components Layer - Reusable UI components
   ========================================================================== */
@layer components {
    /* ==========================================================================
       Buttons
       ========================================================================== */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
        font-weight: 500;
        line-height: 1.25rem;
        border-radius: var(--radius-md);
        border: none;
        cursor: pointer;
        transition: all var(--transition-fast);
        text-decoration: none;
        white-space: nowrap;
        min-height: var(--touch-target);
    }

    .btn:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .btn:disabled,
    .btn[disabled] {
        background-color: var(--color-bg-muted);
        color: var(--color-text-muted);
        border-color: var(--color-border);
        cursor: not-allowed;
    }

    .btn-primary {
        background-color: var(--color-primary);
        color: #ffffff;
    }

    .btn-primary:hover:not(:disabled) {
        background-color: var(--color-primary-hover);
        text-decoration: none;
    }

    .btn-secondary {
        background-color: var(--color-bg-muted);
        color: var(--color-text);
    }

    .btn-secondary:hover:not(:disabled) {
        background-color: var(--color-border);
        text-decoration: none;
    }

    .btn-danger {
        background-color: var(--color-danger);
        color: #ffffff;
    }

    .btn-danger:hover:not(:disabled) {
        background-color: var(--color-danger-hover);
        text-decoration: none;
    }

    .btn-ghost {
        background-color: transparent;
        color: var(--color-text-secondary);
    }

    .btn-ghost:hover:not(:disabled) {
        background-color: var(--color-bg-muted);
        color: var(--color-text);
        text-decoration: none;
    }

    .btn-link {
        background: none;
        border: none;
        padding: 0;
        color: inherit;
        font: inherit;
        text-decoration: underline;
        cursor: pointer;
    }

    .btn-link:hover:not(:disabled) {
        text-decoration: none;
    }

    .btn-link:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .btn-link:disabled,
    .btn-link[disabled] {
        color: var(--color-text-muted);
        cursor: not-allowed;
        text-decoration: none;
    }

    .btn-block {
        width: 100%;
    }

    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    .btn-lg {
        padding: 0.625rem 1.25rem;
        font-size: 1rem;
        min-height: 48px;
    }

    /* Alias: use .btn-sm instead */
    .btn-small {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    .btn-logout {
        background-color: transparent;
        color: var(--sidebar-text);
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }

    .btn-logout:hover {
        background-color: var(--sidebar-hover);
        color: #ffffff;
    }

    /* ==========================================================================
       Avatar Component
       ========================================================================== */
    .avatar {
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        overflow: hidden;
        flex-shrink: 0;
        background-color: var(--color-primary);
        color: #ffffff;
    }

    .avatar-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .avatar-initials {
        font-weight: 600;
        text-transform: uppercase;
        line-height: 1;
    }

    /* Avatar sizes */
    .avatar-sm {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .avatar-md {
        width: 40px;
        height: 40px;
        font-size: 0.875rem;
    }

    .avatar-lg {
        width: 64px;
        height: 64px;
        font-size: 1.25rem;
    }

    .avatar-xl {
        width: 96px;
        height: 96px;
        font-size: 1.75rem;
    }

    .file-input {
        display: none;
    }

    /* ==========================================================================
       Cards
       ========================================================================== */
    .card {
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: var(--space-md);
        box-shadow: var(--shadow-sm);
        margin-bottom: var(--space-md);
        container-type: inline-size;
    }

    .card-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: var(--space-sm);
    }

    .card-description {
        color: var(--color-text-secondary);
        font-size: 0.875rem;
        margin-bottom: var(--space-md);
    }

    .card-actions {
        margin-top: var(--space-lg);
        padding-top: var(--space-md);
        border-top: 1px solid var(--color-border);
    }

    /* ==========================================================================
       Auth card
       ========================================================================== */
    .auth-card {
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        padding: var(--space-lg);
    }

    .auth-card-header {
        text-align: center;
        margin-bottom: var(--space-lg);
    }

    .auth-card-logo {
        display: block;
        max-width: 100%;
        max-height: 150px;
        width: auto;
        height: auto;
        margin: 0 auto var(--space-lg);
        object-fit: contain;
    }

    .auth-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--color-text);
        margin-bottom: var(--space-sm);
    }

    .auth-subtitle {
        font-size: 0.875rem;
        font-weight: 400;
        color: var(--color-text-secondary);
    }

    .auth-form {
        margin-top: var(--space-lg);
    }

    .auth-footer {
        margin-top: var(--space-lg);
        text-align: center;
    }

    .auth-footer .link {
        color: var(--color-primary);
        text-decoration: none;
        font-size: 0.875rem;
    }

    .auth-footer .link:hover {
        text-decoration: underline;
    }

    .form-options {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: var(--space-sm);
    }

    .auth-forgot-link {
        color: var(--color-text-muted);
        text-decoration: none;
        font-size: 0.8125rem;
        white-space: nowrap;
        padding-top: 2px;
    }

    .auth-forgot-link:hover {
        color: var(--color-primary);
        text-decoration: underline;
    }

    .auth-plan-banner {
        background-color: var(--color-bg-subtle);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        padding: var(--space-sm) var(--space-md);
        margin-bottom: var(--space-lg);
        text-align: center;
    }

    .auth-plan-banner-name {
        font-weight: 600;
        font-size: 0.9375rem;
        color: var(--color-text);
    }

    .auth-plan-banner-price {
        font-size: 0.875rem;
        color: var(--color-text-muted);
        margin-top: var(--space-xs);
    }

    .auth-plan-banner-trial {
        font-size: 0.8125rem;
        color: var(--color-success);
        margin-top: var(--space-xs);
    }

    .auth-plan-banner-hint {
        font-size: 0.8125rem;
        color: var(--color-text-muted);
        margin-top: var(--space-xs);
    }

    .auth-alt-action {
        margin-top: var(--space-lg);
        padding-top: var(--space-lg);
        border-top: 1px solid var(--color-border);
        text-align: center;
        font-size: 0.875rem;
    }

    .auth-alt-action-text {
        color: var(--color-text-muted);
    }

    .auth-alt-action-link {
        color: var(--color-primary);
        text-decoration: none;
        font-weight: 600;
    }

    .auth-alt-action-link:hover {
        text-decoration: underline;
    }

    /* ==========================================================================
       Forms
       ========================================================================== */
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group label {
        display: block;
        margin-bottom: var(--space-sm);
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--color-text-secondary);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 0.625rem 0.875rem;
        font-size: 1rem;
        line-height: 1.5;
        color: var(--color-text);
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius-md);
        transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
        min-height: var(--touch-target);
    }

    .form-group textarea {
        min-height: 120px;
        resize: vertical;
        font-family: inherit;
    }

    .form-group .form-static {
        padding: 0.625rem 0.875rem;
        font-size: 1rem;
        line-height: 1.5;
        color: var(--color-text-secondary);
        background-color: var(--color-bg-subtle);
        border: 1px dashed var(--color-border);
        border-radius: var(--radius-md);
    }

    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        outline: none;
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px var(--color-primary-light);
    }

    .form-group input::placeholder,
    .form-group textarea::placeholder {
        color: var(--color-text-muted);
    }

    /* Password input with toggle */
    .password-input-wrapper {
        position: relative;
        display: flex;
        align-items: center;
    }

    .password-input-wrapper input {
        padding-right: 3rem;
    }

    .password-toggle {
        position: absolute;
        right: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.25rem;
        height: 2.25rem;
        background: transparent;
        border: none;
        border-radius: var(--radius-sm);
        color: var(--color-text-muted);
        cursor: pointer;
        transition: color var(--transition-fast);
    }

    .password-toggle:hover {
        color: var(--color-text);
    }

    .password-toggle:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .password-toggle .icon-hide {
        display: none;
    }

    .password-toggle[aria-pressed="true"] .icon-show {
        display: none;
    }

    .password-toggle[aria-pressed="true"] .icon-hide {
        display: block;
    }

    /* Password strength indicator */
    .password-strength {
        margin-top: var(--space-sm);
    }

    .password-strength-bar {
        height: 4px;
        background-color: var(--color-border);
        border-radius: 2px;
        overflow: hidden;
    }

    .password-strength-fill {
        height: 100%;
        width: 0;
        border-radius: 2px;
        transition: width var(--transition-fast), background-color var(--transition-fast);
    }

    .password-strength-fill[data-strength="weak"] {
        width: 33%;
        background-color: var(--color-danger);
    }

    .password-strength-fill[data-strength="medium"] {
        width: 66%;
        background-color: var(--color-warning);
    }

    .password-strength-fill[data-strength="strong"] {
        width: 100%;
        background-color: var(--color-success);
    }

    .password-strength-text {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: var(--space-xs);
        font-size: 0.75rem;
        color: var(--color-text-muted);
    }

    .password-strength-label {
        font-weight: 500;
    }

    .password-strength-label[data-strength="weak"] {
        color: var(--color-danger);
    }

    .password-strength-label[data-strength="medium"] {
        color: var(--color-warning);
    }

    .password-strength-label[data-strength="strong"] {
        color: var(--color-success);
    }

    /* Password requirements checklist */
    .password-requirements {
        margin-top: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
        background: var(--color-bg-subtle);
        border-radius: var(--radius-md);
        border: 1px solid var(--color-border);
    }

    .password-requirements-title {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.025em;
        margin-bottom: var(--space-xs);
    }

    .password-requirements-list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .password-requirements-list li {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.8125rem;
        color: var(--color-text-muted);
        transition: color var(--transition-fast);
    }

    .password-requirements-list li.valid {
        color: var(--color-success);
    }

    .password-requirements-list li.invalid {
        color: var(--color-danger);
    }

    .password-rule-icon {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .password-rule-icon::before {
        content: "○";
        font-size: 0.625rem;
    }

    .password-requirements-list li.valid .password-rule-icon::before {
        content: "✓";
        font-size: 0.875rem;
    }

    .password-requirements-list li.invalid .password-rule-icon::before {
        content: "✗";
        font-size: 0.875rem;
    }

    /* Password match feedback */
    .password-match-feedback {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-top: var(--space-xs);
        font-size: 0.8125rem;
    }

    .password-match-feedback.match {
        color: var(--color-success);
    }

    .password-match-feedback.no-match {
        color: var(--color-danger);
    }

    .password-match-icon {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .password-match-feedback.match .password-match-icon::before {
        content: "✓";
    }

    .password-match-feedback.no-match .password-match-icon::before {
        content: "✗";
    }

    /* ==========================================================================
       Alerts
       ========================================================================== */
    .alert {
        padding: 0.875rem var(--space-md);
        margin-bottom: 1.25rem;
        border-radius: var(--radius-md);
        font-size: 0.875rem;
    }

    .alert-error {
        background-color: light-dark(#fef2f2, #450a0a);
        border: 1px solid light-dark(#fecaca, #7f1d1d);
        color: light-dark(#991b1b, #fecaca);
    }

    .alert-success {
        background-color: light-dark(#f0fdf4, #052e16);
        border: 1px solid light-dark(#bbf7d0, #166534);
        color: light-dark(#166534, #bbf7d0);
        transition: opacity 0.4s ease-out;
    }

    .alert-info {
        background-color: light-dark(#eff6ff, #1e3a5f);
        border: 1px solid light-dark(#bfdbfe, #1e40af);
        color: light-dark(#1e40af, #bfdbfe);
    }

    .alert-info a {
        color: inherit;
        word-break: break-all;
    }

    .alert-warning {
        background-color: light-dark(#fffbeb, #451a03);
        border: 1px solid light-dark(#fde68a, #92400e);
        color: light-dark(#92400e, #fde68a);
    }

    /* Alias: use .alert-error instead */
    .alert-danger {
        background-color: light-dark(#fef2f2, #450a0a);
        border: 1px solid light-dark(#fecaca, #7f1d1d);
        color: light-dark(#991b1b, #fecaca);
    }

    /* Fallback for alerts without light-dark() */
    @supports not (color: light-dark(#000, #fff)) {
        .alert-error {
            background-color: #fef2f2;
            border: 1px solid #fecaca;
            color: #991b1b;
        }

        .alert-success {
            background-color: #f0fdf4;
            border: 1px solid #bbf7d0;
            color: #166534;
            transition: opacity 0.4s ease-out;
        }

        .alert-info {
            background-color: #eff6ff;
            border: 1px solid #bfdbfe;
            color: #1e40af;
        }

        .alert-warning {
            background-color: #fffbeb;
            border: 1px solid #fde68a;
            color: #92400e;
        }

        /* Alias: use .alert-error instead */
        .alert-danger {
            background-color: #fef2f2;
            border: 1px solid #fecaca;
            color: #991b1b;
        }

        [data-theme="dark"] .alert-error {
            background-color: #450a0a;
            border-color: #7f1d1d;
            color: #fecaca;
        }

        [data-theme="dark"] .alert-success {
            background-color: #052e16;
            border-color: #166534;
            color: #bbf7d0;
        }

        [data-theme="dark"] .alert-info {
            background-color: #1e3a5f;
            border-color: #1e40af;
            color: #bfdbfe;
        }

        [data-theme="dark"] .alert-warning {
            background-color: #451a03;
            border-color: #92400e;
            color: #fde68a;
        }

        /* Alias: use .alert-error instead */
        [data-theme="dark"] .alert-danger {
            background-color: #450a0a;
            border-color: #7f1d1d;
            color: #fecaca;
        }

        .admin-badge {
            background-color: rgba(245, 158, 11, 0.15);
            border: 1px solid rgba(245, 158, 11, 0.3);
        }

        .role-badge-admin {
            border-color: rgba(59, 130, 246, 0.3);
        }

        .status-badge.status-enabled {
            background-color: rgba(34, 197, 94, 0.1);
        }

        [data-theme="dark"] .admin-badge {
            background-color: rgba(245, 158, 11, 0.2);
            border-color: rgba(245, 158, 11, 0.4);
        }

        [data-theme="dark"] .role-badge-admin {
            border-color: rgba(59, 130, 246, 0.4);
        }

        [data-theme="dark"] .status-badge.status-enabled {
            background-color: rgba(34, 197, 94, 0.15);
        }
    }

    /* ==========================================================================
       Language switcher (legacy - kept for auth pages)
       ========================================================================== */
    .language-switcher {
        display: inline-flex;
    }

    .language-form {
        margin: 0;
    }

    .language-select {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.875rem;
        background-color: var(--color-bg-subtle);
        color: var(--color-text);
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius-sm);
        cursor: pointer;
    }

    .language-select:focus {
        outline: none;
        border-color: var(--color-primary);
    }

    /* ==========================================================================
       Theme toggle
       ========================================================================== */
    .theme-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        background-color: var(--color-bg-subtle);
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius-sm);
        cursor: pointer;
        color: var(--color-text-secondary);
        transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    }

    .theme-toggle:hover {
        background-color: var(--color-bg-elevated);
        border-color: var(--color-primary);
        color: var(--color-primary);
    }

    .theme-toggle:focus {
        outline: none;
        border-color: var(--color-primary);
        box-shadow: 0 0 0 2px var(--color-primary-light);
    }

    /* Theme icons visibility */
    .theme-icon {
        display: none;
    }

    .theme-icon-system {
        display: block;
    }

    [data-theme="light"] .theme-icon-system,
    html:not([data-theme]) .theme-icon-system {
        display: none;
    }

    [data-theme="light"] .theme-icon-light,
    html:not([data-theme]) .theme-icon-light {
        display: block;
    }

    [data-theme="dark"] .theme-icon-system {
        display: none;
    }

    [data-theme="dark"] .theme-icon-dark {
        display: block;
    }

    .theme-toggle[data-current-theme="light"] .theme-icon { display: none; }
    .theme-toggle[data-current-theme="light"] .theme-icon-light { display: block; }

    .theme-toggle[data-current-theme="dark"] .theme-icon { display: none; }
    .theme-toggle[data-current-theme="dark"] .theme-icon-dark { display: block; }

    .theme-toggle[data-current-theme="system"] .theme-icon { display: none; }
    .theme-toggle[data-current-theme="system"] .theme-icon-system { display: block; }

    /* Theme icons in menus */
    .user-menu-item .theme-icon {
        flex-shrink: 0;
    }

    /* ==========================================================================
       Admin Badge
       ========================================================================== */
    .admin-badge {
        display: inline-flex;
        align-items: center;
        padding: 0.125rem 0.5rem;
        font-size: 0.625rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--color-warning);
        background-color: light-dark(rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.2));
        border: 1px solid light-dark(rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.4));
        border-radius: var(--radius-sm);
    }

    /* ==========================================================================
       Section title
       ========================================================================== */
    .section-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--color-text-secondary);
        margin-top: var(--space-xl);
        margin-bottom: var(--space-md);
        padding-bottom: var(--space-sm);
        border-bottom: 2px solid var(--color-border);
    }

    /* ==========================================================================
       Dashboard
       ========================================================================== */
    .dashboard-welcome {
        margin-bottom: var(--space-md);
    }

    .welcome-card {
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: var(--space-md);
        box-shadow: var(--shadow-sm);
    }

    .welcome-card h3 {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: var(--space-sm);
    }

    .welcome-card p {
        color: var(--color-text-secondary);
        font-size: 0.875rem;
    }

    .dashboard-placeholder {
        display: grid;
        gap: var(--space-md);
    }

    .placeholder-card {
        background-color: var(--color-bg-elevated);
        border-radius: var(--radius-md);
        padding: var(--space-xl);
        box-shadow: var(--shadow-md);
        text-align: center;
        border: 2px dashed var(--color-border);
    }

    .placeholder-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 64px;
        height: 64px;
        background-color: var(--color-bg-subtle);
        border-radius: 50%;
        margin-bottom: var(--space-md);
        color: var(--color-text-muted);
    }

    .placeholder-icon svg {
        width: 32px;
        height: 32px;
    }

    .placeholder-card h4 {
        font-size: 1rem;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: var(--space-sm);
    }

    .placeholder-card p {
        color: var(--color-text-secondary);
        font-size: 0.875rem;
        max-width: 300px;
        margin: 0 auto;
    }

    /* ==========================================================================
       Error pages
       ========================================================================== */
    .error-code {
        font-size: clamp(4rem, 15vw, 6rem);
        font-weight: 700;
        color: var(--color-border);
        line-height: 1;
        margin-bottom: var(--space-sm);
    }

    .error-title {
        font-size: 1.5rem;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: var(--space-sm);
    }

    .error-message {
        font-size: 1rem;
        color: var(--color-text-secondary);
        margin-bottom: var(--space-lg);
    }

    /* ==========================================================================
       Credentials list
       ========================================================================== */
    .credentials-list {
        margin: var(--space-md) 0;
    }

    .credential-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-sm) var(--space-md);
        background-color: var(--color-bg-subtle);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-sm);
        gap: var(--space-md);
        container-type: inline-size;
    }

    .credential-info {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .credential-name {
        font-weight: 500;
        color: var(--color-text);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .credential-date {
        font-size: 0.75rem;
        color: var(--color-text-muted);
    }

    .credential-actions {
        display: flex;
        gap: var(--space-sm);
        flex-shrink: 0;
    }

    @container (max-width: 400px) {
        .credential-item {
            flex-direction: column;
            align-items: stretch;
        }

        .credential-actions {
            margin-top: var(--space-sm);
            justify-content: flex-end;
        }
    }

    .inline-form {
        display: inline;
    }

    .empty-state {
        color: var(--color-text-muted);
        font-style: italic;
        padding: var(--space-md) 0;
    }

    /* ==========================================================================
       Recovery codes
       ========================================================================== */
    .recovery-codes-display {
        background-color: var(--color-bg-subtle);
        border-radius: var(--radius-md);
        padding: var(--space-md);
        margin: var(--space-md) 0;
    }

    .warning-text {
        color: var(--color-warning);
        font-weight: 500;
        margin-bottom: var(--space-md);
    }

    .codes-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--space-sm);
        margin-bottom: var(--space-md);
    }

    .recovery-code-item {
        display: flex;
        align-items: center;
        background-color: var(--color-bg-elevated);
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-sm);
        border: 1px solid var(--color-border);
    }

    .code-number {
        font-size: 0.75rem;
        color: var(--color-text-muted);
        margin-right: var(--space-sm);
        min-width: 1.5rem;
    }

    .recovery-code {
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        font-size: 0.875rem;
        letter-spacing: 0.05em;
        color: var(--color-text);
    }

    .recovery-codes-actions {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        padding-top: var(--space-sm);
        border-top: 1px solid var(--color-border);
    }

    .copy-status {
        font-size: 0.875rem;
        transition: opacity var(--transition-fast);
    }

    .copy-status.success {
        color: var(--color-success);
    }

    .copy-status.error {
        color: var(--color-danger);
    }

    .recovery-status {
        color: var(--color-text-secondary);
        margin: var(--space-md) 0;
    }

    .status-enabled {
        color: var(--color-success);
    }

    .status-disabled {
        color: var(--color-text-muted);
    }

    /* ==========================================================================
       Modal Actions (legacy support for forms with button groups)
       ========================================================================== */
    .modal-actions {
        display: flex;
        justify-content: flex-end;
        gap: var(--space-sm);
        margin-top: var(--space-lg);
    }

    /* ==========================================================================
       2FA page
       ========================================================================== */
    .twofa-section {
        margin: var(--space-lg) 0;
    }

    .twofa-section h3 {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: var(--space-sm);
        color: var(--color-text);
    }

    .twofa-section p {
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        margin-bottom: var(--space-md);
    }

    .divider {
        display: flex;
        align-items: center;
        margin: var(--space-lg) 0;
    }

    .divider::before,
    .divider::after {
        content: '';
        flex: 1;
        height: 1px;
        background-color: var(--color-border);
    }

    .divider span {
        padding: 0 var(--space-md);
        color: var(--color-text-muted);
        font-size: 0.875rem;
    }

    .status-message {
        margin-top: var(--space-md);
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        text-align: center;
    }

    .status-message.error {
        color: var(--color-danger);
    }

    /* ==========================================================================
       Checkbox
       ========================================================================== */
    .form-checkbox {
        margin: var(--space-lg) 0;
    }

    .checkbox-label {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        cursor: pointer;
        font-size: 0.875rem;
        color: var(--color-text);
        user-select: none;
        position: relative;
        min-height: var(--touch-target);
        padding: var(--space-xs) 0;
    }

    .checkbox-label input[type="checkbox"] {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
        pointer-events: none;
    }

    .checkbox-box {
        position: relative;
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        border: 2px solid var(--color-border);
        border-radius: var(--radius-sm);
        background-color: var(--color-bg-elevated);
        transition: all var(--transition-fast);
        margin-top: 2px;
    }

    .checkbox-box::after {
        content: '';
        position: absolute;
        display: none;
        left: 6px;
        top: 2px;
        width: 5px;
        height: 10px;
        border: solid white;
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
    }

    .checkbox-label input[type="checkbox"]:checked + .checkbox-box {
        background-color: var(--color-primary);
        border-color: var(--color-primary);
    }

    .checkbox-label input[type="checkbox"]:checked + .checkbox-box::after {
        display: block;
    }

    .checkbox-label input[type="checkbox"]:focus-visible + .checkbox-box {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .checkbox-label:hover .checkbox-box {
        border-color: var(--color-primary);
    }

    /* Simplified checkbox with native styling for form checkboxes */
    .checkbox-group {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        margin-top: var(--space-sm);
    }

    .checkbox-group .checkbox-label {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
        background-color: var(--color-bg-subtle);
        border-radius: var(--radius-md);
        border: 1px solid var(--color-border);
        transition: all var(--transition-fast);
        cursor: pointer;
    }

    .checkbox-group .checkbox-label:hover {
        border-color: var(--color-primary);
        background-color: var(--color-bg-elevated);
    }

    .checkbox-group .checkbox-label:has(input:checked) {
        border-color: var(--color-primary);
        background-color: var(--color-primary-light);
    }

    .checkbox-group .checkbox-label input[type="checkbox"] {
        position: static;
        opacity: 1;
        width: 18px;
        height: 18px;
        pointer-events: auto;
        accent-color: var(--color-primary);
        cursor: pointer;
        flex-shrink: 0;
    }

    .checkbox-text {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        font-size: 0.875rem;
        color: var(--color-text);
    }

    .badge-small {
        display: inline-flex;
        padding: 0.125rem 0.375rem;
        font-size: 0.6875rem;
        font-weight: 500;
        border-radius: var(--radius-sm);
        background-color: var(--color-bg-subtle);
        color: var(--color-text-muted);
    }

    .badge-small.badge-admin {
        color: var(--color-primary);
        background-color: var(--color-primary-light);
    }

    .checkbox-content {
        display: flex;
        flex-direction: column;
        gap: 2px;
        line-height: 1.4;
    }

    .checkbox-title {
        font-weight: 500;
        color: var(--color-text);
    }

    .checkbox-hint {
        font-size: 0.75rem;
        color: var(--color-text-muted);
        font-weight: 400;
    }

    /* ==========================================================================
       Admin Components
       ========================================================================== */

    /* Admin stats grid */
    .admin-stats,
    .stat-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--space-md);
        margin-bottom: var(--space-xl);
    }

    /* Stat cards */
    .stat-card {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: var(--space-md);
        box-shadow: var(--shadow-sm);
        position: relative;
        overflow: hidden;
    }

    .stat-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 4px;
        height: 100%;
        background-color: var(--color-primary);
    }

    .stat-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        background-color: var(--color-primary-light);
        border-radius: var(--radius-md);
        color: var(--color-primary);
        flex-shrink: 0;
    }

    .stat-icon svg {
        width: 24px;
        height: 24px;
    }

    .stat-content {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-width: 0;
    }

    .stat-value {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--color-text);
        line-height: 1.2;
    }

    .stat-label {
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        margin-top: 0.125rem;
    }

    .stat-link {
        font-size: 0.75rem;
        color: var(--color-primary);
        text-decoration: none;
        white-space: nowrap;
        transition: color var(--transition-fast);
    }

    .stat-link:hover {
        color: var(--color-primary-hover);
        text-decoration: underline;
    }

    /* Quick actions */
    .admin-quick-actions {
        margin-bottom: var(--space-xl);
    }

    .admin-quick-actions h3 {
        font-size: 1rem;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: var(--space-md);
    }

    .quick-actions-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }

    .quick-action-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
        padding: var(--space-md);
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        text-decoration: none;
        color: var(--color-text);
        transition: all var(--transition-fast);
        min-height: var(--touch-target);
    }

    .quick-action-card:hover {
        border-color: var(--color-primary);
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
        text-decoration: none;
    }

    .quick-action-card svg {
        width: 28px;
        height: 28px;
        color: var(--color-primary);
    }

    .quick-action-card span {
        font-size: 0.8125rem;
        font-weight: 500;
        text-align: center;
    }

    /* ==========================================================================
       Navigation Cards
       Reusable component for settings/admin navigation links with icon
       ========================================================================== */
    .nav-card-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--space-md);
    }

    .nav-card {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        padding: var(--space-lg);
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        text-decoration: none;
        color: var(--color-text);
        transition: all var(--transition-fast);
    }

    .nav-card:hover {
        border-color: var(--color-primary);
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
        text-decoration: none;
    }

    .nav-card-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        background-color: var(--color-primary);
        border-radius: var(--radius-md);
        color: white;
        flex-shrink: 0;
    }

    .nav-card-icon svg {
        width: 24px;
        height: 24px;
    }

    .nav-card-content h3 {
        margin: 0 0 0.25rem 0;
        font-size: 1rem;
        font-weight: 600;
        color: var(--color-text);
    }

    .nav-card-content p {
        margin: 0;
        font-size: 0.875rem;
        color: var(--color-text-muted);
    }

    /* Stat card details (sub-statistics) */
    .stat-details {
        display: flex;
        gap: var(--space-sm);
        margin-top: var(--space-xs);
        flex-wrap: wrap;
    }

    .stat-detail {
        font-size: 0.75rem;
        padding: 0.125rem 0.375rem;
        border-radius: var(--radius-sm);
    }

    .stat-detail-success {
        background-color: var(--color-success-light);
        color: var(--color-success);
    }

    .stat-detail-warning {
        background-color: var(--color-warning-light);
        color: var(--color-warning);
    }

    /* Warning state for stat cards */
    .stat-card-warning::before {
        background-color: var(--color-warning);
    }

    .stat-icon-warning {
        background-color: var(--color-warning-light);
        color: var(--color-warning);
    }

    /* Recent activity section */
    .admin-recent-activity {
        margin-bottom: var(--space-xl);
    }

    .recent-activity-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--space-md);
    }

    .recent-activity-header h3 {
        font-size: 1rem;
        font-weight: 600;
        color: var(--color-text);
        margin: 0;
    }

    .recent-activity-link {
        font-size: 0.875rem;
        color: var(--color-primary);
        text-decoration: none;
    }

    .recent-activity-link:hover {
        text-decoration: underline;
    }

    .recent-activity-list {
        background-color: var(--color-bg-elevated);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        overflow: hidden;
    }

    .recent-activity-item {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        padding: var(--space-sm) var(--space-md);
        border-bottom: 1px solid var(--color-border);
    }

    .recent-activity-item:last-child {
        border-bottom: none;
    }

    .recent-activity-item-failure {
        background-color: var(--color-danger-light);
    }

    .recent-activity-time {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        min-width: 50px;
        flex-shrink: 0;
    }

    .activity-date {
        font-size: 0.75rem;
        color: var(--color-text-secondary);
    }

    .activity-time {
        font-size: 0.75rem;
        font-weight: 500;
        color: var(--color-text);
    }

    .recent-activity-content {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
    }

    .activity-action {
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--color-text);
    }

    .activity-user {
        font-size: 0.75rem;
        color: var(--color-text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .recent-activity-status {
        flex-shrink: 0;
    }

    .status-dot {
        display: block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }

    .status-dot-success {
        background-color: var(--color-success);
    }

    .status-dot-failure {
        background-color: var(--color-danger);
    }

    .recent-activity-empty {
        padding: var(--space-lg);
        text-align: center;
        color: var(--color-text-secondary);
        background-color: var(--color-bg-elevated);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
    }

    /* Admin tables */
    .admin-table-container {
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.875rem;
        min-width: 600px;
    }

    .admin-table thead {
        background-color: var(--color-bg-subtle);
        border-bottom: 2px solid var(--color-border);
    }

    .admin-table th {
        padding: var(--space-md) var(--space-md);
        text-align: left;
        font-weight: 600;
        color: var(--color-text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        white-space: nowrap;
    }

    .admin-table td {
        padding: var(--space-md) var(--space-md);
        color: var(--color-text);
        border-bottom: 1px solid var(--color-border);
        vertical-align: middle;
    }

    .admin-table tbody tr {
        transition: background-color var(--transition-fast);
    }

    .admin-table tbody tr:hover {
        background-color: var(--color-bg-subtle);
    }

    .admin-table tbody tr:last-child td {
        border-bottom: none;
    }

    .actions-cell {
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: var(--space-xs);
    }

    /* Badges */
    .role-badge {
        display: inline-flex;
        align-items: center;
        padding: 0.25rem 0.625rem;
        font-size: 0.75rem;
        font-weight: 500;
        color: var(--color-text);
        background-color: var(--color-bg-subtle);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-full);
    }

    .role-badge-admin {
        color: var(--color-primary);
        background-color: var(--color-primary-light);
        border-color: light-dark(rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.4));
    }

    .role-badge-none {
        color: var(--color-text-muted);
        background-color: transparent;
        border-style: dashed;
    }

    .role-badge-more {
        color: var(--color-text-muted);
        background-color: var(--color-bg-muted);
        cursor: help;
    }

    .role-badge + .role-badge {
        margin-left: 0.25rem;
    }

    .status-badge {
        display: inline-flex;
        align-items: center;
        gap: var(--space-xs);
        padding: 0.125rem 0.5rem;
        font-size: 0.75rem;
        font-weight: 500;
        border-radius: var(--radius-full);
        background-color: var(--color-bg-subtle);
        color: var(--color-text-secondary);
        white-space: nowrap;
    }

    .status-badge.status-enabled {
        color: var(--color-success);
        background-color: light-dark(rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.15));
    }

    .status-badge.status-disabled {
        color: var(--color-text-muted);
        background-color: var(--color-bg-subtle);
    }

    /* User account status badges */
    .status-badge.status-active {
        color: var(--color-success);
        background-color: light-dark(rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.15));
    }

    .status-badge.status-suspended {
        color: var(--color-danger);
        background-color: light-dark(rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.15));
    }

    .status-badge.status-pending {
        color: light-dark(#92400e, #fbbf24);
        background-color: light-dark(rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.2));
    }

    .status-badge.status-danger {
        color: var(--color-danger);
        background-color: light-dark(rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.15));
    }

    .status-badge.status-inactive {
        color: var(--color-text-muted);
        background-color: var(--color-bg-subtle);
    }

    .status-badge-icon {
        width: 12px;
        height: 12px;
    }

    /* General purpose badges */
    .badge {
        display: inline-flex;
        align-items: center;
        padding: 0.125rem 0.5rem;
        font-size: 0.75rem;
        font-weight: 500;
        border-radius: var(--radius-sm);
        background-color: var(--color-bg-subtle);
        color: var(--color-text-secondary);
        white-space: nowrap;
    }

    .badge-success {
        color: var(--color-success);
        background-color: var(--color-success-light);
    }

    .badge-danger {
        color: var(--color-danger);
        background-color: var(--color-danger-light);
    }

    .badge-error {
        color: var(--color-danger);
        background-color: var(--color-danger-light);
    }

    .badge-warning {
        color: light-dark(#92400e, #fbbf24);
        background-color: var(--color-warning-light);
    }

    .badge-info {
        color: var(--color-primary);
        background-color: var(--color-primary-light);
    }

    .badge-primary {
        color: var(--color-primary);
        background-color: var(--color-primary-light);
    }

    .badge-secondary {
        color: var(--color-text-muted);
        background-color: var(--color-bg-subtle);
    }

    .permissions-count,
    .permissions-info {
        font-size: 0.875rem;
        color: var(--color-text-secondary);
    }

    /* Back link */
    .back-link {
        display: inline-flex;
        align-items: center;
        gap: var(--space-xs);
        margin-bottom: var(--space-lg);
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        text-decoration: none;
        transition: color var(--transition-fast);
        min-height: var(--touch-target);
    }

    .back-link:hover {
        color: var(--color-primary);
        text-decoration: none;
    }

    .back-link svg {
        width: 16px;
        height: 16px;
    }

    /* Admin form */
    .admin-form-container {
        max-width: 640px;
    }

    .form-card {
        background-color: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: var(--space-md);
        box-shadow: var(--shadow-sm);
    }

    .form-card h3 {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--color-text);
        margin-bottom: var(--space-lg);
        padding-bottom: var(--space-md);
        border-bottom: 1px solid var(--color-border);
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        flex-wrap: wrap;
    }

    .role-type-label {
        font-size: 0.75rem;
        font-weight: 400;
        color: var(--color-text-muted);
    }

    .form-info {
        margin: var(--space-lg) 0;
        padding: var(--space-md);
        background-color: var(--color-bg-subtle);
        border-radius: var(--radius-md);
        border-left: 3px solid var(--color-primary);
    }

    .form-info p {
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        margin: 0;
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        flex-wrap: wrap;
    }

    .form-info strong {
        color: var(--color-text);
    }

    .form-actions {
        display: flex;
        gap: var(--space-sm);
        margin-top: var(--space-lg);
        padding-top: var(--space-lg);
        border-top: 1px solid var(--color-border);
    }

    /* Permissions fieldset */
    fieldset.form-group {
        border: none;
        padding: 0;
        margin: 0 0 1.25rem 0;
    }

    fieldset.form-group legend {
        display: block;
        margin-bottom: var(--space-sm);
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--color-text-secondary);
    }

    .permissions-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--space-sm);
        margin-top: var(--space-sm);
    }

    .permissions-grid .checkbox-label {
        padding: var(--space-sm) var(--space-md);
        background-color: var(--color-bg-subtle);
        border-radius: var(--radius-md);
        border: 1px solid var(--color-border-strong);
        transition: all var(--transition-fast);
    }

    .permissions-grid .checkbox-label:hover {
        border-color: var(--color-primary);
        background-color: var(--color-bg-elevated);
    }

    .permissions-grid .checkbox-label .checkbox-content span {
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        font-size: 0.8125rem;
        color: var(--color-text);
    }

    .permissions-grid .checkbox-label .checkbox-content small {
        display: block;
        font-size: 0.75rem;
        color: var(--color-text-muted);
        margin-top: 0.125rem;
        font-family: inherit;
    }
}

/* ==========================================================================
   Utilities Layer - Helper classes
   ========================================================================== */
@layer utilities {
    /* Display */
    .hidden {
        display: none !important;
    }

    .d-flex {
        display: flex;
    }

    .d-grid {
        display: grid;
    }

    .d-inline-flex {
        display: inline-flex;
    }

    .d-block {
        display: block;
    }

    /* Flexbox direction & wrap */
    .flex-column {
        flex-direction: column;
    }

    .flex-wrap {
        flex-wrap: wrap;
    }

    /* Flexbox alignment */
    .items-center {
        align-items: center;
    }

    .items-start {
        align-items: flex-start;
    }

    .justify-between {
        justify-content: space-between;
    }

    .justify-center {
        justify-content: center;
    }

    .justify-end {
        justify-content: flex-end;
    }

    /* Gap (using design tokens) */
    .gap-xs {
        gap: var(--space-xs);
    }

    .gap-sm {
        gap: var(--space-sm);
    }

    .gap-md {
        gap: var(--space-md);
    }

    .gap-lg {
        gap: var(--space-lg);
    }

    .gap-xl {
        gap: var(--space-xl);
    }

    /* Text alignment */
    .text-center {
        text-align: center;
    }

    .text-right {
        text-align: right;
    }

    /* Text color */
    .text-muted {
        color: var(--color-text-muted);
    }

    .text-secondary {
        color: var(--color-text-secondary);
    }

    /* Font utilities */
    .font-bold {
        font-weight: 700;
    }

    .font-semibold {
        font-weight: 600;
    }

    .font-lg {
        font-size: 1.25rem;
    }

    .font-xl {
        font-size: 1.5rem;
    }

    .font-2xl {
        font-size: 2rem;
    }

    /* Spacing - margin bottom */
    .mb-0 {
        margin-bottom: 0;
    }

    .mb-xs {
        margin-bottom: var(--space-xs);
    }

    .mb-sm {
        margin-bottom: var(--space-sm);
    }

    .mb-md {
        margin-bottom: var(--space-md);
    }

    .mb-lg {
        margin-bottom: var(--space-lg);
    }

    .mb-xl {
        margin-bottom: var(--space-xl);
    }

    /* Spacing - margin top */
    .mt-0 {
        margin-top: 0;
    }

    .mt-sm {
        margin-top: var(--space-sm);
    }

    .mt-md {
        margin-top: var(--space-md);
    }

    .mt-lg {
        margin-top: var(--space-lg);
    }

    /* Display - additional */
    .d-inline {
        display: inline;
    }

    /* Flexbox - additional */
    .flex-1 {
        flex: 1;
    }

    /* Spacing - margin right */
    .mr-xs {
        margin-right: var(--space-xs);
    }

    .mr-sm {
        margin-right: var(--space-sm);
    }

    /* Spacing - margin left */
    .ml-xs {
        margin-left: var(--space-xs);
    }

    .ml-sm {
        margin-left: var(--space-sm);
    }

    /* Sizing */
    .h-full {
        height: 100%;
    }

    .max-w-sm {
        max-width: 400px;
    }

    .max-w-md {
        max-width: 500px;
    }

    .max-w-lg {
        max-width: 700px;
    }

    /* Border radius */
    .rounded-full {
        border-radius: var(--radius-full);
    }

    /* Font - additional */
    .font-mono {
        font-family: monospace;
    }

    .font-sm {
        font-size: 0.875rem;
    }

    /* Grid layouts */
    .grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-md);
    }

    .grid-auto-fit {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: var(--space-md);
    }

    /* Dividers */
    .section-divider {
        padding-top: var(--space-lg);
        border-top: 1px solid var(--color-border);
    }

    /* Accessibility */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* ==========================================================================
   Responsive Styles - Mobile grid stacking
   ========================================================================== */
@media (max-width: 767px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Responsive Styles - Tablet (768px+)
   ========================================================================== */
@media (min-width: 768px) {
    :root {
        --sidebar-width: var(--sidebar-width-mini);
    }

    .app-layout {
        padding-bottom: 0;
    }

    /* Header hidden on tablet+ when sidebar is visible */
    .app-header {
        display: none;
    }

    /* Main content - no top margin when header is hidden */
    .main-content {
        margin-top: 0;
    }

    /* Sidebar visible as mini */
    .sidebar {
        transform: translateX(0);
        width: var(--sidebar-width-mini);
        /* Allow dropdowns to overflow sidebar bounds (user menu) */
        overflow: visible;
    }

    .sidebar-overlay {
        display: none;
    }

    .sidebar-header {
        padding: var(--space-sm);
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    /* Tablet+: hide sidebar logo (shown in content-top-bar instead) */
    .sidebar-logo {
        display: none;
    }

    .sidebar-close {
        display: none;
    }

    /* Tablet+: show sidebar toggle (hamburger) */
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: none;
        border: none;
        color: var(--sidebar-text);
        cursor: pointer;
        border-radius: var(--radius-md);
        padding: 0;
        flex-shrink: 0;
        transition: background var(--transition-fast);
    }

    .sidebar-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    /* Mini mode: hide section headers and chevrons */
    .nav-section-header {
        display: none;
    }

    .nav-section-title {
        display: none;
    }

    .nav-section-chevron {
        display: none;
    }

    /* In mini mode, always show all items (ignore collapsed state) */
    .nav-section.collapsed .nav-section-items {
        max-height: none;
    }

    .nav-item {
        padding: 0.75rem;
        justify-content: center;
        overflow: visible;
    }

    .nav-label {
        display: none;
    }

    /* Allow tooltips to overflow outside nav containers in mini mode */
    .sidebar-nav {
        overflow: visible;
    }

    .nav-section-items {
        overflow: visible;
    }

    /* Utility zone in mini mode */
    .sidebar-utility {
        align-items: center;
    }

    .sidebar-utility-item {
        justify-content: center;
        padding: 0.75rem;
        overflow: visible;
        position: relative;
    }

    .sidebar-utility-label {
        display: none;
    }

    .sidebar-utility-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        margin-left: 0;
        min-width: 16px;
        height: 16px;
        font-size: 0.625rem;
        padding: 0 4px;
    }

    /* Tooltips in mini mode for all sidebar elements with data-tooltip */
    .nav-item[data-tooltip]:hover::after,
    .sidebar-toggle[data-tooltip]:hover::after,
    .sidebar-utility-item[data-tooltip]:hover::after,
    .user-menu-trigger[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + var(--space-sm));
        top: 50%;
        transform: translateY(-50%);
        padding: var(--space-xs) var(--space-sm);
        background-color: var(--color-text);
        color: var(--color-text-inverted);
        font-size: 0.75rem;
        border-radius: var(--radius-sm);
        white-space: nowrap;
        z-index: 10;
    }

    /* Toggle and user-menu-trigger need relative positioning for tooltip */
    .sidebar-toggle,
    .user-menu-trigger {
        position: relative;
    }

    /* Hide user menu tooltip when dropdown is open */
    .user-menu.open .user-menu-trigger[data-tooltip]:hover::after {
        display: none;
    }

    /* Tooltips for content-top-bar elements (positioned below) */
    .content-top-bar [data-tooltip] {
        position: relative;
    }

    .content-top-bar [data-tooltip]:hover::after,
    .content-top-bar [data-tooltip]:focus-visible::after {
        content: attr(data-tooltip);
        position: absolute;
        top: calc(100% + var(--space-xs));
        left: 50%;
        transform: translateX(-50%);
        padding: var(--space-xs) var(--space-sm);
        background-color: var(--color-text);
        color: var(--color-text-inverted);
        font-size: 0.75rem;
        border-radius: var(--radius-sm);
        white-space: nowrap;
        z-index: 10;
        pointer-events: none;
    }

    /* Hide tooltip when element with a popup has it open */
    .content-top-bar [aria-haspopup][aria-expanded="true"][data-tooltip]:hover::after,
    .content-top-bar [aria-haspopup][aria-expanded="true"][data-tooltip]:focus-visible::after {
        display: none;
    }

    .sidebar-footer {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }

    /* User menu in sidebar footer - mini sidebar */
    .sidebar-footer .user-menu {
        width: auto;
    }

    .sidebar-footer .user-menu-trigger {
        justify-content: center;
        padding: var(--space-sm);
    }

    .sidebar-footer .user-name {
        display: none;
    }

    .sidebar-footer .user-menu-chevron {
        display: none;
    }

    .sidebar-footer .user-menu-dropdown {
        left: 0;
        right: auto;
        bottom: 100%;
        top: auto;
        margin-bottom: var(--space-xs);
    }

    /* Main content */
    .main-content {
        margin-left: var(--sidebar-width);
    }

    .content-body {
        padding: var(--space-lg);
        padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    }

    /* Tablet+: content-top-bar back in normal flow (not overlaying header) */
    .content-top-bar {
        position: relative;
        top: auto;
        right: auto;
        height: auto;
        padding: var(--space-xs) var(--space-lg);
        background: none;
        pointer-events: auto;
        flex-shrink: 0;
        z-index: var(--z-dropdown);
    }

    /* Logo visible in content-top-bar on tablet+ */
    .content-top-bar-logo {
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        text-decoration: none;
        color: var(--color-text);
        font-weight: 600;
        font-size: 1rem;
        margin-right: auto;
        flex-shrink: 0;
    }

    .content-top-bar-logo:hover {
        text-decoration: none;
    }

    .content-top-bar-logo-image {
        height: 48px;
        width: auto;
    }

    .content-top-bar-logo-text {
        white-space: nowrap;
    }

    /* Cards */
    .card {
        padding: var(--space-lg);
        margin-bottom: var(--space-lg);
    }

    /* Admin stats */
    .admin-stats,
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Permissions grid */
    .permissions-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    /* Form card */
    .form-card {
        padding: var(--space-lg);
    }
}

/* ==========================================================================
   Responsive Styles - Sidebar expanded state (tablet+)
   The expanded state is controlled via html.sidebar-expanded class to prevent
   flash on page load. The class is set early by sidebar-init.js.
   ========================================================================== */
@media (min-width: 768px) {
    html.sidebar-expanded .sidebar {
        width: var(--sidebar-width-full);
    }

    html.sidebar-expanded .main-content {
        margin-left: var(--sidebar-width-full);
    }

    html.sidebar-expanded .app-header {
        left: var(--sidebar-width-full);
    }

    html.sidebar-expanded .sidebar-header {
        padding: var(--space-md) var(--space-lg);
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: var(--space-sm);
    }

    /* Restore scrolling and overflow in expanded mode */
    html.sidebar-expanded .sidebar-nav {
        overflow-y: auto;
    }

    html.sidebar-expanded .nav-section-items {
        overflow: hidden;
    }

    html.sidebar-expanded .nav-section-header {
        display: flex;
    }

    html.sidebar-expanded .nav-section-title {
        display: flex;
    }

    html.sidebar-expanded .nav-section-chevron {
        display: block;
    }

    /* Restore collapsed state in expanded mode */
    html.sidebar-expanded .nav-section.collapsed .nav-section-items {
        max-height: 0;
    }

    html.sidebar-expanded .nav-item {
        overflow: hidden;
        padding: 0.75rem var(--space-lg);
        justify-content: flex-start;
    }

    html.sidebar-expanded .nav-label {
        display: block;
    }

    /* Utility zone in expanded mode */
    html.sidebar-expanded .sidebar-utility-item {
        overflow: hidden;
        padding: var(--space-sm) var(--space-lg);
        justify-content: flex-start;
    }

    html.sidebar-expanded .sidebar-utility-label {
        display: block;
    }

    html.sidebar-expanded .sidebar-utility-badge {
        position: static;
        margin-left: auto;
        min-width: 18px;
        height: 18px;
        font-size: 0.6875rem;
        padding: 0 5px;
    }

    /* Hide all tooltips when sidebar is expanded (labels are visible) */
    html.sidebar-expanded .nav-item[data-tooltip]:hover::after,
    html.sidebar-expanded .sidebar-toggle[data-tooltip]:hover::after,
    html.sidebar-expanded .sidebar-utility-item[data-tooltip]:hover::after,
    html.sidebar-expanded .user-menu-trigger[data-tooltip]:hover::after {
        display: none;
    }

    /* Sidebar footer - expanded sidebar */
    html.sidebar-expanded .sidebar-footer {
        align-items: stretch;
    }

    html.sidebar-expanded .sidebar-footer .user-menu {
        width: 100%;
    }

    html.sidebar-expanded .sidebar-footer .user-menu-trigger {
        justify-content: flex-start;
    }

    html.sidebar-expanded .sidebar-footer .user-name {
        display: block;
    }

    html.sidebar-expanded .sidebar-footer .user-menu-chevron {
        display: block;
    }

    /* Cursor: pointer on mini sidebar to indicate it's clickable to expand */
    html:not(.sidebar-expanded) .sidebar {
        cursor: pointer;
    }

    /* Reset cursor on interactive elements within mini sidebar */
    html:not(.sidebar-expanded) .sidebar a,
    html:not(.sidebar-expanded) .sidebar button {
        cursor: pointer;
    }

    /* Reset cursor when expanded */
    html.sidebar-expanded .sidebar {
        cursor: default;
    }
}

/* ==========================================================================
   Responsive Styles - Desktop (1024px+)
   Unified behavior with tablet: mini by default, .expanded when user opens
   ========================================================================== */
@media (min-width: 1024px) {
    /* Note: overflow: visible for sidebar is inherited from tablet (768px+) */

    /* Larger content padding on desktop */
    .content-body {
        padding: var(--space-xl);
        padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
    }

    .content-top-bar {
        padding: var(--space-xs) var(--space-xl);
    }

    /* Desktop inherits tablet's mini-by-default behavior.
       No need to override most tablet rules - they work correctly. */
}

/* ==========================================================================
   No Sidebar Layout
   Used when non-admin users have access to only one navigation item.
   The sidebar is hidden and content extends to full width.
   Header is shown since user-menu is not available in sidebar.
   ========================================================================== */
.no-sidebar .main-content {
    margin-left: 0;
    margin-top: var(--header-height);
}

.no-sidebar .app-header {
    display: flex;
    justify-content: space-between;
    left: 0;
}

/* Hide hamburger when there's no sidebar to open */
.no-sidebar .header-menu-toggle {
    display: none;
}

/* Show logo in no-sidebar mode */
.no-sidebar .header-logo {
    display: flex;
}

/* In no-sidebar mode: logo image styling */
.no-sidebar .header-logo-image {
    height: 32px;
    width: auto;
}

.no-sidebar .header-logo-text {
    display: block;
}

/* Show user-menu in header when no sidebar (only way to access profile/logout) */
.no-sidebar .app-header .user-menu {
    display: flex;
}

/* ==========================================================================
   Container queries for content-body children
   ========================================================================== */
@container (min-width: 500px) {
    .dashboard-placeholder {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-stats,
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .codes-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@container (min-width: 800px) {
    .dashboard-placeholder {
        grid-template-columns: repeat(3, 1fr);
    }

    .quick-actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .admin-stats,
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========================================
   Branding Settings
   ======================================== */

.branding-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.branding-item:first-of-type {
    padding-top: 0;
}

.branding-item:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.branding-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* Inline row: preview + buttons aligned horizontally */
.branding-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

/* Preview container */
.branding-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.branding-preview-logo {
    width: 300px;
    height: 100px;
    padding: 0.75rem;
}

.branding-preview-favicon {
    width: 80px;
    height: 80px;
    padding: 0.5rem;
}

.branding-preview-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
}

.branding-preview-avatar .branding-current-image,
.branding-preview-avatar .branding-preview-image {
    border-radius: 50%;
}

.branding-preview-empty {
    border-style: dashed;
}

.branding-placeholder-icon {
    color: var(--text-tertiary);
}

.branding-preview .branding-current-image,
.branding-preview .branding-preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.branding-preview.has-preview .branding-current-image,
.branding-preview.has-preview .branding-placeholder-icon {
    display: none;
}

/* Form inline layout */
.branding-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

/* Hide file input visually but keep accessible */
.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-input:focus + .btn {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Branding form actions and delete button */
.branding-form-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.branding-delete-action {
    margin-top: 0.75rem;
}

/* Outline danger button */
.btn-outline-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

/* Branding actions container */
.branding-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Logo dimensions display */
.branding-dimensions {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* Theme toggle buttons for logo preview */
.branding-theme-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 0.125rem;
    margin-top: 0.5rem;
}

.branding-theme-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all 0.15s ease;
}

.branding-theme-btn:hover {
    color: var(--text-secondary);
}

.branding-theme-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Logo preview theme variants */
.branding-preview-logo.preview-dark {
    background: #1f2937;
    border-color: #374151;
}

/* Responsive adjustments for branding */
@media (max-width: 480px) {
    .branding-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .branding-form {
        width: 100%;
    }

    .branding-form .btn {
        flex: 1;
        justify-content: center;
    }
}

/* ========================================
   Logo Theme Variants (light/dark switching)
   Uses data-theme attribute set by theme-init.js.
   When only logo_url is set (no dark variant), no classes are added
   and the single logo displays normally in all themes.
   ======================================== */
.logo-dark {
    display: none;
}

[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: block;
}

/* ========================================
   Theme Customization
   ======================================== */

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-input {
    width: 48px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--color-bg-elevated);
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-input::-webkit-color-swatch {
    border-radius: var(--radius-sm);
    border: none;
}

.color-input::-moz-color-swatch {
    border-radius: var(--radius-sm);
    border: none;
}

.color-text-input {
    width: 100px;
    font-family: monospace;
    text-transform: uppercase;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

/* Settings List - for toggle switches with labels */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--color-bg-subtle);
    border-radius: var(--radius-md);
    padding: 0.25rem 1rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.settings-row:first-child {
    padding-top: var(--space-md);
}

.settings-row:last-child {
    border-bottom: none;
    padding-bottom: var(--space-md);
}

.settings-row-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
}

.settings-row-label {
    font-weight: 500;
    color: var(--color-text);
}

.settings-row-help {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.settings-row-warning {
    font-size: 0.8125rem;
    color: var(--color-warning-dark);
    line-height: 1.4;
}

/* Settings list mobile responsiveness */
@media (max-width: 480px) {
    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .settings-row .toggle-switch {
        align-self: flex-end;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-bg-muted);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Page Header
   ========================================================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.page-header h1,
.page-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.page-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Modifier for complex headers (filters, multiple action groups) */
.page-header-with-actions {
    align-items: flex-start;
}

/* ==========================================================================
   Back Button Component
   ========================================================================== */

.back-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.back-button-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ==========================================================================
   Audit Logs Styles
   ========================================================================== */

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    padding: var(--space-xs) 0;
    margin-top: var(--space-xs);
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
    background-color: var(--color-bg-subtle);
    text-decoration: none;
}

.dropdown-item svg {
    color: var(--color-text-secondary);
}

/* Dropdown with descriptions */
.dropdown-menu-wide {
    min-width: 280px;
}

.dropdown-item-desc {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: var(--space-sm) var(--space-md);
}

.dropdown-item-title {
    font-weight: 500;
    color: var(--color-text);
}

.dropdown-item-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    line-height: 1.3;
}

/* Audit retention alert */
.audit-retention-alert {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.audit-retention-alert .alert-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.audit-purge-form {
    margin: 0;
}

/* Audit filters */
.audit-filters-card {
    padding: var(--space-md);
}

.audit-filters-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.audit-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    align-items: end;
}

.audit-filters-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
    padding-top: var(--space-md);
}

/* Audit results info */
.audit-results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.audit-date-range {
    font-style: italic;
}

/* Audit table */
.audit-table {
    min-width: 800px;
}

.audit-col-date {
    width: 140px;
}

.audit-col-user {
    min-width: 150px;
}

.audit-col-action {
    min-width: 150px;
}

.audit-col-entity {
    min-width: 100px;
}

.audit-col-status {
    width: 90px;
}

.audit-col-ip {
    width: 120px;
}

.audit-col-details {
    width: 50px;
    text-align: center;
}

/* Audit cell styles */
.audit-cell-date .audit-date,
.audit-cell-date .audit-time,
.audit-cell-user .audit-user-name,
.audit-cell-user .audit-user-email,
.audit-cell-entity .audit-entity-type,
.audit-cell-entity .audit-entity-id {
    display: block;
}

.audit-date {
    font-weight: 500;
    color: var(--color-text);
}

.audit-time {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.audit-user-name {
    font-weight: 500;
    color: var(--color-text);
}

.audit-user-email {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.audit-user-unknown,
.audit-user-system {
    font-style: italic;
    color: var(--color-text-muted);
}

/* Audit action badge */
.audit-action-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-mono, ui-monospace, monospace);
    color: var(--color-text-secondary);
    background-color: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* Audit entity */
.audit-entity-type {
    font-weight: 500;
    color: var(--color-text);
}

.audit-entity-id {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    font-family: var(--font-mono, ui-monospace, monospace);
    margin-top: 2px;
}

/* Audit cell IP */
.audit-cell-ip {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

/* Audit details toggle */
.audit-details-toggle {
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: transform var(--transition-fast);
}

.audit-details-toggle.expanded svg {
    transform: rotate(180deg);
}

/* Audit details row */
.audit-details-row {
    background-color: var(--color-bg-subtle);
}

.audit-details-row td {
    padding: 0 !important;
}

.audit-details-content {
    padding: var(--space-md);
    border-top: 1px solid var(--color-border);
}

.audit-changes-json {
    margin: var(--space-sm) 0 0 0;
    padding: var(--space-sm);
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

/* Button icon */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--color-bg-subtle);
    color: var(--color-text);
}

/* Button outline danger */
.btn-outline-danger {
    color: var(--color-danger);
    background-color: transparent;
    border: 1px solid var(--color-danger);
}

.btn-outline-danger:hover {
    color: #fff;
    background-color: var(--color-danger);
}

/* ==========================================================================
   Permissions Admin Page
   ========================================================================== */

/* Info card with icon */
.permissions-info-card {
    margin-bottom: var(--space-md);
}

.card-body-info {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: light-dark(#e8f4fd, rgba(59, 130, 246, 0.1));
    border: 1px solid light-dark(#b8daff, rgba(59, 130, 246, 0.3));
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.card-body-info .info-icon {
    flex-shrink: 0;
    color: var(--color-primary);
    margin-top: 2px;
}

.card-body-info p {
    margin: 0;
    font-size: 0.875rem;
    color: light-dark(#004085, var(--color-text-secondary));
    line-height: 1.5;
}

/* Scope legend */
.scope-legend {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* Scope badges */
.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.scope-badge svg {
    flex-shrink: 0;
}

.scope-badge.scope-global {
    background: light-dark(#e3f2fd, rgba(33, 150, 243, 0.15));
    color: light-dark(#1565c0, #64b5f6);
}

.scope-badge.scope-owned {
    background: light-dark(#fff3e0, rgba(255, 152, 0, 0.15));
    color: light-dark(#e65100, #ffb74d);
}

.scope-badge.scope-relation {
    background: light-dark(#f3e5f5, rgba(156, 39, 176, 0.15));
    color: light-dark(#7b1fa2, #ce93d8);
}

.scope-badge .relation-code {
    opacity: 0.75;
    margin-left: 0.125rem;
    font-weight: 400;
}

/* Filter card */
.permissions-filter-card {
    margin-bottom: var(--space-md);
}

.permissions-filter-form {
    display: flex;
    align-items: flex-end;
    gap: var(--space-md);
}

.permissions-filter-form .form-group {
    margin: 0;
    min-width: 200px;
}

/* Module card */
.module-card {
    margin-bottom: var(--space-md);
}

.module-header {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-md);
}

.module-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.permission-count {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Permission code */
.permission-code {
    background: var(--color-bg-subtle);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    color: var(--color-text);
}

/* Page header info badge */
.page-header-info {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-weight: 400;
    margin-left: auto;
}

/* Responsive page header and audit styles */
@media (max-width: 768px) {
    /* Page header responsive */
    .page-header {
        gap: var(--space-sm);
    }

    .page-header h1,
    .page-header h2,
    .page-title {
        font-size: 1.25rem;
    }

    /* Title followed by action button: stack vertically */
    .page-header .page-title:first-child {
        flex: 1 1 100%;
    }

    /* Back button + title pattern: keep on same line */
    .page-header > .btn:first-child + .page-title {
        flex: 1 1 auto;
        font-size: 1.125rem;
    }

    /* Action buttons take full width */
    .page-header > .btn:last-child:not(.btn-sm):not(.btn-small) {
        width: 100%;
    }

    /* Back button stays compact */
    .page-header > .btn.btn-sm:first-child,
    .page-header > .btn.btn-small:first-child {
        width: auto;
        flex-shrink: 0;
    }

    .page-header-with-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .page-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* Audit-specific responsive styles */
    .audit-filters-row {
        grid-template-columns: 1fr;
    }

    .audit-filters-actions {
        flex-direction: column;
    }

    .audit-filters-actions .btn {
        width: 100%;
    }

    .audit-retention-alert {
        flex-direction: column;
        align-items: stretch;
    }

    .audit-purge-form {
        text-align: right;
    }
}

/* ==========================================================================
   Language Management - Admin section
   ========================================================================== */

/* Language badges */
.language-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Static translations table */
.static-translations-table .col-key {
    width: 40%;
    font-size: 0.875rem;
}

.static-translations-table .col-key code {
    word-break: break-all;
}

.static-translations-table .col-value {
    width: 60%;
}

/* Static translations filters */
.static-filters {
    margin-bottom: 0;
}

.static-filters .form-row {
    align-items: flex-end;
}

.static-filters .form-group-actions {
    display: flex;
    gap: 0.5rem;
    padding-bottom: 0;
}

/* Translation progress indicators */
.translation-progress {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.translation-progress.progress-complete {
    background-color: light-dark(#dcfce7, rgba(34, 197, 94, 0.2));
    color: light-dark(#166534, #86efac);
}

.translation-progress.progress-partial {
    background-color: light-dark(#fef9c3, rgba(245, 158, 11, 0.2));
    color: light-dark(#854d0e, #fcd34d);
}

.translation-progress.progress-none {
    background-color: light-dark(#fee2e2, rgba(239, 68, 68, 0.2));
    color: light-dark(#991b1b, #fca5a5);
}

/* Translation card for edit page */
.translation-card {
    margin-bottom: 1.5rem;
}

.translation-card .card-title {
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* Translation tabs */
.translation-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.translation-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: var(--transition-fast);
    position: relative;
}

.translation-tab:hover {
    background: var(--color-bg-subtle);
    color: var(--color-text);
}

.translation-tab.active {
    background: var(--color-primary);
    color: white;
}

.translation-tab .tab-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    margin-left: 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    background: var(--color-warning);
    color: white;
    border-radius: 50%;
}

.translation-tab.active .tab-warning {
    background: white;
    color: var(--color-warning);
}

/* Translation panels */
.translation-panel {
    display: none;
}

.translation-panel.active {
    display: block;
}

/* Translation reference */
.translation-reference {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

.translation-reference label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.translation-reference .reference-text {
    font-size: 0.875rem;
    color: var(--color-text);
    white-space: pre-wrap;
}

/* Translation input */
.translation-input {
    width: 100%;
    min-height: 80px;
    resize: vertical;
}

/* Responsive for translation interface */
@media (max-width: 768px) {
    .translation-tabs {
        flex-direction: column;
        gap: 0.125rem;
    }

    .translation-tab {
        border-radius: var(--radius-sm);
        text-align: left;
    }

    .static-filters .form-row {
        flex-direction: column;
    }

    .static-filters .form-group-actions {
        flex-direction: column;
    }

    .static-filters .form-group-actions .btn {
        width: 100%;
    }
}

/* ==========================================================================
   TOTP Setup Styles
   ========================================================================== */

/* TOTP setup container */
.totp-setup {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.totp-setup-step {
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.totp-setup-step:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.totp-setup-step h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.totp-setup-step p {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
}

/* QR code container */
.totp-qr-container {
    text-align: center;
}

.totp-qr-code {
    display: inline-block;
    padding: var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.totp-qr-code img {
    display: block;
    max-width: 256px;
    height: auto;
}

/* Manual secret entry */
.totp-secret-manual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-bg-subtle);
    border-radius: var(--radius-md);
}

.totp-secret-label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.totp-secret-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1rem;
    letter-spacing: 0.1em;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    user-select: all;
}

/* TOTP verify form */
.totp-verify-form {
    max-width: 300px;
    margin: 0 auto;
}

.totp-verify-form input[type="text"] {
    text-align: center;
    font-size: 1.25rem;
    letter-spacing: 0.2em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* TOTP disable form (inline in profile) */
.totp-disable-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

.totp-disable-form .form-group-inline {
    flex: 1;
    min-width: 200px;
}

.totp-disable-form .form-group-inline input {
    width: 100%;
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .totp-secret-manual {
        padding: var(--space-sm);
    }

    .totp-secret-code {
        font-size: 0.75rem;
        word-break: break-all;
    }

    .totp-disable-form {
        flex-direction: column;
    }

    .totp-disable-form .form-group-inline {
        width: 100%;
    }

    .totp-disable-form .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Inline Confirmation Component
   ========================================================================== */

/* Inline confirm wrapper */
.inline-confirm-wrapper {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Inline confirm buttons */
.inline-confirm-yes,
.inline-confirm-no {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.inline-confirm-yes {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

.inline-confirm-yes:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
}

.inline-confirm-no {
    background: var(--color-bg-elevated);
    color: var(--color-text);
    border-color: var(--color-border);
}

.inline-confirm-no:hover {
    background: var(--color-bg-subtle);
}

/* Active state for element being confirmed */
.inline-confirm-active {
    display: inline-flex !important;
    align-items: center;
}

/* Focus visible for keyboard navigation */
.inline-confirm-yes:focus-visible,
.inline-confirm-no:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Inline Confirm - Floating Mode
   -------------------------------------------------------------------------- */

/* Source element marker */
.inline-confirm-source {
    position: relative;
}

/* Floating bubble container */
.inline-confirm-floating {
    position: absolute;
    z-index: var(--z-widget);
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 150ms ease-out, transform 150ms ease-out;
}

/* Visible state */
.inline-confirm-floating-visible {
    opacity: 1;
    transform: scale(1);
}

/* Hiding state (exit animation) */
.inline-confirm-floating-hiding {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 100ms ease-in, transform 100ms ease-in;
}

/* Content wrapper */
.inline-confirm-floating-content {
    background: var(--color-bg-elevated, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05));
    padding: 0.875rem 1rem;
    min-width: 180px;
    max-width: 280px;
    text-align: center;
}

/* Confirmation text */
.inline-confirm-floating-text {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text, #111827);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* Action buttons container */
.inline-confirm-floating-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

/* Floating buttons */
.inline-confirm-floating-yes,
.inline-confirm-floating-no {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md, 8px);
    border: 1px solid;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, transform 100ms ease;
    min-width: 70px;
    /* Touch-friendly size (min 44px height) */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.inline-confirm-floating-yes {
    background: var(--color-danger, #dc2626);
    color: white;
    border-color: var(--color-danger, #dc2626);
}

.inline-confirm-floating-yes:hover {
    background: var(--color-danger-hover, #b91c1c);
    border-color: var(--color-danger-hover, #b91c1c);
}

.inline-confirm-floating-yes:active {
    transform: scale(0.98);
}

/* Success variant for confirm button */
.inline-confirm-floating-yes.btn-success {
    background: var(--color-success, #22c55e);
    border-color: var(--color-success, #22c55e);
}

.inline-confirm-floating-yes.btn-success:hover {
    background: var(--color-success-hover, #16a34a);
    border-color: var(--color-success-hover, #16a34a);
}

/* Warning variant for confirm button */
.inline-confirm-floating-yes.btn-warning {
    background: var(--color-warning, #f59e0b);
    border-color: var(--color-warning, #f59e0b);
    color: #000;
}

.inline-confirm-floating-yes.btn-warning:hover {
    background: var(--color-warning-hover, #d97706);
    border-color: var(--color-warning-hover, #d97706);
}

/* Cancel button */
.inline-confirm-floating-no {
    background: var(--color-bg-subtle, #f3f4f6);
    color: var(--color-text, #111827);
    border-color: var(--color-border, #e5e7eb);
}

.inline-confirm-floating-no:hover {
    background: var(--color-bg-muted, #e5e7eb);
    border-color: var(--color-border-strong, #d1d5db);
}

.inline-confirm-floating-no:active {
    transform: scale(0.98);
}

/* Focus visible for keyboard navigation */
.inline-confirm-floating-yes:focus-visible,
.inline-confirm-floating-no:focus-visible {
    outline: 2px solid var(--color-primary, #3b82f6);
    outline-offset: 2px;
}

/* Arrow pointer */
.inline-confirm-floating-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--color-bg-elevated, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    transform: rotate(45deg);
    pointer-events: none;
}

/* Arrow position based on placement */
.inline-confirm-floating[data-placement="top"] .inline-confirm-floating-arrow {
    bottom: -7px;
    border-top: none;
    border-left: none;
}

.inline-confirm-floating[data-placement="bottom"] .inline-confirm-floating-arrow {
    top: -7px;
    border-bottom: none;
    border-right: none;
}

/* Dark mode */
[data-theme="dark"] .inline-confirm-floating-content,
.dark .inline-confirm-floating-content {
    background: var(--color-bg-elevated, #1f2937);
    border-color: var(--color-border, #374151);
}

[data-theme="dark"] .inline-confirm-floating-arrow,
.dark .inline-confirm-floating-arrow {
    background: var(--color-bg-elevated, #1f2937);
    border-color: var(--color-border, #374151);
}

[data-theme="dark"] .inline-confirm-floating-no,
.dark .inline-confirm-floating-no {
    background: var(--color-bg-subtle, #374151);
    border-color: var(--color-border, #4b5563);
}

[data-theme="dark"] .inline-confirm-floating-no:hover,
.dark .inline-confirm-floating-no:hover {
    background: var(--color-bg-muted, #4b5563);
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .inline-confirm-floating,
    .inline-confirm-floating-visible,
    .inline-confirm-floating-hiding {
        transition: none;
        transform: none;
    }
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .inline-confirm-floating-content {
        min-width: 160px;
        padding: 0.75rem;
    }

    .inline-confirm-floating-text {
        font-size: 0.875rem;
    }

    .inline-confirm-floating-yes,
    .inline-confirm-floating-no {
        padding: 0.5rem 0.75rem;
        min-width: 60px;
    }
}

/* ==========================================================================
   Clickable Rows
   ========================================================================== */

.clickable-row[data-href] {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.clickable-row[data-href]:hover {
    background-color: var(--color-bg-subtle);
}

/* Prevent propagation on interactive elements within rows */
.clickable-row a,
.clickable-row button,
.clickable-row input,
.clickable-row select,
.clickable-row .no-propagate {
    cursor: auto;
}

/* ==========================================================================
   Drag & Drop Component
   ========================================================================== */

/* Drag handle */
.drag-handle {
    cursor: move;
    cursor: grab;
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
    touch-action: none;
    user-select: none;
}

.drag-handle:hover {
    color: var(--color-text);
}

.drag-handle:active {
    cursor: grabbing;
}

/* Item being dragged (position:fixed, floating above content) */
.dragging {
    box-shadow: var(--shadow-lg);
    cursor: grabbing !important;
}

/* Placeholder during drag */
.drag-placeholder {
    background: var(--color-bg-subtle);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    opacity: 0.5;
}

/* Table row placeholder */
tr.drag-placeholder {
    border-radius: 0;
}

tr.drag-placeholder td {
    background: var(--color-bg-subtle);
    border-top: 2px dashed var(--color-border);
    border-bottom: 2px dashed var(--color-border);
}

/* ==========================================================================
   Empty State Component
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.empty-state-text {
    font-size: 1rem;
    margin-bottom: var(--space-lg);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-action {
    margin-top: var(--space-lg);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .empty-state {
        padding: var(--space-xl) var(--space-md);
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .empty-state-title {
        font-size: 1.25rem;
    }

    .empty-state-text {
        font-size: 0.9375rem;
    }
}

/* ==========================================================================
   Profile Accordion Sections
   Native <details><summary> for progressive enhancement (works without JS)
   ========================================================================== */

.profile-section {
    background-color: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.profile-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    min-height: var(--touch-target);
    cursor: pointer;
    user-select: none;
    list-style: none;
    background-color: var(--color-bg-elevated);
    border-bottom: 1px solid transparent;
    transition: background-color var(--transition-fast);
}

.profile-section summary::-webkit-details-marker {
    display: none;
}

.profile-section summary:hover {
    background-color: var(--color-bg-subtle);
}

.profile-section summary:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.profile-section[open] summary {
    border-bottom-color: var(--color-border);
}

.profile-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
}

.profile-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.profile-section-chevron {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
}

.profile-section[open] .profile-section-chevron {
    transform: rotate(180deg);
}

.profile-section-content {
    padding: var(--space-lg);
}

/* Profile subsections (within accordion content) */
.profile-subsection {
    padding: var(--space-md);
    background-color: var(--color-bg-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.profile-subsection:last-child {
    margin-bottom: 0;
}

.profile-subsection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.profile-subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.profile-subsection-description {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-md) 0;
}

.profile-subsection-status {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.profile-subsection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

/* Avatar section within profile */
.profile-avatar-section {
    display: flex;
    align-items: flex-start;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.profile-avatar-preview {
    flex-shrink: 0;
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    background-color: var(--color-bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--color-border);
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-preview .avatar-placeholder-icon {
    width: 40px;
    height: 40px;
    color: var(--color-text-muted);
}

.profile-avatar-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.profile-avatar-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

/* Form help text */
.form-help {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    margin-bottom: 0;
}

/* Password requirements list (profile page simple list) */
.profile-section ul.password-requirements {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-md);
    margin-top: var(--space-sm);
    padding: 0;
    list-style: none;
}

.profile-section ul.password-requirements li {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.profile-section ul.password-requirements li::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--color-text-muted);
    flex-shrink: 0;
}

/* Responsive: Tablet and up */
@media (min-width: 768px) {
    .profile-section {
        margin-bottom: var(--space-lg);
    }

    .profile-section-content {
        padding: var(--space-xl);
    }

    .profile-section-content .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-md);
        margin-bottom: var(--space-md);
    }

    .profile-section-content .form-row .form-group {
        margin-bottom: 0;
    }

    .profile-avatar-section {
        gap: var(--space-xl);
    }

    .profile-avatar-preview {
        width: 120px;
        height: 120px;
    }

    .profile-avatar-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Responsive: Mobile */
@media (max-width: 767px) {
    .profile-section summary {
        padding: var(--space-md);
    }

    .profile-section-content {
        padding: var(--space-md);
    }

    .profile-avatar-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-avatar-actions {
        width: 100%;
    }

    .profile-avatar-actions .btn {
        width: 100%;
    }

    .profile-subsection-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-subsection-actions {
        flex-direction: column;
    }

    .profile-subsection-actions .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Admin Modules Page
   ========================================================================== */

/* Module name cell with dependency indicators */
.module-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.module-name-cell strong {
    font-weight: 600;
}

.module-id {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

.module-deps-indicator {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.dep-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}

.dep-requires {
    background-color: light-dark(#e0f2fe, rgba(56, 189, 248, 0.15));
    color: light-dark(#0369a1, #7dd3fc);
}

.dep-required-by {
    background-color: light-dark(#fef3c7, rgba(245, 158, 11, 0.15));
    color: light-dark(#b45309, #fcd34d);
}

.dep-optional {
    background-color: light-dark(#f3e8ff, rgba(168, 85, 247, 0.15));
    color: light-dark(#7e22ce, #c084fc);
}

.dep-badge svg {
    width: 10px;
    height: 10px;
}

/* Module features badges */
.module-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-subtle);
    color: var(--color-text-muted);
    transition: background-color 0.2s, color 0.2s;
}

.feature-badge:hover {
    background-color: var(--color-primary);
    color: white;
}

.feature-badge svg {
    width: 14px;
    height: 14px;
}

.feature-badge-special {
    background-color: light-dark(#dbeafe, rgba(59, 130, 246, 0.2));
    color: light-dark(#1d4ed8, #60a5fa);
}

/* Module row disabled state */
.module-row-disabled {
    opacity: 0.6;
}

.module-row-disabled .module-name-cell strong {
    color: var(--color-text-muted);
}

/* Module overview card (detail page) */
.module-overview-card {
    margin-bottom: var(--space-md);
}

.module-header-detail {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.module-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.module-info .module-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.module-id-code {
    font-size: 0.8125rem;
    background-color: var(--color-bg-subtle);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

.module-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.module-description {
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.module-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.meta-value {
    font-weight: 500;
}

/* Capabilities grid */
.capabilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
}

.capability-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
}

.capability-item svg {
    flex-shrink: 0;
}

.capability-active {
    background-color: light-dark(#dcfce7, rgba(34, 197, 94, 0.15));
    color: light-dark(#166534, #86efac);
}

.capability-active svg {
    stroke: light-dark(#16a34a, #4ade80);
}

.capability-inactive {
    background-color: var(--color-bg-subtle);
    color: var(--color-text-muted);
}

.capability-inactive svg {
    opacity: 0.5;
}

.capability-special {
    background-color: light-dark(#dbeafe, rgba(59, 130, 246, 0.2));
    color: light-dark(#1d4ed8, #60a5fa);
}

.capability-special svg {
    stroke: light-dark(#2563eb, #3b82f6);
}

.capability-label {
    font-weight: 500;
    font-size: 0.875rem;
}

.capability-detail {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Permissions list (detail page) */
.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.permission-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
}

.permission-scope {
    font-size: 0.6875rem;
    text-transform: uppercase;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

.scope-global {
    background-color: light-dark(#fee2e2, rgba(239, 68, 68, 0.2));
    color: light-dark(#991b1b, #fca5a5);
}

.scope-owned {
    background-color: light-dark(#dcfce7, rgba(34, 197, 94, 0.2));
    color: light-dark(#166534, #86efac);
}

.scope-workspace {
    background-color: light-dark(#dbeafe, rgba(59, 130, 246, 0.2));
    color: light-dark(#1d4ed8, #60a5fa);
}

.scope-relation {
    background-color: light-dark(#fef3c7, rgba(245, 158, 11, 0.2));
    color: light-dark(#b45309, #fcd34d);
}

.permission-desc {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    flex: 1;
}

/* Navigation items list */
.nav-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nav-item-row {
    padding: 0.75rem;
    background-color: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
}

.nav-item-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-context-badge {
    font-size: 0.6875rem;
    text-transform: uppercase;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

.context-app {
    background-color: light-dark(#dcfce7, rgba(34, 197, 94, 0.2));
    color: light-dark(#166534, #86efac);
}

.context-admin {
    background-color: light-dark(#fef3c7, rgba(245, 158, 11, 0.2));
    color: light-dark(#b45309, #fcd34d);
}

.nav-item-label {
    font-weight: 500;
}

.nav-item-url {
    font-size: 0.75rem;
    background-color: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

.nav-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.nav-item-admin-only {
    color: light-dark(#dc2626, #f87171);
    font-weight: 500;
}

/* Widgets list */
.widgets-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.widget-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
}

.widget-type {
    font-size: 0.75rem;
    background-color: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

.widget-name {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Relations list */
.relations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.relation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
}

.relation-code {
    font-size: 0.75rem;
    background-color: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

.relation-flow {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.relation-name {
    color: var(--color-text);
    font-size: 0.875rem;
}

/* Dependency type badges (detail page) */
.dep-type-badge {
    display: inline-block;
    font-size: 0.6875rem;
    padding: 0.0625rem 0.375rem;
    border-radius: var(--radius-full, 9999px);
    font-weight: 500;
    line-height: 1.4;
}

.dep-type-required {
    background-color: light-dark(#e0f2fe, rgba(56, 189, 248, 0.15));
    color: light-dark(#0369a1, #7dd3fc);
}

.dep-type-optional {
    background-color: light-dark(#f3e8ff, rgba(168, 85, 247, 0.15));
    color: light-dark(#7e22ce, #c084fc);
}

/* Module action buttons group */
.module-action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Dependencies section improvements */
.dependency-name {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-size: 0.875rem;
    text-decoration: none;
    color: inherit;
}

.dependency-name:hover {
    text-decoration: underline;
    color: var(--color-primary);
}

/* Stats card for modules */
.modules-stats-card {
    margin-bottom: var(--space-md);
}

.modules-info-card {
    margin-bottom: var(--space-md);
}

.modules-info-card .card-body-info {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.modules-info-card .info-icon {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .module-header-detail {
        flex-direction: column;
        gap: var(--space-md);
    }

    .capabilities-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .permission-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-item-main {
        flex-direction: column;
        align-items: flex-start;
    }
}
