/* ==========================================================================
   COMMAND CENTER DASHBOARD - MAIN STYLESHEET
   Version: 1.0.0

   TABLE OF CONTENTS
   ==========================================================================

   0. FONT FACES
   1. DESIGN TOKENS (CSS Custom Properties)
   2. RESET & BASE
   3. LAYOUT COMPONENTS
   4. NAVIGATION
   5. CARDS
   6. DATA DISPLAY
   7. UI PRIMITIVES
   8. STATE COMPONENTS (Skeletons, Errors, Empty)
   9. UTILITIES
   10. RESPONSIVE

   ========================================================================== */


/* ==========================================================================
   0. FONT FACES
   ========================================================================== */

/* Industry - Brand Font */
@font-face {
    font-family: 'Industry';
    src: url('../assets/fonts/IndustryTest-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

/* Muli - Primary Font */
@font-face {
    font-family: 'Muli';
    src: url('../assets/fonts/Muli.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Muli';
    src: url('../assets/fonts/Muli-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}
@font-face {
    font-family: 'Muli';
    src: url('../assets/fonts/Muli-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}
@font-face {
    font-family: 'Muli';
    src: url('../assets/fonts/Muli-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

/* Timeout B - Secondary Headline / Accent Font */
@font-face {
    font-family: 'Timeout';
    src: url('../assets/fonts/timeout-b.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}


/* ==========================================================================
   1. DESIGN TOKENS
   ========================================================================== */

:root {
    /* Core palette - Deep slate with red accent (Nexus brand) */
    --bg-primary: #0a0c10;
    --bg-secondary: #12151c;
    --bg-tertiary: #1a1e28;
    --bg-elevated: #222836;
    --bg-hover: #2a303e;

    /* Accent colors (synced with department colors) */
    --accent-primary: #ef4444;      /* Brand - Red */
    --accent-secondary: #10b981;    /* HR - Emerald */
    --accent-success: #06b6d4;      /* Support - Cyan */
    --accent-warning: #f59e0b;      /* Operations - Amber */
    --accent-danger: #ef4444;
    --accent-info: #8b5cf6;         /* Maintenance - Purple */

    /* Semantic colors for data visualization */
    --color-positive: #22c55e;      /* Green - positive changes/deltas */
    --color-negative: #ef4444;      /* Red - negative changes/deltas */
    --color-positive-rgb: 34, 197, 94;
    --color-negative-rgb: 239, 68, 68;

    /* RGB variants for alpha blending */
    --accent-primary-rgb: 239, 68, 68;
    --accent-secondary-rgb: 16, 185, 129;
    --accent-success-rgb: 6, 182, 212;
    --accent-warning-rgb: 245, 158, 11;
    --accent-danger-rgb: 239, 68, 68;
    --accent-info-rgb: 139, 92, 246;

    /* Text hierarchy */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0a0c10;

    /* Borders & Dividers */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(239, 68, 68, 0.15);

    /* Typography */
    --font-display: 'Industry', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Muli', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-accent: 'Timeout', cursive;

    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Animation Timing Standards */
    --transition-card-expand: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --easing-standard: cubic-bezier(0.4, 0, 0.2, 1);

    /* Grid Standards */
    --grid-card-min-width: 225px;
    --grid-gap-cards: var(--space-lg);

    /* Z-Index Scale */
    --z-dropdown: 10;
    --z-sticky: 20;
    --z-header: 50;
    --z-sidebar: 100;
    --z-modal: 200;
    --z-toast: 300;
}


/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle background texture */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(239, 68, 68, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}


/* ==========================================================================
   3. LAYOUT COMPONENTS
   ========================================================================== */

/* Dashboard Wrapper */
/* Page Entry Animation */
@keyframes pageEnter {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    animation: pageEnter 350ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: var(--z-sidebar);
    transition: width 0.25s ease, transform var(--transition-base);
    overflow: hidden;
}

.sidebar-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
}

.logo-drop {
    height: 52px;
    width: auto;
    object-fit: contain;
}

.logo-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    line-height: 1;
}

.logo-tagline {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-top: 2px;
}

.logo-image {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-lg) var(--space-md);
    overflow-y: auto;
}

.sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}

/* Collapsed Sidebar (desktop) */
.dashboard-wrapper.sidebar-collapsed .sidebar {
    width: 60px;
}
.dashboard-wrapper.sidebar-collapsed .main-content {
    margin-left: 60px;
}
.dashboard-wrapper.sidebar-collapsed .logo-brand {
    display: none;
}
.dashboard-wrapper.sidebar-collapsed .logo-drop {
    height: 32px;
}
.dashboard-wrapper.sidebar-collapsed .sidebar-header {
    padding: 0.75rem;
    display: flex;
    justify-content: center;
}
.dashboard-wrapper.sidebar-collapsed .sidebar-header .logo {
    justify-content: center;
}
.dashboard-wrapper.sidebar-collapsed .nav-section-label {
    display: none;
}
.dashboard-wrapper.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0.6rem;
    font-size: 0;
    gap: 0;
}
.dashboard-wrapper.sidebar-collapsed .nav-icon {
    font-size: 1rem;
}
.dashboard-wrapper.sidebar-collapsed .nav-badge {
    display: none;
}
.dashboard-wrapper.sidebar-collapsed .sidebar-footer {
    padding: 0.5rem;
    display: flex;
    justify-content: center;
}
.dashboard-wrapper.sidebar-collapsed .user-info {
    justify-content: center;
}
.dashboard-wrapper.sidebar-collapsed .user-details {
    display: none;
}
.dashboard-wrapper.sidebar-collapsed .user-logout-btn {
    display: none;
}
.dashboard-wrapper.sidebar-collapsed .sidebar-version-link,
.dashboard-wrapper.sidebar-collapsed .sidebar-footer-row {
    display: none;
}

/* Header */
.header {
    height: var(--header-height);
    background: rgba(18, 21, 28, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.page-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breadcrumb-separator {
    opacity: 0.5;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Search Box */
.search-box {
    position: relative;
}

.search-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    padding-left: 38px;
    font-size: 0.875rem;
    color: var(--text-primary);
    width: 240px;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    width: calc(100% + 136px);  /* Search box width + header actions (3×40px buttons + 2×8px gaps) */
    margin-top: var(--space-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.search-results--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-results__empty {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-subtle);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item--selected {
    background: var(--bg-hover);
}

.search-result__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
}

.search-result__content {
    flex: 1;
    min-width: 0;
}

.search-result__name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result__name mark {
    background: rgba(var(--accent-primary-rgb), 0.3);
    color: var(--accent-primary);
    padding: 0 2px;
    border-radius: 2px;
}

.search-result__dept {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.search-result__value {
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.sidebar-toggle-btn {
    display: flex;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-btn .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--accent-danger);
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

/* Dashboard Content */
.dashboard-content {
    flex: 1;
    padding: var(--space-xl);
}


/* ==========================================================================
   4. NAVIGATION
   ========================================================================== */

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

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 var(--space-md);
    margin-bottom: var(--space-sm);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(var(--page-accent-rgb, 239, 68, 68), 0.1);
    color: var(--page-accent, var(--accent-primary));
    transition: background 0.3s ease, color 0.3s ease;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--page-accent, var(--accent-primary));
    border-radius: 0 2px 2px 0;
    transition: background 0.3s ease;
}

.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-external-icon {
    margin-left: auto;
    opacity: 0.4;
    flex-shrink: 0;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
}

/* User Profile */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-info:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-info));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
    overflow: hidden;
}

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

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.user-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.user-logout-btn:hover {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.user-logout-btn svg {
    width: 18px;
    height: 18px;
}

/* Version Badge in Sidebar Footer */
.sidebar-version-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    margin-top: 0.5rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    width: fit-content;
}

.sidebar-version-link:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.sidebar-version-icon {
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-version-link:hover .sidebar-version-icon {
    opacity: 1;
}

.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-left: 0.6rem;
    margin-top: 2px;
}

.sidebar-sw-version {
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.sidebar-made-in {
    font-size: 0.55rem;
    color: var(--text-muted);
    opacity: 0.4;
}


/* ==========================================================================
   5. CARDS
   ========================================================================== */

/* Department Tabs */
.department-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-xl);
    background: var(--bg-secondary);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    width: fit-content;
}

.dept-tab {
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dept-tab:hover {
    color: var(--text-primary);
}

.dept-tab.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--grid-card-min-width), 1fr));
    gap: var(--grid-gap-cards);
    margin-bottom: var(--space-xl);
}

/* Full KPI Grid - for department pages with dense packing */
.kpi-grid--full {
    grid-template-columns: repeat(auto-fit, minmax(var(--grid-card-min-width), 1fr));
    grid-auto-flow: dense;
}

/* KPI Card */
.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--kpi-color, var(--accent-primary));
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: visible;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
}

.kpi-card:hover {
    border-color: var(--border-default);
    border-top-color: var(--kpi-color, var(--accent-primary));
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.kpi-header__left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.kpi-header__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kpi-header__text .kpi-category {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kpi-color, var(--accent-primary));
    flex-shrink: 0;
}

.kpi-body {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.kpi-footer {
    margin-top: auto;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
}

.kpi-trend.up,
.kpi-trend--up {
    color: var(--color-positive);
}

.kpi-trend.down,
.kpi-trend--down {
    color: var(--color-negative);
}

/* Semantic coloring based on favorable/unfavorable (overrides direction color) */
.kpi-trend.favorable {
    background: rgba(var(--color-positive-rgb), 0.1);
    color: var(--color-positive);
}

.kpi-trend.unfavorable {
    background: rgba(var(--color-negative-rgb), 0.1);
    color: var(--color-negative);
}

.kpi-trend.flat-trend {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
}

/* Trend Popover */
.kpi-trend {
    position: relative;
    cursor: pointer;
}

.trend-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    pointer-events: none;
    text-align: left;
    white-space: nowrap;
}

.trend-popover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bg-tertiary);
}

.kpi-trend:hover .trend-popover {
    opacity: 1;
    visibility: visible;
}

/* Elevate card z-index when popover is shown so it appears above adjacent cards */
.kpi-card:has(.kpi-trend:hover) {
    z-index: var(--z-dropdown);
}

/* Pop-under for top row cards (first 4 cards) - popover appears below instead of above */
.kpi-card-wrapper:nth-child(-n+4) .trend-popover {
    bottom: auto;
    top: calc(100% + 8px);
}

.kpi-card-wrapper:nth-child(-n+4) .trend-popover::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--bg-tertiary);
}

.trend-popover__header {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-xs);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.trend-popover__row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 2px 0;
}

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

.trend-popover__value {
    color: var(--text-primary);
    font-weight: 500;
}

