/*
 * PenTest Platform - Superadmin Theme
 * Design tokens matching portal theme
 * Navy/Teal gradient system - Light default, html.dark for dark mode
 */

:root {
    /* ========================================
     * COLOR PALETTE
     * ======================================== */

    /* Primary Colors - Navy */
    --color-primary: #0F2B5B;
    --color-primary-dark: #091a38;
    --color-primary-darker: #061127;
    --color-primary-light: #3d83f6;
    --color-primary-lighter: #7aabff;
    --color-primary-pale: #b2cdff;

    /* Secondary Colors - Cyan */
    --color-secondary: #00B4D8;
    --color-secondary-dark: #0891b2;
    --color-secondary-darker: #0e7490;
    --color-secondary-light: #22d3ee;
    --color-secondary-lighter: #67e8f9;

    /* Accent Colors */
    --color-accent: #f59e0b;
    --color-accent-dark: #d97706;
    --color-accent-light: #fbbf24;

    /* Purple Accent */
    --color-purple: #1a65d6;
    --color-purple-dark: #0c2249;
    --color-purple-light: #3d83f6;

    /* Background Colors - Light Theme (default) */
    --color-bg-dark: #F0F4F8;
    --color-bg-darker: #e2e8f0;
    --color-bg-card: rgba(255, 255, 255, 0.8);
    --color-bg-elevated: #ffffff;
    --color-bg-hover: rgba(0, 0, 0, 0.04);
    --color-bg-glass: rgba(255, 255, 255, 0.72);
    --color-bg-glass-light: rgba(255, 255, 255, 0.6);

    /* Text Colors */
    --color-text-primary: #1e293b;
    --color-text-secondary: #475569;
    --color-text-tertiary: #64748b;
    --color-text-muted: #94a3b8;
    --color-text-disabled: #cbd5e1;

    /* Border Colors */
    --color-border: rgba(0, 0, 0, 0.08);
    --color-border-light: rgba(0, 0, 0, 0.05);
    --color-border-strong: rgba(0, 0, 0, 0.12);
    --color-border-hover: rgba(0, 0, 0, 0.15);

    /* Status Colors */
    --color-success: #10b981;
    --color-success-dark: #059669;
    --color-success-light: #34d399;
    --color-success-bg: rgba(16, 185, 129, 0.1);

    --color-warning: #f59e0b;
    --color-warning-dark: #d97706;
    --color-warning-light: #fbbf24;
    --color-warning-bg: rgba(245, 158, 11, 0.1);

    --color-danger: #ef4444;
    --color-danger-dark: #dc2626;
    --color-danger-light: #f87171;
    --color-danger-bg: rgba(239, 68, 68, 0.1);

    --color-info: #3b82f6;
    --color-info-dark: #2563eb;
    --color-info-light: #60a5fa;
    --color-info-bg: rgba(59, 130, 246, 0.1);

    /* Severity Colors */
    --color-critical: #dc2626;
    --color-high: #f59e0b;
    --color-medium: #eab308;
    --color-low: #3b82f6;

    /* ========================================
     * GRADIENTS
     * ======================================== */

    --gradient-primary: linear-gradient(135deg, #0F2B5B 0%, #1a65d6 50%, #00B4D8 100%);
    --gradient-primary-hover: linear-gradient(135deg, #091a38 0%, #0c2249 50%, #0891b2 100%);
    --gradient-secondary: linear-gradient(135deg, #00B4D8 0%, #0891b2 100%);
    --gradient-purple: linear-gradient(135deg, #1a65d6 0%, #0c2249 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

    /* Background Gradients */
    --gradient-bg: none;

    /* ========================================
     * TYPOGRAPHY
     * ======================================== */

    /* Font Families */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

    /* Font Sizes */
    --font-size-xs: 0.75rem;      /* 12px */
    --font-size-sm: 0.875rem;     /* 14px */
    --font-size-base: 1rem;       /* 16px */
    --font-size-lg: 1.125rem;     /* 18px */
    --font-size-xl: 1.25rem;      /* 20px */
    --font-size-2xl: 1.5rem;      /* 24px */
    --font-size-3xl: 1.875rem;    /* 30px */
    --font-size-4xl: 2.25rem;     /* 36px */
    --font-size-5xl: 3rem;        /* 48px */

    /* Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;

    /* Line Heights */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;

    /* ========================================
     * SPACING SCALE (8px base)
     * ======================================== */

    --spacing-0: 0;
    --spacing-1: 0.25rem;   /* 4px */
    --spacing-2: 0.5rem;    /* 8px */
    --spacing-3: 0.75rem;   /* 12px */
    --spacing-4: 1rem;      /* 16px */
    --spacing-5: 1.25rem;   /* 20px */
    --spacing-6: 1.5rem;    /* 24px */
    --spacing-8: 2rem;      /* 32px */
    --spacing-10: 2.5rem;   /* 40px */
    --spacing-12: 3rem;     /* 48px */
    --spacing-16: 4rem;     /* 64px */
    --spacing-20: 5rem;     /* 80px */
    --spacing-24: 6rem;     /* 96px */

    /* ========================================
     * BORDER RADIUS
     * ======================================== */

    --radius-sm: 0.5rem;     /* 8px */
    --radius-md: 0.75rem;    /* 12px */
    --radius-lg: 1rem;       /* 16px */
    --radius-xl: 1.25rem;    /* 20px */
    --radius-2xl: 1.5rem;    /* 24px */
    --radius-full: 9999px;

    /* ========================================
     * SHADOWS
     * ======================================== */

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

    /* Glow Shadows */
    --shadow-glow-primary: 0 0 20px rgba(0, 180, 216, 0.15);
    --shadow-glow-secondary: 0 0 20px rgba(0, 180, 216, 0.15);
    --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.15);

    /* ========================================
     * GLASSMORPHISM EFFECTS
     * ======================================== */

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-bg-light: rgba(255, 255, 255, 0.7);
    --glass-bg-strong: rgba(255, 255, 255, 0.98);
    --glass-blur: blur(12px);
    --glass-blur-strong: blur(20px);

    /* ========================================
     * TRANSITIONS
     * ======================================== */

    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;

    /* ========================================
     * Z-INDEX LAYERS
     * ======================================== */

    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;

    /* ========================================
     * LAYOUT DIMENSIONS
     * ======================================== */

    --sidebar-width: 260px;
    --sidebar-width-collapsed: 64px;
    --header-height: 64px;
    --page-padding: 2rem;
    --content-max-width: 1600px;
}

/* ========================================
 * DARK MODE (activated by html.dark class)
 * ======================================== */

html.dark {
    --color-bg-dark: #0A1628;
    --color-bg-darker: #061127;
    --color-bg-card: #1E293B;
    --color-bg-elevated: #1e293b;
    --color-bg-hover: #334155;
    --color-bg-glass: rgba(15, 23, 42, 0.8);
    --color-bg-glass-light: rgba(30, 41, 59, 0.6);

    --color-text-primary: #f8fafc;
    --color-text-secondary: #cbd5e1;
    --color-text-tertiary: #94a3b8;
    --color-text-muted: #64748b;
    --color-text-disabled: #475569;

    --color-border: rgba(255, 255, 255, 0.08);
    --color-border-light: rgba(255, 255, 255, 0.05);
    --color-border-strong: rgba(255, 255, 255, 0.12);
    --color-border-hover: rgba(255, 255, 255, 0.15);

    --gradient-bg: radial-gradient(circle at 20% 50%, rgba(0, 180, 216, 0.15) 0%, transparent 50%),
                   radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.15) 0%, transparent 50%);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4),
                 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5),
                 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5),
                 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);

    --shadow-glow-primary: 0 0 20px rgba(0, 180, 216, 0.3),
                           0 0 40px rgba(0, 180, 216, 0.15);
    --shadow-glow-secondary: 0 0 20px rgba(6, 182, 212, 0.3),
                             0 0 40px rgba(6, 182, 212, 0.15);
    --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.3),
                          0 0 40px rgba(239, 68, 68, 0.15);

    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-bg-light: rgba(30, 41, 59, 0.6);
    --glass-bg-strong: rgba(15, 23, 42, 0.95);
}