.trend-popover__dates {
    margin-top: var(--space-xs);
    padding-top: var(--space-xs);
    border-top: 1px solid var(--border-subtle);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-label--link {
    text-decoration: none;
    color: inherit;
    transition: color 0.15s ease;
}

.kpi-label--link:hover {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.kpi-sparkline {
    width: 100%;
    height: 40px;
    max-height: 40px;
    overflow: visible;
}

/* Hide sparkline canvas initially to prevent flash before animation */
.kpi-sparkline canvas {
    transition: opacity 0.1s ease;
}

/* KPI header actions container (info + export buttons) */
.kpi-header__actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* KPI Info Button */
.kpi-info-btn {
    position: relative;
    padding: 4px 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s ease, color 0.15s ease;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.kpi-info-btn:hover {
    opacity: 1;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

/* KPI Info Popover */
.kpi-info-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm) var(--space-md);
    z-index: calc(var(--z-sidebar) + 10);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    pointer-events: none;
    text-align: left;
    white-space: normal;
}

.kpi-info-btn:hover .kpi-info-popover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Elevate card z-index when info popover is shown — above expanded cards and sidebar */
.kpi-card:has(.kpi-info-btn:hover) {
    z-index: calc(var(--z-sidebar) + 5);
}

.kpi-info-popover__desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: var(--space-sm);
}

.kpi-info-popover__meta {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.kpi-info-popover__type {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 99px;
}

.kpi-info-popover__type--source {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.kpi-info-popover__type--calculated {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.kpi-info-popover__source {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.kpi-info-popover__formula {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.kpi-info-popover__formula-kpi {
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.kpi-info-popover__formula-kpi:hover {
    opacity: 0.8;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.kpi-info-popover__formula-op {
    color: var(--text-muted);
    font-weight: 400;
}

/* Pop-under for first row info buttons (avoid clipping above viewport) */
.kpi-card-wrapper:nth-child(-n+4) .kpi-info-popover {
    bottom: auto;
    top: calc(100% + 8px);
}

/* Expandable KPI Card */
.kpi-card {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.kpi-card__summary {
    display: flex;
    flex-direction: column;
    flex: 1;
    transition: opacity 0.2s ease;
}

.kpi-card__details {
    display: none;
    opacity: 0;
}

.kpi-card--expanded {
    grid-column: span 2;
    cursor: default;
    transform: scale(1);
}

.kpi-card--expanded .kpi-card__summary {
    display: none;
}

.kpi-card--expanded .kpi-card__details {
    display: block;
    animation: kpiSlideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Expand/Collapse animations */
@keyframes kpiSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KPI Card — Restricted State */
.kpi-card--restricted {
    opacity: 0.75;
    border-color: rgba(245, 158, 11, 0.3);
}
.kpi-card__restricted {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 0;
    min-height: 60px;
}
.kpi-card__restricted-icon {
    color: #f59e0b;
    font-size: 22px;
}
.kpi-card__restricted-msg {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

/* KPI Card Loading State (for date range refresh) */
.kpi-card.refreshing {
    pointer-events: none;
}

.kpi-card.refreshing .kpi-card__summary {
    opacity: 0.4;
}

.kpi-card.refreshing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.08),
        transparent
    );
    background-size: 200% 100%;
    animation: kpiShimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-lg);
    pointer-events: none;
}

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

/* Contracting animation for collapse - scales from expanded to collapsed size */
.kpi-card-wrapper.contracting {
    transition: transform var(--transition-card-expand);
}

.kpi-card__close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-xs);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    z-index: 10;
}

.kpi-card__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* Top actions wrapper - trend badge + close button together */
.kpi-card__top-actions {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    z-index: 10;
}

/* Override close button positioning when inside top-actions */
.kpi-card__top-actions .kpi-card__close {
    position: static;
}

.kpi-card__details-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.kpi-card__details-header > .kpi-icon {
    margin-top: 4px;
    flex-shrink: 0;
}

.kpi-card__metrics-row {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: var(--space-lg);
    padding-right: 40px;
}

.kpi-card__current .kpi-value {
    font-size: 1.5rem;
}

.kpi-card__current .kpi-label {
    margin-top: 2px;
}

.kpi-card__comparison-top {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.kpi-card__prior {
    display: flex;
    flex-direction: column;
}

.kpi-card__prior-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-card__prior-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Responsible party section */
.kpi-card__owner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.kpi-card__owner-label {
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-card__owner-value {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
}

.kpi-card__owner-value svg {
    color: var(--text-muted);
}

.kpi-card__chart-container {
    height: 260px;
    margin-bottom: var(--space-xl);
}

.chart-type-toggle {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
    margin-bottom: var(--space-sm);
}

.chart-type-toggle .control-btn {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8125rem;
}

.kpi-detailed-chart {
    width: 100%;
    height: 100%;
}

.kpi-card__table-container {
    max-height: 200px;
    overflow-y: auto;
}

.kpi-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.kpi-data-table th,
.kpi-data-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.kpi-data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

.kpi-data-table td {
    color: var(--text-primary);
}

.table-prior-date {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.kpi-data-table td:last-child {
    text-align: right;
}

.kpi-data-table .change-up,
.kpi-data-table .change-favorable {
    color: var(--color-positive);
}

.kpi-data-table .change-down,
.kpi-data-table .change-unfavorable {
    color: var(--color-negative);
}

.kpi-data-table .change-neutral {
    color: #eab308;
}

/* KPI Card Footer with Department Link */
.kpi-card__footer {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.kpi-card__dept-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--kpi-color, var(--accent-primary));
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.kpi-card__dept-link:hover {
    gap: var(--space-sm);
}

.kpi-card__dept-link svg {
    transition: transform var(--transition-fast);
}

.kpi-card__dept-link:hover svg {
    transform: translateX(4px);
}

/* KPI Header Actions (export button + trend) */
.kpi-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    align-self: flex-start;
    margin-top: var(--space-md);
}

/* Export Button Styles */
.kpi-export-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kpi-export-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.kpi-export-btn:active {
    transform: scale(0.98);
}

/* Small export button for summary view */
.kpi-export-btn--small {
    padding: 4px 6px;
    background: transparent;
    border: none;
    opacity: 0.5;
}

.kpi-export-btn--small:hover {
    background: var(--bg-tertiary);
    opacity: 1;
}

/* Export section in expanded card footer */
.kpi-card__export-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.kpi-card__export-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-card__export-buttons {
    display: flex;
    gap: var(--space-xs);
}

/* Links section in expanded card footer */
.kpi-card__links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
}

/* Export Dropdown (for small button click) */
.export-dropdown {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 180px;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.export-dropdown__header {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.export-dropdown__option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.export-dropdown__option:hover {
    background: var(--bg-tertiary);
}

.export-dropdown__option svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.export-dropdown__desc {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* KPI Card Wrapper (for dashboard) */
.kpi-card-wrapper {
    position: relative;
    align-self: start;
}

/* FLIP animation for grid reflow */
.kpi-card-wrapper.animating {
    transition: transform var(--transition-card-expand);
}

/* Smooth wrapper transition when expanding */
.kpi-card-wrapper {
    transition: none;
}

/* Z-index management for expansion */
.kpi-card-wrapper:has(.kpi-card--expanded) {
    grid-column: span 2;
    z-index: 20; /* Keep above other cards */
}

.kpi-card-wrapper.animating {
    z-index: 30; /* Highest priority during animation */
    transform-origin: top left;
    will-change: transform;
}

/* Responsive: Collapse to single column on smaller screens */
@media (max-width: 768px) {
    .kpi-card--expanded {
        grid-column: span 1;
    }
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

/* Chart Card */
.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    overflow: hidden;
}

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

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.chart-actions {
    display: flex;
    gap: var(--space-xs);
}

.chart-action-btn {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.chart-action-btn:hover,
.chart-action-btn.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 280px;
    max-height: 280px;
    overflow: hidden;
}

.chart-container canvas {
    max-height: 100% !important;
}

/* Table Section */
.table-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

/* Table Card */
.table-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.table-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Activity Card */
.activity-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.activity-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}


/* ==========================================================================
   6. DATA DISPLAY
   ========================================================================== */

/* Data Table */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

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

.data-table tr:hover td {
    background: var(--bg-hover);
}

/* Activity Feed */
.activity-list {
    padding: var(--space-md);
    max-height: 320px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.activity-item:hover {
    background: var(--bg-hover);
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot.blue { background: var(--accent-secondary); }
.activity-dot.green { background: var(--color-positive); }
.activity-dot.amber { background: var(--accent-warning); }
.activity-dot.red { background: var(--accent-danger); }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.activity-text strong {
    color: var(--text-primary);
    font-weight: 500;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}


/* ==========================================================================
   7. UI PRIMITIVES
   ========================================================================== */

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
}

.status-badge.active::before {
    background: var(--accent-success);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-warning);
}

.status-badge.pending::before {
    background: var(--accent-warning);
}

.status-badge.inactive {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
}

.status-badge.inactive::before {
    background: var(--text-muted);
}

/* Progress Bars */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-slow);
}

.progress-fill.primary { background: var(--accent-primary); }
.progress-fill.success { background: var(--accent-success); }
.progress-fill.info { background: var(--accent-info); }
.progress-fill.warning { background: var(--accent-warning); }

/* Progress Inline */
.progress-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-inline .progress-bar {
    width: 80px;
}


/* ==========================================================================
   8. STATE COMPONENTS
   ========================================================================== */

/* Skeleton Base */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-hover) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

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

/* KPI Skeleton */
.skeleton-kpi {
    padding: var(--space-lg);
}

.skeleton-kpi .skeleton-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.skeleton-kpi .skeleton-icon {
    width: 40px;
    height: 40px;
}

.skeleton-kpi .skeleton-badge {
    width: 60px;
    height: 24px;
    border-radius: 20px;
}

.skeleton-kpi .skeleton-value {
    width: 120px;
    height: 32px;
    margin-bottom: var(--space-xs);
}

.skeleton-kpi .skeleton-label {
    width: 100px;
    height: 16px;
}

.skeleton-kpi .skeleton-sparkline {
    width: 100%;
    height: 40px;
    margin-top: var(--space-md);
}

/* Chart Skeleton */
.skeleton-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 280px;
}

.skeleton-chart-area {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
}

/* Table Skeleton */
.skeleton-table .skeleton-th {
    width: 80%;
    height: 12px;
}

.skeleton-table .skeleton-td {
    width: 60%;
    height: 16px;
}

/* Activity Skeleton */
.skeleton-activity-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
}

.skeleton-activity-item .skeleton-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.skeleton-activity-item .skeleton-text {
    width: 80%;
    height: 16px;
    margin-bottom: var(--space-xs);
}

.skeleton-activity-item .skeleton-time {
    width: 60px;
    height: 12px;
}

/* ============================
   KPI GRID SKELETON
   ============================ */

.kpi-grid-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.skeleton-kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    animation: skeletonFadeIn 0.3s ease-out both;
}

.skeleton-kpi-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.skeleton-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
}

.skeleton-kpi-export {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
}

.skeleton-kpi-card__body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.skeleton-kpi-value {
    width: 100px;
    height: 36px;
    border-radius: var(--radius-sm);
}

.skeleton-kpi-trend {
    width: 60px;
    height: 24px;
    border-radius: var(--radius-full);
}

.skeleton-kpi-card__footer {
    margin-top: auto;
}

.skeleton-kpi-sparkline {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
}

/* KPI Grid wrapper for fade-in animation */
.kpi-grid-content {
    position: relative;
}

.kpi-grid-content .kpi-grid {
    opacity: 0;
}

.kpi-grid-content .kpi-grid.visible {
    opacity: 1;
}

/* KPI Skeleton Card (inline loading state) */
.kpi-card--skeleton {
    animation: kpiCardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kpi-card--skeleton .kpi-icon {
    background: var(--bg-tertiary);
}

/* KPI Card Fade In Animation */
.kpi-card-wrapper.fade-in {
    animation: kpiCardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes kpiCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Skeleton fade out */
.kpi-grid-skeleton.fade-out {
    animation: skeletonFadeOut 0.3s ease-out forwards;
}

/* ============================
   KPI DETAIL PAGE SKELETON
   ============================ */

.kpi-detail-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* Detail Header Skeleton */
.skeleton-detail-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    position: relative;
    overflow: hidden;
}

.skeleton-detail-header__indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg-tertiary);
}