/* ========================================
 * ENS THEME - ANIMATIONS & UTILITIES
 * ======================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 180, 216, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(0, 180, 216, 0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fadeIn { animation: fadeIn 0.3s ease-out; }
.animate-fadeInScale { animation: fadeInScale 0.25s ease-out; }
.animate-slideInRight { animation: slideInRight 0.3s ease-out; }
.animate-pulseGlow { animation: pulseGlow 2s ease-in-out infinite; }

/* Staggered children animation */
.animate-stagger > * { animation: fadeIn 0.3s ease-out both; }
.animate-stagger > *:nth-child(1) { animation-delay: 0s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.05s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.15s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.25s; }

/* Shimmer loading skeleton */
.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Glow effect */
.glow-cyan {
    box-shadow: 0 0 20px rgba(0, 180, 216, 0.15), 0 0 40px rgba(0, 180, 216, 0.08);
}

/* Gradient text */
.text-gradient {
    background: linear-gradient(135deg, #0F2B5B, #00B4D8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
 * LIGHT MODE ELEMENT STYLES (default, excluded in dark)
 * ======================================== */

html:not(.dark) body {
    background-color: #F0F4F8;
    background-image: none;
    color: #1e293b;
}

html:not(.dark) ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #94a3b8, #cbd5e1);
}
html:not(.dark) ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #64748b, #94a3b8);
}