.skeleton-detail-header__content {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.skeleton-detail-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.skeleton-detail-header__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.skeleton-detail-title {
    width: 200px;
    height: 24px;
    border-radius: var(--radius-sm);
}

.skeleton-detail-description {
    width: 300px;
    height: 16px;
    border-radius: var(--radius-sm);
}

.skeleton-detail-header__metrics {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.skeleton-detail-value {
    width: 80px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.skeleton-detail-trend {
    width: 60px;
    height: 24px;
    border-radius: var(--radius-full);
}

/* Detail Controls Skeleton */
.skeleton-detail-controls {
    display: flex;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.skeleton-control-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.skeleton-control-label {
    width: 50px;
    height: 12px;
    border-radius: var(--radius-sm);
}

.skeleton-control-buttons {
    width: 200px;
    height: 36px;
    border-radius: var(--radius-md);
}

/* Detail Chart Skeleton */
.skeleton-detail-chart {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    height: 350px;
}

.skeleton-detail-chart .skeleton-chart-area {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
}

/* Detail Table Skeleton */
.skeleton-detail-table {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.skeleton-detail-table__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.skeleton-table-title {
    width: 60px;
    height: 20px;
    border-radius: var(--radius-sm);
}

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

.skeleton-export-btn {
    width: 60px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.skeleton-table-container {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.skeleton-table-row {
    width: 100%;
    height: 40px;
    border-radius: var(--radius-sm);
}

/* Detail content fade in */
.kpi-detail-content {
    opacity: 0;
}

.kpi-detail-content.visible {
    opacity: 1;
}

.kpi-detail-content.fade-in > * {
    animation: kpiDetailFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kpi-detail-content.fade-in > *:nth-child(1) { animation-delay: 0s; }
.kpi-detail-content.fade-in > *:nth-child(2) { animation-delay: 0.1s; }
.kpi-detail-content.fade-in > *:nth-child(3) { animation-delay: 0.2s; }
.kpi-detail-content.fade-in > *:nth-child(4) { animation-delay: 0.3s; }
.kpi-detail-content.fade-in > *:nth-child(5) { animation-delay: 0.4s; }

@keyframes kpiDetailFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive skeleton adjustments */
@media (max-width: 768px) {
    .skeleton-detail-header__content {
        flex-direction: column;
        align-items: flex-start;
    }

    .skeleton-detail-header__metrics {
        width: 100%;
        justify-content: flex-start;
    }

    .skeleton-detail-title {
        width: 150px;
    }

    .skeleton-detail-description {
        width: 200px;
    }
}

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    text-align: center;
    min-height: 120px;
}

.error-state__icon {
    color: var(--accent-danger);
    margin-bottom: var(--space-md);
}

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

.error-state__retry {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.error-state__retry:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Context-specific error sizing */
.error-state--chart { min-height: 280px; }
.error-state--kpi { min-height: 150px; }
.error-state--table { min-height: 200px; }

/* ==================== KPI Detail Loading Overlay ==================== */
.kpi-detail-header,
.kpi-detail-chart,
.kpi-detail-table {
    position: relative;
}

.kpi-detail-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 16, 0.75);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.kpi-detail-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.kpi-detail-loading-overlay__spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: detailSpinner 0.7s linear infinite;
}

@keyframes detailSpinner {
    to { transform: rotate(360deg); }
}

.kpi-detail-loading-overlay__message {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: var(--space-sm);
    text-align: center;
    max-width: 240px;
}

/* ==================== KPI Card Expanded Loading States ==================== */
.kpi-card__chart-container,
.kpi-card__table-container {
    position: relative;
}

.kpi-card__chart-container.is-loading .kpi-detailed-chart,
.kpi-card__table-container.is-loading .kpi-data-table {
    opacity: 0.15;
    transition: opacity 0.2s ease;
}

.kpi-card__chart-container.is-loading::after,
.kpi-card__table-container.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    background-size: 200% 100%;
    animation: kpiShimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
    pointer-events: none;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
}

.empty-state__icon {
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state__message {
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

/* Component State Modifiers */
.kpi-card--loading .kpi-content,
.kpi-card--error .kpi-content {
    display: none;
}

.kpi-card--loading .skeleton-kpi,
.kpi-card--error .error-state {
    display: flex;
}

.chart-card--loading .chart-container canvas,
.chart-card--error .chart-container canvas {
    display: none;
}


/* ==========================================================================
   9. TOAST NOTIFICATIONS
   ========================================================================== */

/* Toast Container */
.toast-container {
    position: fixed;
    top: calc(var(--space-lg) + env(safe-area-inset-top, 0px));
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
    max-width: 400px;
    width: calc(100vw - var(--space-xl) * 2);
}

/* Individual Toast */
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease forwards;
    overflow: hidden;
    position: relative;
}

.toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--toast-color, var(--accent-info));
}

.toast.toast--exiting {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Toast Icon */
.toast__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--toast-color, var(--accent-info));
}

/* Toast Content */
.toast__content {
    flex: 1;
    min-width: 0;
}

.toast__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast__message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Toast Close Button */
.toast__close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    margin: -4px -8px -4px 0;
}

.toast__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Toast Progress Bar */
.toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--toast-color, var(--accent-info));
    opacity: 0.5;
    animation: toastProgress var(--toast-duration, 5s) linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Toast Variants */
.toast--success {
    --toast-color: var(--accent-success);
}

.toast--error {
    --toast-color: var(--accent-danger);
}

.toast--warning {
    --toast-color: var(--accent-warning);
}

.toast--info {
    --toast-color: var(--accent-info);
}

/* Toast with action button */
.toast__action {
    margin-top: var(--space-sm);
}

.toast__action-btn {
    padding: var(--space-xs) var(--space-sm);
    background: rgba(var(--accent-primary-rgb), 0.1);
    border: 1px solid rgba(var(--accent-primary-rgb), 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toast__action-btn:hover {
    background: rgba(var(--accent-primary-rgb), 0.2);
}


/* ==========================================================================
   10. NOTIFICATION CENTER
   ========================================================================== */

/* Notification Panel */
.notification-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: calc(240px + 136px);
    margin-top: var(--space-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow: hidden;
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}

.notification-panel--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Panel Header */
.notification-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.notification-panel__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.notification-panel__clear-btn {
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.notification-panel__clear-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-secondary);
}

/* Notification List */
.notification-panel__list {
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
}

/* Empty State */
.notification-panel__empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
    color: var(--text-muted);
}

.notification-panel__empty svg {
    opacity: 0.4;
    margin-bottom: var(--space-md);
}

.notification-panel__empty p {
    font-size: 0.875rem;
    margin: 0;
}

/* Notification Item */
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
    position: relative;
}

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

.notification-item:hover {
    background: var(--bg-hover);
}

/* Unread indicator */
.notification-item--unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-info);
}

/* Type-specific colors for unread indicator */
.notification-item--success.notification-item--unread::before {
    background: var(--accent-success);
}

.notification-item--error.notification-item--unread::before {
    background: var(--accent-danger);
}

.notification-item--warning.notification-item--unread::before {
    background: var(--accent-warning);
}

/* Notification Icon */
.notification-item__icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
}

.notification-item--success .notification-item__icon {
    color: var(--accent-success);
}

.notification-item--error .notification-item__icon {
    color: var(--accent-danger);
}

.notification-item--warning .notification-item__icon {
    color: var(--accent-warning);
}

.notification-item--info .notification-item__icon {
    color: var(--accent-info);
}

/* Notification Content */
.notification-item__content {
    flex: 1;
    min-width: 0;
}