html:not(.dark) ::selection {
    background-color: rgba(0, 180, 216, 0.2);
    color: #0F2B5B;
}

html:not(.dark) a { color: #1a65d6; }
html:not(.dark) a:hover { color: #0F2B5B; }

html:not(.dark) code {
    background-color: rgba(0, 0, 0, 0.05);
    color: #0e7490;
}

html:not(.dark) pre {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: transparent;
}

/* Theme toggle button */
.theme-toggle-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}
.theme-toggle-btn:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--color-secondary);
    border-color: var(--color-secondary);
}

/* ========================================
 * BASE RESET
 * ======================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* No font-size override - inherit browser default (16px) so rem is anchored
       to the same scale portal uses. Forcing 14px (or 13px <1440px) used to
       shrink rem-based sizes while inline px sizes in templates stayed put,
       breaking proportions. All sizes are now rem and scale together. */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--color-text-primary);
    background-color: var(--color-bg-dark);
    background-image: var(--gradient-bg);
    background-attachment: fixed;
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

/* GPU acceleration for animated elements */
.sidebar,
.card,
.stat-card,
.btn,
.toast,
.modal,
.modal-content,
.notification-dropdown,
.dropdown-menu {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
 * SCROLLBAR STYLING
 * ======================================== */

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-card);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #475569, #334155);
    border-radius: 10px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #64748b, #475569);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-bg-elevated) var(--color-bg-card);
}

/* ========================================
 * SELECTION
 * ======================================== */

::selection {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
}

::-moz-selection {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
}

/* ========================================
 * FOCUS STYLES
 * ======================================== */

:focus {
    outline: none;
}

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

/* ========================================
 * TYPOGRAPHY DEFAULTS
 * ======================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--color-text-primary);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

p {
    margin-bottom: var(--spacing-4);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
}

strong, b {
    font-weight: var(--font-weight-semibold);
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background-color: var(--color-bg-elevated);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: var(--color-secondary-light);
}

pre {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    background-color: var(--color-bg-card);
    padding: var(--spacing-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--color-border);
}

pre code {
    background: none;
    padding: 0;
}

/* ========================================
 * UTILITY CLASSES
 * ======================================== */

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

.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* ========================================
 * LAPTOP BREAKPOINT (1440px and below)
 * ======================================== */
@media (max-width: 1440px) {
    :root {
        --sidebar-width: 220px;
        --header-height: 56px;
        --page-padding: var(--spacing-5);
        --font-size-base: 0.875rem;
    }

    body {
        font-size: var(--font-size-sm);
    }
}

/* ========================================
 * THEME SWITCHER PILL (3-state Light/Dark/Auto)
 * Default: fixed top-right (fallback for pages without header-actions).
 * .theme-pill--inline: rendered inline with .header-actions on each page
 * (prepended via JS in base.html so it sits next to Customize / SU avatar).
 * ======================================== */
.theme-pill {
    position: fixed;
    top: 14px;
    right: 76px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem;
    background: var(--color-bg-glass, rgba(255, 255, 255, 0.72));
    border: 1px solid rgba(15, 43, 91, 0.12);
    border-radius: 999px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 8px rgba(15, 43, 91, 0.08);
    font-size: 0.78rem;
}

/* When the pill has been moved into .header-actions, drop fixed positioning
 * so it flows inline with the page's other action buttons. */
.theme-pill.theme-pill--inline {
    position: static;
    top: auto;
    right: auto;
    z-index: auto;
}

/* ========================================
 * USER MENU DROPDOWN
 * Opens when user clicks the SU avatar in .header-actions.
 * Replaces the old sidebar-footer Profile + Logout buttons -
 * everything user-related is grouped under the avatar.
 * ======================================== */