.notification-item__title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-item__message {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-item__time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Notification Actions */
.notification-item__actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.notification-item:hover .notification-item__actions {
    opacity: 1;
}

.notification-item__action-btn,
.notification-item__dismiss-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.notification-item__action-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.notification-item__dismiss-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

/* Active state for notification button */
.header-btn--active {
    background: var(--bg-hover);
    color: var(--text-primary);
}


/* ==========================================================================
   11. DATE RANGE PICKER
   ========================================================================== */

/* Date Range Display in Header */
.date-range-display {
    margin-left: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.header-btn[aria-label="Date Range"] {
    width: auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    min-width: auto;
    gap: var(--space-xs);
}

.header-btn[aria-label="Date Range"]:hover .date-range-display {
    color: var(--text-primary);
}

.header-btn--active .date-range-display {
    color: var(--accent-primary);
}

/* Date Range Panel */
.date-range-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 340px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    margin-top: var(--space-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.date-range-panel--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Panel Header */
.date-range-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.date-range-panel__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.date-range-panel__close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.date-range-panel__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Presets Section */
.date-range-panel__presets {
    padding: var(--space-md) var(--space-lg);
}

.date-range-panel__preset-group {
    margin-bottom: var(--space-md);
}

.date-range-panel__preset-group:last-child {
    margin-bottom: 0;
}

.date-range-panel__preset-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.date-range-panel__preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

/* Preset Button */
/* Shared toggle button style for date range panel (presets, granularity, comp mode) */
.dr-toggle-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dr-toggle-btn:hover:not(:disabled):not(.active) {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.dr-toggle-btn.active {
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.dr-toggle-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Legacy class aliases */
.preset-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.preset-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.preset-btn.active {
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.preset-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.preset-btn:disabled:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

/* Divider */
.date-range-panel__divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0 var(--space-lg);
}

/* Custom Range Section */
.date-range-panel__custom {
    padding: var(--space-md) var(--space-lg);
}

.date-range-panel__custom-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.date-range-panel__custom-inputs {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.date-input-group {
    flex: 1;
    position: relative;
}

/* Right-align end date Flatpickr calendars so they don't overflow the panel's right edge */
.date-range-panel__custom-inputs .date-input-group:has(#date-range-end) .flatpickr-calendar,
.date-range-panel__comp-custom .date-input-group:has(#comp-range-end) .flatpickr-calendar {
    left: auto !important;
    right: 0 !important;
    transform: none !important;
}

.date-input-group label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.date-input {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    padding-right: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: var(--font-body);
    /* Calendar icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.2);
}

/* Hide native date input picker indicator when using Flatpickr */
.date-input::-webkit-calendar-picker-indicator {
    display: none;
}

.date-input::-webkit-inner-spin-button,
.date-input::-webkit-clear-button {
    display: none;
}

.date-range-panel__separator {
    color: var(--text-muted);
    font-size: 0.75rem;
    padding-bottom: var(--space-xs);
}

.date-range-panel__apply-btn {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-inverse);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-range-panel__apply-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.date-range-panel__apply-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Granularity Section */
.date-range-panel__granularity {
    padding: var(--space-md) var(--space-lg);
}

.date-range-panel__granularity-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.date-range-panel__granularity-buttons {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.granularity-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.granularity-btn:hover:not(:disabled):not(.active) {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.granularity-btn.active {
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.granularity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Compare Mode Section */
.date-range-panel__comp-mode {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.date-range-panel__comp-mode-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.date-range-panel__comp-mode-buttons {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.date-range-panel__comp-custom {
    padding: var(--space-md) var(--space-lg);
    padding-top: 0;
}

.date-range-panel__comp-apply-btn {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-inverse);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-range-panel__comp-apply-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.date-range-panel__comp-apply-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Current Selection Display */
.date-range-panel__current {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.75rem;
    position: sticky;
    bottom: 82px;
    z-index: 1;
}

.date-range-panel__current svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.date-range-panel__current-label {
    color: var(--text-primary);
    font-weight: 500;
}

.date-range-panel__current-days {
    color: var(--text-muted);
}

/* Comparison Summary Display */
.date-range-panel__comp-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px var(--space-lg);
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    position: sticky;
    bottom: 52px;
    z-index: 1;
}

.date-range-panel__comp-summary svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.date-range-panel__comp-days {
    opacity: 0.7;
}

/* Footer with Apply/Cancel buttons */
.date-range-panel__footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    position: sticky;
    bottom: 0;
    z-index: 1;
}

.date-range-panel__cancel-btn,
.date-range-panel__confirm-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-range-panel__cancel-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.date-range-panel__cancel-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.date-range-panel__confirm-btn {
    background: var(--accent-primary);
    border: none;
    color: var(--text-inverse);
}

.date-range-panel__confirm-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.date-range-panel__confirm-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Visual indicator for pending changes */
.date-range-panel.has-pending-changes .date-range-panel__current {
    background: rgba(var(--accent-primary-rgb, 239, 68, 68), 0.1);
    border-left: 3px solid var(--accent-primary);
}

/* Adjust current section when footer is present */
.date-range-panel__current {
    border-radius: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .date-range-panel {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        width: 100%;
        max-height: calc(100vh - var(--header-height));
        border-radius: 0;
        margin-top: 0;
        overflow-y: auto;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    }

    .date-range-display {
        display: none;
    }
}

/* Flatpickr Custom Dark Theme Overrides */
.flatpickr-calendar {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    width: 307px;
}

.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after {
    border-bottom-color: var(--bg-elevated);
}

.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after {
    border-top-color: var(--bg-elevated);
}

.flatpickr-months {
    background: var(--bg-elevated);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: var(--space-xs) 0;
}

.flatpickr-months .flatpickr-month {
    background: transparent;
    color: var(--text-primary);
    height: 34px;
}

.flatpickr-current-month {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 2px 4px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month .flatpickr-monthDropdown-months:focus {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Style the month dropdown options */
.flatpickr-current-month .flatpickr-monthDropdown-months option {
    background: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months option:hover {
    background: var(--bg-hover) !important;
}

.flatpickr-current-month input.cur-year {
    color: var(--text-primary);
    font-weight: 600;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--text-secondary);
    fill: var(--text-secondary);
    padding: var(--space-xs);
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    color: var(--text-primary);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--text-primary);
}

.flatpickr-innerContainer {
    background: var(--bg-elevated);
}

.flatpickr-weekdays {
    background: var(--bg-elevated);
}

.flatpickr-weekday {
    background: transparent !important;
    color: var(--text-secondary) !important;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

span.flatpickr-weekday {
    color: var(--text-secondary) !important;
}

.flatpickr-days {
    background: var(--bg-elevated);
    border: none;
}

.dayContainer {
    padding: var(--space-xs);
}

.flatpickr-day {
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    height: 34px;
    line-height: 34px;
    border: 1px solid transparent;
}

.flatpickr-day:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.flatpickr-day.today {
    border-color: var(--accent-primary);
}

.flatpickr-day.today:hover {
    background: rgba(var(--accent-primary-rgb), 0.1);
    color: var(--text-primary);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.flatpickr-day.inRange {
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-color: transparent;
    box-shadow: none;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-muted);
}

.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
    background: var(--bg-hover);
    border-color: var(--border-subtle);
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: var(--text-muted);
    opacity: 0.4;
    cursor: not-allowed;
}

/* Position flatpickr inline within panel (static mode) */
.date-input-group {
    position: relative;
}

.date-input-group .flatpickr-wrapper {
    width: 100%;
}

.date-input-group .flatpickr-calendar.static {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: var(--space-xs);
    z-index: 100;
}

/* Ensure calendar doesn't overflow panel */
.date-range-panel__custom {
    position: relative;
    overflow: visible;
}


/* ==========================================================================
   12. UTILITIES
   ========================================================================== */

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

/* Staggered animation delays */
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }

.chart-card { animation: fadeInUp 0.5s ease 0.25s forwards; opacity: 0; }
.table-card { animation: fadeInUp 0.5s ease 0.35s forwards; opacity: 0; }
.activity-card { animation: fadeInUp 0.5s ease 0.4s forwards; opacity: 0; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* Hide scrollbar on mobile */
@media (max-width: 768px) {
    ::-webkit-scrollbar { display: none; }
    * { scrollbar-width: none; }
}


/* ==========================================================================
   10. RESPONSIVE
   ========================================================================== */

@media (max-width: 1200px) {
    .charts-section {
        grid-template-columns: 1fr;
    }

    .table-section {
        grid-template-columns: 1fr;
    }
}

/* Mobile Nav Bar (Separate from Sidebar) */
.mobile-nav-bar {
    display: none;
}

@media (max-width: 768px) {
    /* Native app feel */
    html {
        -webkit-tap-highlight-color: transparent;
        overscroll-behavior-y: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    /* Backdrop overlay when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-backdrop.active {
        display: block;
        opacity: 1;
    }

    .mobile-nav-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Height is 60px content + safe area padding */
        height: calc(60px + env(safe-area-inset-bottom, 20px));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-subtle);
        border-radius: 20px 20px 0 0;
        z-index: 1000;
        justify-content: space-around;
        align-items: flex-start;
        padding-top: 8px;
        padding-bottom: env(safe-area-inset-bottom, 20px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
        box-sizing: border-box;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 44px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 500;
        transition: color 0.2s ease, opacity 0.05s ease;
        -webkit-user-select: none;
        user-select: none;
    }

    .mobile-nav-item {
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-item:active,
    .mobile-nav-item.tapped {
        transform: scale(0.90);
        opacity: 0.6;
        transition: transform 0.1s ease, opacity 0.1s ease;
    }

    .mobile-nav-item.active {
        color: var(--text-primary);
        /* Use accent color for active icon */
    }

    .mobile-nav-item.active .mobile-nav-icon {
        color: var(--accent-primary);
    }

    .mobile-nav-icon {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
    }

    /* Main Content Adjustments */
    .main-content {
        margin-left: 0;
        /* Padding bottom = Nav height (60px) + Safe Area + Extra breathing room (20px) */
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    }

    .header {
        padding: env(safe-area-inset-top, 0px) 16px 0 16px;
        height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    }

    .sidebar-toggle-btn {
        display: none !important;
    }

    .search-box {
        display: none; /* Hide search on mobile for now */
    }

    .dashboard-content {
        padding: 16px;
    }

    /* Force single column grid */
    .kpi-grid, .charts-section, .table-section {
        grid-template-columns: 1fr !important;
    }
    
    /* Hide elements not suitable for mobile */
    .desktop-only {
        display: none !important;
    }
}

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


/* ==========================================================================
   KPI DETAIL PAGE
   ========================================================================== */

/* KPI Detail Header */
.kpi-detail-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.kpi-detail-header__indicator {
    width: 6px;
    align-self: stretch;
    background: var(--dept-accent);
    border-radius: 3px;
    flex-shrink: 0;
}

.kpi-detail-header__content {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex: 1;
    flex-wrap: wrap;
}

.kpi-detail-header__icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.kpi-detail-header__info {
    flex: 1;
    min-width: 200px;
}

.kpi-detail-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-xs) 0;
}

.kpi-detail-header__description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
    max-width: 600px;
}

.kpi-detail-header__meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    flex-wrap: wrap;
}

.kpi-detail-header__source {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.kpi-detail-header__formula {
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.kpi-detail-header__formula a {
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.kpi-detail-header__formula a:hover {
    opacity: 0.8;
    text-decoration: underline;
    text-underline-offset: 2px;
}


.kpi-detail-header__metrics {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

.kpi-detail-header__value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-display);
}

.kpi-detail-header__values {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.kpi-detail-header__current {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.kpi-detail-header__metrics .kpi-trend {
    font-size: 1rem;
    padding: var(--space-sm) var(--space-md);
}

/* Prior period value in header */
.kpi-detail-header__prior {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    opacity: 0.6;
}

.kpi-detail-header__prior-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: var(--font-display);
}

.kpi-detail-header__prior-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── Formula Calculation Display (Header — inline in metrics) ── */
.formula-calculation {
    display: flex;
    align-items: center;
    gap: 14px;
}

.formula-calculation__expression {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.formula-calculation__component {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 14px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.formula-calculation__component:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1.03);
}

.formula-calculation__label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--comp-color);
    opacity: 0.6;
    margin-bottom: 1px;
    font-weight: 500;
}

.formula-calculation__value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--comp-color);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.formula-calculation__bar {
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.15));
    margin: 3px 0;
    border-radius: 1px;
}

.formula-calculation__equals {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 300;
}

.formula-calculation__multiplier {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
}

/* Formula animation */
.formula-calculation--animate .formula-calculation__component,
.formula-calculation--animate .formula-calculation__bar,
.formula-calculation--animate .formula-calculation__multiplier,
.formula-calculation--animate .formula-calculation__equals {
    animation: formulaFadeSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.formula-calculation--animate .formula-calculation__component--num {
    animation-delay: 0s;
}

.formula-calculation--animate .formula-calculation__bar {
    animation-delay: 0.1s;
    animation-name: formulaBarReveal;
}

.formula-calculation--animate .formula-calculation__component--den {
    animation-delay: 0.2s;
}

.formula-calculation--animate .formula-calculation__multiplier {
    animation-delay: 0.35s;
}

.formula-calculation--animate .formula-calculation__equals {
    animation-delay: 0.4s;
}

@keyframes formulaFadeSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes formulaBarReveal {
    from {
        opacity: 0;
        transform: scaleX(0);
    }
    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* Hide animation */
.formula-calculation--hiding {
    animation: formulaFadeOut 0.3s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes formulaFadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-12px);
    }
}

/* ── Table Fraction (inline, compact) ── */
.calc-cell {
    white-space: nowrap;
}

.table-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    line-height: 1.2;
    font-size: 0.8rem;
    padding: 2px 0;
}

.table-fraction__num,
.table-fraction__den {
    font-variant-numeric: tabular-nums;
    padding: 1px 6px;
    font-weight: 500;
}

.table-fraction__bar {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 1px 0;
}

.table-fraction__mult {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.75rem;
    margin-left: 6px;
    vertical-align: middle;
}

/* Prior period calc cell — slightly muted */
.calc-cell--prior {
    opacity: 0.55;
}

/* KPI Detail Controls */
.kpi-detail-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.control-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.control-btn {
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.control-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.control-btn.active {
    background: rgba(var(--page-accent-rgb, 239, 68, 68), 0.15);
    border-color: var(--page-accent);
    color: var(--page-accent);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* KPI Detail Chart */
.kpi-detail-chart {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    height: 400px;
    contain: layout style;
}

/* KPI Detail Table */
.kpi-detail-table {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-xl);
}

.kpi-detail-table__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.kpi-detail-table__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.kpi-detail-table__actions {
    display: flex;
    gap: var(--space-xs);
}

.kpi-detail-table__container {
    max-height: 400px;
    overflow-y: auto;
}

.kpi-detail-table .kpi-data-table {
    width: 100%;
    border-collapse: collapse;
}

.kpi-detail-table .kpi-data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.kpi-detail-table .kpi-data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.kpi-detail-table .kpi-data-table tr:hover td {
    background: var(--bg-hover);
}

.kpi-detail-table .kpi-data-table .change-favorable {
    color: var(--color-positive);
    font-weight: 600;
}

.kpi-detail-table .kpi-data-table .change-unfavorable {
    color: var(--color-negative);
    font-weight: 600;
}

.kpi-detail-table .kpi-data-table .change-neutral {
    color: #eab308;
    font-weight: 600;
}

/* Back Link */
.back-link-container {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

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

/* KPI Card Detail Link */
.kpi-card__detail-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--kpi-color, var(--accent-primary));
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.kpi-card__detail-link:hover {
    gap: var(--space-sm);
}

.kpi-card__detail-link svg {
    transition: transform var(--transition-fast);
}

.kpi-card__detail-link:hover svg {
    transform: translateX(4px);
}

/* Responsive adjustments for KPI detail */
@media (max-width: 768px) {
    .kpi-detail-header__content {
        flex-direction: column;
    }

    .kpi-detail-header__metrics {
        width: 100%;
        justify-content: flex-start;
    }

    .kpi-detail-controls {
        flex-direction: column;
    }

    .control-selector {
        overflow-x: auto;
    }

    .kpi-detail-chart {
        height: 360px;
        padding: var(--space-md);
    }

    /* Stack legend above toolbar on mobile so they don't collide */
    .kpi-detail-chart .apexcharts-legend {
        padding: 0 !important;
        margin-bottom: 4px !important;
    }

    .kpi-detail-chart .apexcharts-toolbar {
        top: 0 !important;
        right: 4px !important;
    }

    /* Ensure x-axis labels are visible */
    .kpi-detail-chart .apexcharts-xaxis-texts-g text {
        font-size: 9px !important;
    }

    /* Formula calculation mobile */
    .formula-calculation {
        gap: 8px;
    }

    .formula-calculation__value {
        font-size: 0.85rem;
    }

    .formula-calculation__label {
        font-size: 0.5rem;
    }

    .formula-calculation__component {
        padding: 3px 8px;
    }

    .formula-calculation__equals {
        font-size: 1rem;
    }

    .formula-calculation__multiplier {
        font-size: 0.8rem;
    }

    .table-fraction {
        font-size: 0.7rem;
    }

    /* Prior value mobile */
    .kpi-detail-header__values {
        align-items: flex-start;
    }

    .kpi-detail-header__prior-value {
        font-size: 0.85rem;
    }
}


/* ==========================================================================
   13. PERIOD SELECTOR
   ========================================================================== */

.period-selector {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-xl);
    background: var(--bg-secondary);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    width: fit-content;
}

.period-btn {
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.period-btn:hover {
    color: var(--text-primary);
}

.period-btn.active {
    background: var(--bg-elevated);
    color: var(--page-accent, var(--text-primary));
    box-shadow: var(--shadow-sm);
}

/* Department-specific accent color for period selector */
.period-btn.active[style*="--dept-accent"] {
    color: var(--dept-accent, var(--page-accent, var(--text-primary)));
    border-bottom: 2px solid var(--dept-accent, var(--page-accent, var(--accent-primary)));
}


/* ==========================================================================
   14. DEPARTMENT HEADER
   ========================================================================== */

.dept-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.dept-header__indicator {
    width: 6px;
    height: 36px;
    background: var(--dept-accent, var(--page-accent, var(--accent-primary)));
    border-radius: 3px;
}

.dept-header__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}


/* ==========================================================================
   15. SECTION TITLE
   ========================================================================== */

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    margin-top: var(--space-xl);
}


/* ==========================================================================
   16. DEPARTMENT CARDS
   ========================================================================== */

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

.dept-card-container {
    position: relative;
}

.dept-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.dept-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--dept-color);
}

.dept-card:hover {
    border-color: var(--border-default);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dept-card[aria-expanded="true"] {
    border-color: var(--dept-color);
    box-shadow: var(--shadow-md);
}

.dept-card__name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.dept-card__desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dept-card__arrow {
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.dept-card:hover .dept-card__arrow {
    color: var(--dept-color);
}

.dept-card[aria-expanded="true"] .dept-card__arrow {
    color: var(--dept-color);
    transform: translateY(-50%) rotate(180deg);
}

/* Department Dropdown */
.dept-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all var(--transition-base);
    margin-top: var(--space-xs);
}

.dept-dropdown--open {
    max-height: 400px;
    overflow-y: auto;
    opacity: 1;
}

.dept-dropdown__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.dept-dropdown__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dept-dropdown__view-all {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.dept-dropdown__view-all:hover {
    color: var(--accent-primary);
}

.dept-dropdown__list {
    max-height: 320px;
    overflow-y: auto;
}

.dept-dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    text-decoration: none;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.dept-dropdown__item:last-child {
    border-bottom: none;
}

.dept-dropdown__item:hover {
    background: var(--bg-secondary);
}

.dept-dropdown__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.dept-dropdown__info {
    flex: 1;
    min-width: 0;
}

.dept-dropdown__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.dept-dropdown__item .kpi-trend {
    font-size: 0.7rem;
    flex-shrink: 0;
}


/* ==========================================================================
   17. BACK LINK
   ========================================================================== */

.back-link-container {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

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


/* ==========================================================================
   CHANGELOG TIMELINE
   ========================================================================== */

.changelog-page {
    max-width: 800px;
}

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

.changelog-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.changelog-subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Timeline Container */
.timeline {
    position: relative;
    padding-left: var(--space-md);
}

.timeline-loading,
.timeline-error {
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
}

/* Timeline Item */
.timeline-item {
    display: flex;
    gap: var(--space-lg);
    position: relative;
    padding-bottom: var(--space-lg);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item:last-child .timeline-line {
    display: none;
}

/* Timeline Marker (dot + line) */
.timeline-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 20px;
}

.timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 3px solid var(--accent-primary);
    z-index: 1;
    transition: all 0.2s ease;
}

.timeline-item.expanded .timeline-dot {
    background: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

.timeline-line {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: calc(100% - 4px);
    background: var(--border-subtle);
}

/* Timeline Content */
.timeline-content {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.timeline-item.expanded .timeline-content {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Timeline Header (clickable) */
.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    cursor: pointer;
    transition: background 0.2s ease;
}

.timeline-header:hover {
    background: var(--bg-hover);
}

.timeline-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.timeline-version {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(239, 68, 68, 0.1);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.timeline-title-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

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

.timeline-chevron {
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.timeline-item.expanded .timeline-chevron {
    transform: rotate(180deg);
}

/* Timeline Details (expandable) */
.timeline-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-item.expanded .timeline-details {
    max-height: 5000px;
}

/* Timeline Categories */
.timeline-category {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.timeline-category-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.timeline-category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.timeline-category--features .timeline-category-dot {
    background: var(--color-positive);
}

.timeline-category--improvements .timeline-category-dot {
    background: var(--accent-info);
}

.timeline-category--fixes .timeline-category-dot {
    background: var(--color-negative);
}

.timeline-category-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-category--features .timeline-category-title {
    color: var(--color-positive);
}

.timeline-category--improvements .timeline-category-title {
    color: var(--accent-info);
}

.timeline-category--fixes .timeline-category-title {
    color: var(--color-negative);
}

/* Timeline List */
.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline-list li {
    position: relative;
    padding-left: var(--space-lg);
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.timeline-list li:last-child {
    margin-bottom: 0;
}

.timeline-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.5em;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .timeline-meta {
        width: 100%;
        justify-content: space-between;
    }

    .timeline-info {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
}

/* ============================
   TIMELINE SKELETON LOADING
   ============================ */

.timeline-skeleton {
    display: flex;
    flex-direction: column;
}

.skeleton-timeline-item {
    display: flex;
    gap: var(--space-lg);
    padding-bottom: var(--space-xl);
    opacity: 1;
    animation: skeletonFadeIn 0.3s ease-out both;
}

.skeleton-timeline-item .timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.skeleton-timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-tertiary);
}

.skeleton-timeline-item .timeline-line {
    width: 2px;
    flex: 1;
    min-height: 60px;
    background: var(--border-subtle);
    margin-top: var(--space-sm);
}

.skeleton-timeline-item:last-child .timeline-line {
    display: none;
}

.skeleton-timeline-content {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    min-height: 70px;
}

.skeleton-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.skeleton-timeline-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.skeleton-timeline-version {
    width: 60px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
}

.skeleton-timeline-title {
    width: 180px;
    height: 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.skeleton-timeline-date {
    width: 100px;
    height: 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

/* Skeleton Shimmer Animation */
.skeleton-timeline-dot.skeleton,
.skeleton-timeline-version.skeleton,
.skeleton-timeline-title.skeleton,
.skeleton-timeline-date.skeleton {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Staggered animation for skeleton items */
.skeleton-timeline-item:nth-child(1) .skeleton {
    animation-delay: 0s;
}

.skeleton-timeline-item:nth-child(2) .skeleton {
    animation-delay: 0.15s;
}

.skeleton-timeline-item:nth-child(3) .skeleton {
    animation-delay: 0.3s;
}

/* Fade out animation for skeleton */
.timeline-skeleton.fade-out {
    animation: skeletonFadeOut 0.3s ease-out forwards;
}

@keyframes skeletonFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes skeletonFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Timeline item fade in animation */
.timeline-item.fade-in {
    animation: timelineItemFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes timelineItemFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive skeleton */
@media (max-width: 600px) {
    .skeleton-timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .skeleton-timeline-title {
        width: 140px;
    }
}


/* ==========================================================================
   18. APEXCHARTS OVERRIDES
   ========================================================================== */

.apexcharts-menu {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-default) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-lg) !important;
    border-radius: var(--radius-md) !important;
    padding: var(--space-xs) !important;
    min-width: 140px !important;
}

.apexcharts-menu-item {
    color: var(--text-secondary) !important;
    font-family: var(--font-body) !important;
    font-size: 0.8rem !important;
    transition: all var(--transition-fast);
    padding: var(--space-sm) var(--space-md) !important;
    border-radius: var(--radius-sm);
}

.apexcharts-menu-item:hover {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Toolbar icons */
.apexcharts-toolbar {
    z-index: 10 !important;
}

.apexcharts-toolbar svg {
    fill: var(--text-muted) !important;
    transition: fill var(--transition-fast);
}

.apexcharts-toolbar svg:hover {
    fill: var(--text-primary) !important;
}

.apexcharts-toolbar .apexcharts-menu-icon:hover svg,
.apexcharts-toolbar .apexcharts-reset-icon:hover svg,
.apexcharts-toolbar .apexcharts-zoom-icon:hover svg,
.apexcharts-toolbar .apexcharts-zoomin-icon:hover svg,
.apexcharts-toolbar .apexcharts-zoomout-icon:hover svg,
.apexcharts-toolbar .apexcharts-pan-icon:hover svg,
.apexcharts-toolbar .apexcharts-selection-icon:hover svg {
    fill: var(--text-primary) !important;
}

/* Active state for toolbar icons */
.apexcharts-toolbar .apexcharts-pan-icon.apexcharts-selected svg,
.apexcharts-toolbar .apexcharts-selection-icon.apexcharts-selected svg,
.apexcharts-toolbar .apexcharts-zoom-icon.apexcharts-selected svg {
    fill: var(--accent-primary) !important;
}

/* Tooltip customization to match theme */
.apexcharts-tooltip {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-default) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    pointer-events: auto !important;
    will-change: transform !important;
    transform: translateZ(0);
    contain: layout paint;
    max-height: 350px;
    overflow-y: auto;
}

.apexcharts-tooltip-title {
    background: var(--bg-tertiary) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    font-family: var(--font-body) !important;
    font-size: 0.8rem !important;
    padding: var(--space-xs) var(--space-sm) !important;
}

.apexcharts-tooltip-text {
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
    font-size: 0.8rem !important;
    display: flex !important;
    align-items: center !important;
}

.apexcharts-tooltip-series-group {
    padding: 4px var(--space-sm) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

.apexcharts-tooltip-marker {
    width: 10px !important;
    height: 10px !important;
    margin-right: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    align-self: center !important;
}

.apexcharts-tooltip-y-group {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

/* X-axis tooltip */
.apexcharts-xaxistooltip {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-default) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    font-family: var(--font-body) !important;
    font-size: 0.75rem !important;
}

.apexcharts-xaxistooltip:after,
.apexcharts-xaxistooltip:before {
    border-bottom-color: var(--bg-elevated) !important;
}


/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .dashboard-wrapper {
        animation: none;
    }
}


/* ==========================================================================
   19. DASHBOARD CUSTOMIZATION
   ========================================================================== */

/* Dashboard Toolbar */
.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.dashboard-toolbar__left,
.dashboard-toolbar__right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.dashboard-toolbar__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dashboard-toolbar__btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.dashboard-toolbar__btn.active {
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.dashboard-toolbar__btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.dashboard-toolbar__btn--primary:hover {
    filter: brightness(1.1);
    color: white;
}

/* Responsive button labels - show full by default, short on mobile */
.dashboard-toolbar__label--short {
    display: none;
}

/* Layout Switcher */
.layout-switcher {
    position: relative;
}

.layout-switcher__btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 180px;
    justify-content: space-between;
}

.layout-switcher__btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.layout-switcher__btn svg {
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.layout-switcher__dropdown.open + .layout-switcher__btn svg,
.layout-switcher__btn[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.layout-switcher__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 250px;
    margin-top: var(--space-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

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

.layout-switcher__list {
    padding: var(--space-xs);
    overflow: visible;
}

.layout-switcher__item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.layout-switcher__item:hover {
    background: var(--bg-hover);
}

.layout-switcher__item.active {
    background: rgba(var(--accent-primary-rgb), 0.1);
}

.layout-switcher__item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
    min-width: 0;
}

.layout-switcher__item-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layout-switcher__item-meta {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.layout-switcher__item-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.layout-switcher__badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    background: rgba(var(--accent-primary-rgb), 0.15);
    color: var(--accent-primary);
    border-radius: var(--radius-full);
}

/* More button */
.layout-switcher__more-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.layout-switcher__item:hover .layout-switcher__more-btn {
    opacity: 1;
}

.layout-switcher__more-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Context Menu */
.layout-context-menu {
    position: absolute;
    top: 100%;
    right: var(--space-xs);
    z-index: var(--z-modal);
    min-width: 160px;
    padding: var(--space-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transform-origin: top right;
    transition: all 0.15s ease;
}

.layout-context-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px) scale(1);
}

.layout-context-menu__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-sm);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.layout-context-menu__item:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.layout-context-menu__item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.layout-context-menu__item--danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.layout-context-menu__divider {
    height: 1px;
    margin: var(--space-xs) 0;
    background: var(--border-subtle);
}

/* Layout Modal */
.layout-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1000);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.layout-modal.open {
    opacity: 1;
    visibility: visible;
}

.layout-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.layout-modal__content {
    position: relative;
    width: 90%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.2s ease;
}

.layout-modal.open .layout-modal__content {
    transform: translateY(0) scale(1);
}

.layout-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-default);
}

.layout-modal__header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.layout-modal__close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.layout-modal__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.layout-modal__body {
    padding: var(--space-lg);
}

.layout-modal__label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.layout-modal__input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.15s;
}

.layout-modal__input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.layout-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-default);
}

.layout-modal__btn {
    padding: var(--space-sm) var(--space-lg);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.layout-modal__btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.layout-modal__btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.layout-modal__btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.layout-modal__btn--danger {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.layout-modal__btn--danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* Toast Notification */
.layout-toast {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    z-index: 9999;
    transition: all 0.3s ease;
}

.layout-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Export Menu */
.export-menu {
    position: relative;
}

.export-menu__dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    min-width: 260px;
    margin-top: var(--space-xs);
    padding: var(--space-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transform-origin: top right;
    transition: all 0.15s ease;
}

.export-menu__dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.export-menu__header {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.export-menu__option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    text-align: left;
    text-decoration: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.export-menu__option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.export-menu__option svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.export-menu__option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.export-menu__option-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.export-menu__option-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.export-menu__option:hover .export-menu__option-desc {
    color: var(--text-secondary);
}

.export-menu__divider {
    height: 1px;
    margin: var(--space-xs) 0;
    background: var(--border-subtle);
}

.export-menu__option--link {
    border-top: 1px solid var(--border-subtle);
    margin-top: var(--space-xs);
    padding-top: var(--space-sm);
}

/* Site Selector */
.header-btn[aria-label="Site Filter"] {
    width: auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    min-width: auto;
    gap: var(--space-xs);
}

.site-selector-display {
    margin-left: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-btn[aria-label="Site Filter"]:hover .site-selector-display {
    color: var(--text-primary);
}

.site-selector {
    position: relative;
}

.site-selector__dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    min-width: 300px;
    max-width: 360px;
    margin-top: var(--space-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transform-origin: top right;
    transition: all 0.15s ease;
}

.site-selector__dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.site-selector__search {
    position: relative;
    padding: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
}

.site-selector__search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.site-selector__search-input {
    width: 100%;
    padding: 6px 8px 6px 28px;
    font-size: 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.site-selector__search-input:focus {
    border-color: var(--accent-primary);
}

.site-selector__body {
    max-height: 320px;
    overflow-y: auto;
    padding: var(--space-xs) 0;
}

.site-selector__section-header {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.site-selector__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 5px var(--space-sm);
    background: none;
    border: none;
    text-align: left;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 0.82rem;
}

.site-selector__item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.site-selector__item--all {
    padding: var(--space-xs) var(--space-sm);
    font-weight: 500;
}

.site-selector__item--active {
    color: var(--accent-primary);
}

.site-selector__item--active .site-selector__item-label {
    font-weight: 500;
}

.site-selector__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--accent-primary);
}

.site-selector__checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 1.5px solid var(--border-default);
    border-radius: 3px;
    transition: all var(--transition-fast);
}

.site-selector__checkbox--checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.site-selector__checkbox--partial {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.site-selector__checkbox-dash {
    font-size: 10px;
    line-height: 1;
    font-weight: 700;
}

.site-selector__item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-selector__item-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.site-selector__org-group {
    margin-bottom: 2px;
}

.site-selector__org-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 6px var(--space-sm);
    background: none;
    border: none;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.site-selector__org-header:hover {
    background: var(--bg-hover);
}

.site-selector__org-name {
    flex: 1;
}

.site-selector__org-group > .site-selector__item {
    padding-left: calc(var(--space-sm) + 24px);
}

.site-selector__group-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.site-selector__group-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
    padding: 5px var(--space-sm);
    background: none;
    border: none;
    text-align: left;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    transition: background var(--transition-fast);
}

.site-selector__group-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.site-selector__group-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.site-selector__group-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.site-selector__group-action--danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.site-selector__divider {
    height: 1px;
    margin: var(--space-xs) 0;
    background: var(--border-subtle);
}

.site-selector__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-sm);
}

.site-selector__footer-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

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

.site-selector__clear {
    font-size: 0.75rem;
    color: var(--accent-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.site-selector__clear:hover {
    background: rgba(var(--accent-primary-rgb, 59, 130, 246), 0.1);
}

.site-selector__new-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.site-selector__new-group:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Site Selector Apply/Cancel Actions */
.site-selector__actions {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.site-selector__cancel-btn,
.site-selector__apply-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.site-selector__cancel-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.site-selector__cancel-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.site-selector__apply-btn {
    background: var(--accent-primary);
    border: none;
    color: var(--text-inverse);
}

.site-selector__apply-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.site-selector__apply-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Site Selector Modal (for custom groups) */
.site-selector-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-selector-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.site-selector-modal__content {
    position: relative;
    width: 90%;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.site-selector-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.site-selector-modal__header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.site-selector-modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.site-selector-modal__close:hover {
    color: var(--text-primary);
}

.site-selector-modal__body {
    padding: var(--space-md);
}

.site-selector-modal__label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.site-selector-modal__input {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.site-selector-modal__input:focus {
    border-color: var(--accent-primary);
}

.site-selector-modal__sites {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-xs);
}

.site-selector-modal__site-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 4px var(--space-xs);
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.site-selector-modal__site-row:hover {
    background: var(--bg-hover);
}

.site-selector-modal__site-row input[type="checkbox"] {
    accent-color: var(--accent-primary);
}

.site-selector-modal__site-org {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.site-selector-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.site-selector-modal__btn {
    padding: 6px 16px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.site-selector-modal__btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.site-selector-modal__btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.site-selector-modal__btn--primary:hover {
    opacity: 0.9;
}

/* Orchestrator site card org badge */
.orch-site-card__org {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.layout-switcher__actions {
    padding: var(--space-xs);
    border-top: 1px solid var(--border-subtle);
}

.layout-switcher__action {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.layout-switcher__action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* KPI Grid Edit Mode */
.kpi-grid--edit-mode .kpi-card-wrapper {
    cursor: grab;
}

.kpi-grid--edit-mode .kpi-card-wrapper:active {
    cursor: grabbing;
}

.kpi-grid--edit-mode .kpi-card {
    border-style: dashed;
    position: relative;
}

.kpi-grid--edit-mode .kpi-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(var(--accent-primary-rgb), 0.03);
    pointer-events: none;
    border-radius: inherit;
}

.kpi-card-wrapper.dragging {
    opacity: 0.5;
}

.kpi-card-wrapper.drag-over {
    transform: scale(1.02);
}

.kpi-card-placeholder {
    background: rgba(var(--accent-primary-rgb), 0.1);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--accent-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ==========================================================================
   20. KPI PICKER MODAL
   ========================================================================== */

.kpi-picker-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.kpi-picker-modal.open {
    opacity: 1;
    visibility: visible;
}

.kpi-picker-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.kpi-picker-modal__content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 95%;
    max-width: 1100px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(20px) scale(0.98);
    transition: transform var(--transition-base);
}

.kpi-picker-modal.open .kpi-picker-modal__content {
    transform: translateY(0) scale(1);
}

.kpi-picker-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.kpi-picker-modal__header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.kpi-picker-modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kpi-picker-modal__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.kpi-picker-modal__body {
    display: grid;
    grid-template-columns: 200px 1fr 280px;
    flex: 1;
    overflow: hidden;
}

/* KPI Picker Sidebar */
.kpi-picker__sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.kpi-picker__search {
    position: relative;
}

.kpi-picker__search-icon {
    position: absolute;
    left: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.kpi-picker__search-input {
    width: 100%;
    padding: var(--space-sm) var(--space-sm) var(--space-sm) 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-body);
}

.kpi-picker__search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.2);
}

.kpi-picker__dept-tabs {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kpi-picker__dept-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.kpi-picker__dept-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.kpi-picker__dept-tab.active {
    background: var(--bg-secondary);
    color: var(--dept-color, var(--text-primary));
    font-weight: 600;
    border-left: 3px solid var(--dept-color, var(--accent-primary));
}

.kpi-picker__dept-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-full);
}

/* KPI Picker Main Grid */
.kpi-picker__main {
    padding: var(--space-md);
    overflow-y: auto;
}

.kpi-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-sm);
}

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

.kpi-picker__item:hover {
    border-color: var(--border-default);
    background: var(--bg-hover);
}

.kpi-picker__item.selected {
    border-color: var(--kpi-color, var(--accent-primary));
    background: rgba(var(--accent-primary-rgb), 0.1);
}

.kpi-picker__item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    color: var(--kpi-color, var(--text-secondary));
    flex-shrink: 0;
}

.kpi-picker__item-content {
    flex: 1;
    min-width: 0;
}

.kpi-picker__item-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-picker__item-dept {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.kpi-picker__item-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.kpi-picker__item-toggle:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.kpi-picker__item.selected .kpi-picker__item-toggle {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.kpi-picker__empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

/* KPI Picker Selected Panel */
.kpi-picker__selected {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.kpi-picker__selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.kpi-picker__selected-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.kpi-picker__selected-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.15);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.kpi-picker__selected-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.kpi-picker__selected-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.kpi-picker__selected-empty p {
    margin: 0 0 var(--space-xs) 0;
}

.kpi-picker__selected-hint {
    font-size: 0.75rem;
}

.kpi-picker__selected-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-xs);
    transition: transform 0.15s ease, opacity 0.15s ease,
                border-color 0.15s ease, background 0.15s ease;
}

.kpi-picker__selected-grip {
    color: var(--text-muted);
    cursor: grab;
    flex-shrink: 0;
}

.kpi-picker__selected-grip:active {
    cursor: grabbing;
}

/* Drag and drop states */
.kpi-picker__selected-item.dragging {
    opacity: 0.4;
    transform: scale(0.98);
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.kpi-picker__selected-item.drop-above {
    border-top-color: var(--accent-primary);
    border-top-width: 2px;
}

.kpi-picker__selected-item.drop-below {
    border-bottom-color: var(--accent-primary);
    border-bottom-width: 2px;
}

.kpi-picker__selected-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-picker__selected-label {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-picker__selected-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.kpi-picker__move-btn,
.kpi-picker__remove-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kpi-picker__move-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.kpi-picker__move-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.kpi-picker__remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

/* KPI Picker Footer */
.kpi-picker-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.kpi-picker__btn {
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kpi-picker__btn--secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.kpi-picker__btn--secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.kpi-picker__btn--primary {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.kpi-picker__btn--primary:hover {
    filter: brightness(1.1);
}

/* ==========================================================================
   21. SETUP WIZARD
   ========================================================================== */

.setup-wizard {
    position: fixed;
    inset: 0;
    z-index: 1100; /* Must be above mobile nav (1000) and sidebar (1001) */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.setup-wizard.open {
    opacity: 1;
    visibility: visible;
}

.setup-wizard__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.setup-wizard__container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 95%;
    max-width: 700px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    transition: transform var(--transition-base);
}

.setup-wizard.open .setup-wizard__container {
    transform: translateY(0) scale(1);
}

/* Progress Steps */
.setup-wizard__progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.setup-wizard__progress-step {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-default);
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.setup-wizard__progress-step.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.setup-wizard__progress-step.current {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.setup-wizard__progress-line {
    width: 40px;
    height: 2px;
    background: var(--border-default);
}

/* Wizard Content */
.setup-wizard__content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
}

.setup-wizard__step {
    animation: fadeInUp 0.3s ease;
}

.setup-wizard__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-sm) 0;
    text-align: center;
}

.setup-wizard__subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 var(--space-lg) 0;
    text-align: center;
}

.setup-wizard__count {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Welcome Step */
.setup-wizard__step--welcome {
    text-align: center;
    padding: var(--space-xl) 0;
}

.setup-wizard__welcome-icon {
    color: var(--accent-primary);
    margin-bottom: var(--space-lg);
}

.setup-wizard__hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: var(--space-md);
}

/* Presets Step */
.setup-wizard__presets {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.setup-wizard__preset {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
}

.setup-wizard__preset:hover {
    border-color: var(--border-default);
    background: var(--bg-hover);
}

.setup-wizard__preset.selected {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.1);
}

.setup-wizard__preset-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    flex-shrink: 0;
}

.setup-wizard__preset.selected .setup-wizard__preset-icon {
    color: var(--accent-primary);
}

.setup-wizard__preset-content {
    flex: 1;
}

.setup-wizard__preset-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.setup-wizard__preset-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.setup-wizard__preset-count {
    font-size: 0.75rem;
    color: var(--accent-primary);
    margin-top: var(--space-xs);
}

.setup-wizard__preset-check {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-default);
    border-radius: 50%;
    color: transparent;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.setup-wizard__preset.selected .setup-wizard__preset-check {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* KPI Selection Step */
.setup-wizard__kpi-groups {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.setup-wizard__kpi-group {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.setup-wizard__group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    border-left: 3px solid var(--dept-color, var(--accent-primary));
}

.setup-wizard__group-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setup-wizard__group-toggle {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.setup-wizard__group-toggle:hover {
    color: var(--accent-primary);
}

.setup-wizard__group-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-xs);
    padding: var(--space-sm);
}

.setup-wizard__kpi-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.setup-wizard__kpi-item:hover {
    background: var(--bg-hover);
}

.setup-wizard__kpi-item.selected {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.1);
}

.setup-wizard__kpi-item input {
    display: none;
}

.setup-wizard__kpi-icon {
    flex-shrink: 0;
}

.setup-wizard__kpi-label {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.setup-wizard__kpi-check {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: transparent;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.setup-wizard__kpi-item.selected .setup-wizard__kpi-check {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Review Step */
.setup-wizard__name-input {
    margin-bottom: var(--space-lg);
}

.setup-wizard__name-input label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.setup-wizard__name-input input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-body);
}

.setup-wizard__name-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.2);
}

.setup-wizard__review-list {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    max-height: 300px;
    overflow-y: auto;
}

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

.setup-wizard__review-item:last-child {
    border-bottom: none;
}

.setup-wizard__review-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.setup-wizard__review-icon {
    flex-shrink: 0;
}

.setup-wizard__review-label {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.setup-wizard__review-dept {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.setup-wizard__review-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

/* Wizard Footer */
.setup-wizard__footer {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.setup-wizard__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.setup-wizard__btn--secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.setup-wizard__btn--secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.setup-wizard__btn--primary {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.setup-wizard__btn--primary:hover:not(:disabled) {
    filter: brightness(1.1);
}

.setup-wizard__btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Setup Wizard — Mobile */
@media (max-width: 768px) {
    .setup-wizard__container {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 80px - env(safe-area-inset-bottom, 20px));
        margin-top: env(safe-area-inset-top, 0px);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        align-self: flex-end;
    }

    .setup-wizard__progress {
        padding: var(--space-md);
    }

    .setup-wizard__content {
        padding: var(--space-md);
    }

    .setup-wizard__title {
        font-size: 1.25rem;
    }

    .setup-wizard__step--welcome {
        padding: var(--space-md) 0;
    }

    .setup-wizard__preset-icon {
        width: 40px;
        height: 40px;
    }

    .setup-wizard__preset {
        padding: var(--space-md);
    }

    .setup-wizard__group-kpis {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .setup-wizard__review-list {
        max-height: 200px;
    }

    .setup-wizard__footer {
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
    }
}

/* ==========================================================================
   20. SEARCH PAGE
   ========================================================================== */

.search-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 160px);
}

.search-page__input-wrap {
    position: relative;
    padding: var(--space-md) 0;
}

.search-page__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-page__input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) 44px;
    font-size: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    -webkit-appearance: none;
}

.search-page__input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Override dropdown behavior — results are inline on the search page */
.search-page .search-results {
    position: static;
    width: 100%;
    margin-top: var(--space-sm);
    max-height: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: transparent;
}

.search-page .search-result-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    padding: var(--space-md);
}

.search-page .search-result-item:hover {
    background: var(--bg-elevated);
    border-color: var(--border-default);
}

.search-page .search-result-item:last-child {
    border-bottom: 1px solid var(--border-subtle);
}

.search-page .search-results__empty {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-page__empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    color: var(--text-muted);
    flex: 1;
}

.search-page__empty-state svg {
    opacity: 0.3;
}

.search-page__empty-state p {
    font-size: 0.875rem;
    max-width: 240px;
}

@media (min-width: 769px) {
    .search-page {
        max-width: 640px;
        margin: 0 auto;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-toolbar {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .dashboard-toolbar__left,
    .dashboard-toolbar__right {
        width: 100%;
        justify-content: center;
    }

    /* Export dropdown: fixed full-width panel on mobile */
    .export-menu {
        position: static;
    }

    .export-menu__dropdown {
        position: fixed;
        top: auto;
        left: var(--space-md);
        right: var(--space-md);
        min-width: unset;
        max-height: calc(100vh - 220px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform-origin: top center;
        z-index: 1000;
    }

    .export-menu__dropdown.open {
        transform: translateY(0) scale(1);
    }

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

    .site-selector__dropdown {
        position: fixed;
        top: auto;
        left: var(--space-md);
        right: var(--space-md);
        min-width: unset;
        max-width: unset;
        max-height: calc(100vh - 220px);
        -webkit-overflow-scrolling: touch;
        transform-origin: top center;
        z-index: 1000;
    }

    .site-selector__dropdown.open {
        transform: translateY(0) scale(1);
    }

    .site-selector__body {
        max-height: calc(100vh - 380px);
    }

    .site-selector-display {
        display: none;
    }

    .export-menu__option-label {
        font-size: 0.95rem;
    }

    .export-menu__option-desc {
        font-size: 0.8rem;
    }

    .export-menu__header {
        padding: var(--space-sm) var(--space-md);
    }

    /* Show short label on mobile, hide full label */
    .dashboard-toolbar__label--full {
        display: none;
    }

    .dashboard-toolbar__label--short {
        display: inline;
    }

    .kpi-picker-modal__body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .kpi-picker__sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .kpi-picker__dept-tabs {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .kpi-picker__selected {
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        max-height: 200px;
    }

    .setup-wizard__group-kpis {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   PWA Install Prompt — Bottom Sheet
   ============================================================ */

.install-prompt {
    position: fixed;
    inset: 0;
    z-index: 1100;
    pointer-events: none;
}

.install-prompt.open {
    pointer-events: auto;
}

.install-prompt__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 300ms ease;
}

.install-prompt.open .install-prompt__overlay {
    opacity: 1;
}

.install-prompt__sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-sm) var(--space-lg) var(--space-xl);
    transform: translateY(100%);
    transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.install-prompt.open .install-prompt__sheet {
    transform: translateY(0);
}

.install-prompt__handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-default);
    margin: 0 auto var(--space-md);
}

.install-prompt__header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.install-prompt__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.install-prompt__title-group {
    flex: 1;
    min-width: 0;
}

.install-prompt__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.install-prompt__subtitle {
    margin: 2px 0 0;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.install-prompt__close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.install-prompt__close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.install-prompt__description {
    margin: 0 0 var(--space-lg);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* iOS instruction steps */

.install-prompt__steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.install-prompt__step {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.install-prompt__step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.install-prompt__step-text {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
}

.install-prompt__inline-icon {
    display: inline-block;
    vertical-align: middle;
    color: var(--accent-primary);
    flex-shrink: 0;
}

/* Action buttons */

.install-prompt__actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    padding-top: var(--space-md);
}

.install-prompt__btn {
    padding: var(--space-sm) var(--space-lg);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.install-prompt__btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.install-prompt__btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.install-prompt__btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Responsive — mobile adjustments */

@media (max-width: 768px) {
    .install-prompt__sheet {
        max-width: none;
        border-radius: 16px 16px 0 0;
        padding-bottom: calc(var(--space-xl) + 70px + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 769px) {
    .install-prompt__sheet {
        bottom: var(--space-lg);
        border-radius: var(--radius-lg);
    }
}

/* ===================================================================
   Scheduled Exports
   =================================================================== */

/* Schedule card list */
.sched-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.sched-empty {
    padding: var(--space-xl);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.sched-empty--error { color: #fca5a5; }

/* Schedule card */
.sched-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: border-color 0.2s ease;
}
.sched-card:hover { border-color: var(--border-default); }
.sched-card--inactive { opacity: 0.5; }
.sched-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}
.sched-card__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sched-card__clickable { cursor: pointer; }
.sched-card__title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.sched-card__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sched-card__type {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.sched-card__owner {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.sched-card__meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.sched-card__id {
    font-family: var(--font-mono, monospace);
    font-size: 0.625rem;
    color: var(--text-muted);
    opacity: 0.7;
}
.sched-card__actions { display: flex; gap: 4px; flex-shrink: 0; }
.sched-card__btn {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.sched-card__btn:hover { border-color: var(--border-default); color: var(--text-primary); }
.sched-card__btn--danger:hover { border-color: rgba(239,68,68,0.5); color: #fca5a5; }
.sched-card__details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sched-card__divider { color: var(--border-default); }

/* Status badges */
.sched-status {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
}
.sched-status--success { background: rgba(16,185,129,0.1); color: #6ee7b7; }
.sched-status--error { background: rgba(239,68,68,0.15); color: #fca5a5; }
.sched-status--pending { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* Schedule modal (reused by exports, reports, admin) */
.sched-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.sched-modal.active { display: flex; }
.sched-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.sched-modal__content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: schedModalIn 0.2s ease;
}
.sched-modal__content--sm { max-width: 400px; }
.sched-modal__content--lg { max-width: 600px; }
@keyframes schedModalIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.sched-modal__header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 4px;
    padding: var(--space-lg) var(--space-xl) var(--space-md);
}
.sched-modal__header .sched-modal__close { margin-left: auto; }
.sched-modal__title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.sched-modal__subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: var(--space-sm);
}
.sched-modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease;
}
.sched-modal__close:hover { color: var(--text-primary); }
.sched-modal__body { padding: 0 var(--space-xl) var(--space-lg); }
.sched-modal__text { font-size: 0.875rem; color: var(--text-secondary); margin: 0 0 var(--space-sm); line-height: 1.5; }
.sched-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--border-subtle);
}
.sched-modal__btn {
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border-default);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}
.sched-modal__btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.sched-modal__btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}
.sched-modal__btn--primary:hover { opacity: 0.9; }
.sched-modal__btn--danger {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
}
.sched-modal__btn--danger:hover { background: rgba(239,68,68,0.25); border-color: #ef4444; }

/* Schedule form fields */
.sched-form-group { margin-bottom: var(--space-md); }
.sched-form-group--half { flex: 1; min-width: 0; }
.sched-form-row { display: flex; gap: var(--space-md); }
.sched-form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sched-form-input,
.sched-form-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s ease;
    color-scheme: dark;
}
.sched-form-input:focus,
.sched-form-select:focus { border-color: var(--accent-primary); }
.sched-form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 4px 0 0;
}
.sched-form-hint code {
    font-size: 0.6875rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-mono, monospace);
    color: var(--text-secondary);
}

/* File name preview */
.sched-filename-preview {
    color: var(--accent-primary);
    font-family: var(--font-mono, monospace);
    font-size: 0.6875rem;
    padding: 4px 8px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    margin-top: 6px;
}

/* Form divider */
.sched-form-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-md) 0;
}

/* Date mode radio group */
.sched-form-radio-group {
    display: flex;
    gap: var(--space-md);
    margin-top: 4px;
}
.sched-form-radio__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.sched-form-radio__label input[type="radio"] {
    accent-color: var(--accent-primary);
    margin: 0;
}

/* Comparison checkbox */
.sched-form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.sched-form-check input[type="checkbox"] {
    accent-color: var(--accent-primary);
    margin: 0;
}

/* KPI picker in schedule modal */
.sched-kpi-picker-container {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}
.sched-kpi-picker { padding: var(--space-xs) 0; }
.sched-kpi-dept { border-bottom: 1px solid var(--border-subtle); }
.sched-kpi-dept:last-child { border-bottom: none; }
.sched-kpi-dept__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--space-sm);
    background: rgba(255,255,255,0.02);
}
.sched-kpi-dept__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}
.sched-kpi-dept__label input[type="checkbox"] { accent-color: var(--accent-primary); }
.sched-kpi-dept__count {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
}
.sched-kpi-dept__list { padding: 0 var(--space-sm) var(--space-xs) 28px; }
.sched-kpi-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    cursor: pointer;
}
.sched-kpi-item__cb { accent-color: var(--accent-primary); }
.sched-kpi-item__label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.sched-kpi-total {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Site picker in schedule modal */
.sched-site-picker-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}
.sched-site-picker { padding: var(--space-xs) 0; }
.sched-site-picker__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255,255,255,0.03);
    position: sticky;
    top: 0;
    z-index: 1;
}
.sched-site-picker__select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
}
.sched-site-picker__select-all input[type="checkbox"] { accent-color: var(--accent-primary); }
.sched-site-picker__count {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
}
.sched-site-org { border-bottom: 1px solid var(--border-subtle); }
.sched-site-org:last-child { border-bottom: none; }
.sched-site-org__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--space-sm);
    background: rgba(255,255,255,0.02);
}
.sched-site-org__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}
.sched-site-org__label input[type="checkbox"] { accent-color: var(--accent-primary); }
.sched-site-org__count {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
}
.sched-site-org__list { padding: 0 var(--space-sm) var(--space-xs) 28px; }
.sched-site-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    cursor: pointer;
}
.sched-site-item__cb { accent-color: var(--accent-primary); }
.sched-site-item__label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.sched-site-total {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Email tag editor in schedule modal */
.sched-tag-editor {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    min-height: 42px;
    cursor: text;
    transition: border-color 0.2s ease;
}
.sched-tag-editor:focus-within { border-color: var(--accent-primary); }
.sched-tag-editor__input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.8125rem;
    min-width: 120px;
    flex: 1;
    padding: 2px 0;
}
.sched-tag-editor__input::placeholder { color: var(--text-muted); }
.sched-tag-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    padding: 4px 8px 4px 12px;
    font-size: 0.8125rem;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    animation: tagIn 0.15s ease;
}
.sched-tag-chip__remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    transition: color 0.15s ease, background 0.15s ease;
}
.sched-tag-chip__remove:hover {
    color: var(--accent-primary);
    background: rgba(239,68,68,0.15);
}