.user-menu {
    position: fixed;
    z-index: 1200;
    min-width: 200px;
    padding: 0.375rem;
    background: var(--color-bg-elevated, #ffffff);
    border: 1px solid rgba(15, 43, 91, 0.1);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(15, 43, 91, 0.15);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.96);
    transform-origin: top right;
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.user-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}
.user-menu__item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--color-text-primary, #1e293b);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background 0.12s ease;
}
.user-menu__item:hover,
.user-menu__item:focus {
    background: rgba(0, 180, 216, 0.08);
    outline: none;
}
.user-menu__item--danger {
    color: #b91c1c;
}
.user-menu__item--danger:hover {
    background: rgba(239, 68, 68, 0.08);
}
.user-menu__icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
html.dark .user-menu {
    background: #1a2540;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
html.dark .user-menu__item {
    color: rgba(255, 255, 255, 0.85);
}
html.dark .user-menu__item:hover {
    background: rgba(0, 180, 216, 0.15);
}
html.dark .user-menu__item--danger {
    color: #f87171;
}
html.dark .user-menu__item--danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Sidebar footer - minimal version label since Profile/Logout moved
 * to the SU avatar dropdown. Kept as small/subtle as possible so it
 * doesn't visually compete with the nav items. */
.sidebar-footer-meta {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0 0.375rem;
    color: var(--color-text-tertiary, #64748b);
    font-size: 0.6rem;
    opacity: 0.45;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

/* ========================================
 * SIDEBAR BRAND LOGO
 * Shield-in-gradient + 'PentestOps' word + 'Superadmin' subtitle.
 * Matches the website navbar branding for visual consistency.
 * ======================================== */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
}
.sidebar-brand:hover { opacity: 0.85; }

.sidebar-brand__logo {
    /* Show the PentestOps icon PNG directly (transparent), exactly like the
       portal sidebar. Previously the icon sat on a blue gradient box, which
       doubled the branding and made the superadmin logo look different. */
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand__text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    overflow: hidden;
}
.sidebar-brand__name {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #0F2B5B, #00B4D8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-brand__role {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--color-text-tertiary, #64748b);
    margin-top: 0.125rem;
}

html.dark .sidebar-brand__name {
    /* gradient still works in dark mode but bump contrast a notch */
    background: linear-gradient(135deg, #7aabff, #67e8f9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
html.dark .sidebar-brand__role {
    color: rgba(255, 255, 255, 0.55);
}

/* Collapsed/narrow sidebar - show only logo */
@media (max-width: 1440px) {
    .sidebar-brand__logo {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }
    .sidebar-brand__name { font-size: 0.95rem; }
}

/* ========================================
 * GPU ACCELERATION (compositor layer hints)
 * Applied selectively to elements that animate frequently. We use
 * `will-change` only on elements that are animation-active AND we
 * isolate paint/layout where it gives a meaningful win. Over-using
 * `will-change` hurts performance, so this is intentionally a small
 * curated list.
 * ======================================== */

/* Modal overlay - compositor layer prevents jank during open/close */
.modal,
.modal-content {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* User menu - promote during animation only, drop after open */
.user-menu {
    will-change: transform, opacity;
    transform: translate3d(0, -6px, 0) scale(0.96);
}
.user-menu.open {
    transform: translate3d(0, 0, 0) scale(1);
}

/* Theme pill segments - gradient/transform on click */
.theme-pill__seg {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Cards and stat cards - isolate paint so hover effects don't trigger
 * page-wide repaints */
.stat-card,
.tenant-card,
.modal-content,
.glass-card {
    contain: paint;
    transform: translateZ(0);
}

/* Sidebar mobile slide-in (already animated via transform; just hint) */
@media (max-width: 768px) {
    .sidebar {
        will-change: transform;
        transform: translate3d(-100%, 0, 0);
    }
    .sidebar.active {
        transform: translate3d(0, 0, 0);
    }
}

/* Buttons: hover effects are GPU-friendly already (transform/opacity)
 * but force a layer for interactive elements that have shadow transitions */
.btn,
.nav-item,
.user-menu__item {
    transform: translateZ(0);
}

/* Animations: wrap heavy keyframe sequences in compositor layer */
.chatbot-fab,
.theme-pill,
.peek-bubble,
.chatbot-peek-bubble {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Reduce motion preference - respect user's OS setting */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

html.dark .theme-pill {
    /* Solid dark surface that visually integrates with the dark page
     * instead of a barely-visible 6% white wash. */
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(0, 180, 216, 0.22);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.theme-pill__seg {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--color-text-secondary, #475569);
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 500;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.theme-pill__seg:hover {
    color: var(--color-text-primary, #1e293b);
    background: rgba(15, 43, 91, 0.06);
}

html.dark .theme-pill__seg {
    /* Higher contrast - readable against the dark glass bg */
    color: rgba(226, 232, 240, 0.78);
}

html.dark .theme-pill__seg:hover {
    color: #ffffff;
    background: rgba(0, 180, 216, 0.12);
}

/* Active segment - boost glow in dark mode so it pops */
html.dark .theme-pill__seg.is-active {
    background: linear-gradient(135deg, #1a65d6, #00B4D8);
    box-shadow:
        0 1px 4px rgba(0, 180, 216, 0.5),
        0 0 0 1px rgba(0, 180, 216, 0.4);
}

.theme-pill__seg.is-active {
    background: linear-gradient(135deg, var(--color-primary, #0F2B5B), var(--color-secondary, #00B4D8));
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 180, 216, 0.35);
}

.theme-pill__seg.is-active:hover {
    color: #fff;
}

.theme-pill__seg i {
    font-size: 0.85rem;
}

/* Compact label on small screens */
@media (max-width: 900px) {
    .theme-pill {
        right: 68px;
        top: 12px;
    }
    .theme-pill__seg span {
        display: none;
    }
    .theme-pill__seg {
        padding: 0.5rem 0.625rem;
    }
}

/* Mobile: tuck under the menu burger so it doesn't overlap content */
@media (max-width: 600px) {
    .theme-pill {
        right: 60px;
    }
}