/* Inline error in schedule modal */
.sched-modal__error {
    margin: var(--space-md) 0 0;
    padding: var(--space-sm) var(--space-md);
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: #fca5a5;
    line-height: 1.5;
}
.sched-modal__error strong { color: #fecaca; }
.sched-error__domains {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sched-error__domain {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-mono, monospace);
}

/* Schedule section on pages */
.sched-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}
.sched-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}
.sched-section__title {
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.sched-section__count {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
}

/* Schedule button (inline with other action buttons) */
.sched-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.sched-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.sched-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Admin scheduled exports table */
.sched-admin-table {
    width: 100%;
    border-collapse: collapse;
}
.sched-admin-table th {
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}
.sched-admin-table td {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}
.sched-admin-table tr:hover td { background: rgba(255,255,255,0.02); }
.sched-admin-table .sched-inactive td { opacity: 0.5; }

@media (max-width: 768px) {
    .sched-form-row { flex-direction: column; gap: 0; }
    .sched-modal__content { width: 95%; max-height: 90vh; }
    .sched-admin-table { font-size: 0.75rem; }
    .sched-admin-table th, .sched-admin-table td { padding: var(--space-xs) var(--space-sm); }
}

/* ── Landscape orientation lock (phones only, not tablets) ── */
.landscape-lock-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--bg-primary);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-primary);
}

@media (orientation: landscape) and (max-height: 500px) {
    .landscape-lock-overlay {
        display: flex;
    }
}
