html {
    height: 100%;
}

body {
    height: 100%;
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #dc2626 0%, #ea580c 35%, #2563eb 100%);
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
}

/* Enhanced Design Tokens */
:root {
  /* Brand Colors */
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --brand-900: #1e3a8a;
  
  /* Grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Semantic Colors */
  --success-50: #f0fdf4;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --danger-50: #fef2f2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  
  /* Surfaces */
  --surface-primary: rgba(255, 255, 255, 0.95);
  --surface-secondary: rgba(255, 255, 255, 0.8);
  --surface-tertiary: rgba(255, 255, 255, 0.6);
  
  /* Professional Chart Colors - Manufacturing Focus */
  --chart-primary: #2563eb;
  --chart-primary-rgb: 37, 99, 235;
  --chart-success: #059669;
  --chart-success-rgb: 5, 150, 105;
  --chart-danger: #dc2626;
  --chart-danger-rgb: 220, 38, 38;
  --chart-neutral: #374151;
  --chart-neutral-rgb: 55, 65, 81;
  --chart-accent: #f97316;
  --chart-accent-rgb: 249, 115, 22;
  
  /* Chart Supporting Colors */
  --chart-bg-primary: rgba(37, 99, 235, 0.08);
  --chart-bg-success: rgba(5, 150, 105, 0.08);
  --chart-bg-danger: rgba(220, 38, 38, 0.08);
  --chart-grid: rgba(55, 65, 81, 0.12);
  --chart-grid-major: rgba(55, 65, 81, 0.2);
  --chart-text: #1f2937;
  --chart-text-secondary: #6b7280;
  --chart-text-muted: #9ca3af;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  /* Borders */
  --border-radius-sm: 6px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --border-radius-full: 9999px;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Chart Typography */
  --chart-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --chart-title-size: 1.125rem;
  --chart-title-weight: 600;
  --chart-title-size-mobile: 1rem;
  --chart-label-size: 0.875rem;
  --chart-label-weight: 500;
  --chart-label-size-mobile: 0.75rem;
  --chart-tick-size: 0.75rem;
  --chart-tick-weight: 400;
  --chart-tick-size-mobile: 0.625rem;
  --chart-legend-size: 0.8125rem;
  --chart-legend-weight: 500;
  --chart-legend-size-mobile: 0.75rem;
}

/* Utility Classes */
.glass {
  background: var(--surface-primary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

.rounded-sm { border-radius: var(--border-radius-sm); }
.rounded-md { border-radius: var(--border-radius-md); }
.rounded-lg { border-radius: var(--border-radius-lg); }
.rounded-xl { border-radius: var(--border-radius-xl); }
.rounded-full { border-radius: var(--border-radius-full); }

.text-gradient {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.active { color: var(--brand-600); }

#app {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    padding: var(--space-lg);
    max-width: 1800px; /* Increased from 1400px for wider charts */
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Prevent all overflow on main app */
}

.container {
    padding: var(--space-lg) 8px; /* 8px left/right, keep vertical padding */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100%;
    box-sizing: border-box;
    background: var(--surface-primary);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Remove white background on desktop for settings view */
@media (min-width: 769px) {
    .container {
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
    }
}

.chart-container {
    flex-grow: 1;
    position: relative;
    width: 100%;
    min-height: 0;
    max-width: 100%; /* Prevent overflow */
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-xl);
    padding: var(--space-lg) 0 0 0; /* Top padding only, 0 left/right/bottom */
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: var(--space-lg);
    overflow: hidden; /* Clip any overflow */
    box-sizing: border-box;
}

/* Professional Chart Canvas Styling */
.chart-container canvas {
    font-family: var(--chart-font-family) !important;
    border-radius: var(--border-radius-md);
    transition: all 0.3s ease;
}

.chart-container:hover {
    box-shadow: var(--shadow-2xl);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Desktop Navbar - Fixed and Improved */
nav {
    padding: 0 var(--space-xl);
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 72px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    min-width: 0; /* Prevent overflow */
}

/* Desktop only - ensure proper spacing and show desktop controls */
@media (min-width: 769px) {
    .nav-brand {
        flex: 0 0 auto;
        margin-right: var(--space-xl);
    }
    
    .nav-links {
        flex: 1;
        display: flex;
        justify-content: center;
        min-width: 0;
    }
    
    .nav-auth {
        flex: 0 0 auto;
        margin-left: var(--space-xl);
    }
    
    /* Show desktop controls, hide mobile controls */
    .desktop-controls {
        display: flex !important;
    }
    
    .mobile-control-bar,
    .mobile-overlays {
        display: none !important;
    }
}

.nav-brand a {
    text-decoration: none;
    font-weight: 700;
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
    transition: all 0.3s ease;
}

.nav-brand a:hover {
    transform: scale(1.05);
}

.nav-links {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    gap: var(--space-lg); /* Reduced gap to prevent overflow */
    justify-content: center;
    flex-wrap: nowrap;
}

.nav-links a {
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.95rem;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--border-radius-full);
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap; /* Prevent text wrapping */
    min-height: 44px; /* Touch target */
    display: flex;
    align-items: center;
}

.nav-links a:hover {
    color: var(--brand-600);
    background: var(--brand-50);
    transform: translateY(-1px);
}

/* Modern Active State */
.nav-links a.nav-link { position: relative; }
.nav-links a.nav-link.active {
    color: var(--brand-600);
    background: var(--brand-50);
    box-shadow: var(--shadow-sm);
}
/* Remove the dot - using background highlight instead */

/* Auth Navigation */
.nav-auth {
    display: flex;
    align-items: center;
}

.nav-auth .nav-link {
    color: #555;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-auth .nav-link:hover {
    color: #007bff;
}

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

.user-dropdown-btn {
    background: none;
    border: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #495057;
    font-weight: 500;
    transition: all 0.3s ease;
}

.user-dropdown-btn:hover {
    background-color: #f8f9fa;
    border-color: var(--brand-600);
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.user-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #fff;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1000;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    padding: 0.5rem 0;
    top: 100%;
    margin-top: 0.25rem;
}

.user-dropdown.open .user-dropdown-content {
    display: block;
}

.user-dropdown-content a {
    color: #495057;
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.user-dropdown-content a:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

.user-dropdown-content hr {
    margin: 0.5rem 0;
    border: none;
    border-top: 1px solid #dee2e6;
}

/* Admin-only elements */
.admin-only {
    display: none !important;
}

.user-admin .admin-only {
    display: block !important;
}

/* Main content styles */
main {
    padding: 16px 32px;
}

h1 {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: var(--space-md);
}

/* Professional SaaS Page Header - Ultra Compact */
.page-header {
    text-align: left; /* Left-align for professional SaaS look */
    margin-bottom: var(--space-sm); /* Even more compact */
    padding: var(--space-xs) 0; /* Minimal padding */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Subtle separator */
}

.page-header h1 {
    color: rgba(255, 255, 255, 0.95) !important;
    font-size: 1.5rem; /* Further reduced for SaaS compactness */
    font-weight: 600; /* Slightly lighter for modern feel */
    letter-spacing: -0.025em;
    margin-bottom: 0; /* Remove bottom margin */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); /* Subtle shadow */
    line-height: 1.2; /* Tight line height */
}

.page-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8125rem; /* Professional SaaS size */
    font-weight: 400; /* Lighter weight for modern feel */
    margin: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); /* Subtle shadow */
    line-height: 1.4; /* Tight line height */
}

.controls-container {
    text-align: center;
    margin-bottom: 20px;
}

.controls-container label {
    font-size: 1.1em;
    margin-right: 10px;
}

.controls-container select {
    padding: 8px;
    font-size: 1em;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* Modern Data Hub */
.data-hub-container {
    display: flex;
    height: calc(100vh - 140px);
    gap: var(--space-lg);
    overflow: hidden;
    padding: var(--space-lg) 8px; /* Match dashboard container spacing */
}

/* Desktop data hub - ensure main content scrolls */
@media (min-width: 769px) {
    .data-hub-container {
        align-items: stretch; /* Ensure children match height */
    }

    .data-hub-container > .sidebar,
    .data-hub-container > .main-content {
        height: 100%;
        box-sizing: border-box; /* Include borders/padding in height calc */
    }

    .main-content {
        overflow: hidden; /* hide outer scrollbar completely */
        height: 100%;
        max-height: none;
        scrollbar-width: none;        /* Firefox */
        -ms-overflow-style: none;     /* IE/Edge */
        display: flex;
        flex-direction: column;
        min-height: 0; /* allow children to size */
    }
    .main-content::-webkit-scrollbar { display: none; } /* WebKit */
    .spreadsheet-container {
        overflow: visible;
        height: auto;
        max-height: none;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    /* Align empty state to page center (account for 200px sidebar + gap) */
    .data-empty-state {
        transform: translateX(calc((-200px - var(--space-lg)) / 2));
    }
    /* Hide page header on desktop */
    .page-header { display: none; }
    
    /* Desktop Chart Sets - Show traditional list, hide dropdown */
    .dataset-selector-wrapper {
        display: none;
    }
    
    .dataset-list-desktop {
        display: block !important;
    }
    
    .sidebar {
        max-height: none !important;
        padding: var(--space-sm) !important;
        background: var(--surface-primary) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        box-shadow: var(--shadow-lg) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        display: block !important;
        gap: unset !important;
    }
    
    .sidebar-header {
        justify-content: space-between !important;
        margin-bottom: var(--space-md) !important;
        padding-bottom: var(--space-sm) !important;
        border-bottom: 1px solid var(--brand-100) !important;
        gap: unset !important;
    }
    
    .sidebar-header h2 {
        font-size: 1.1rem !important;
        color: var(--gray-800) !important;
    }
    
    #addDatasetBtn {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.9rem !important;
        background: linear-gradient(135deg, var(--brand-500), var(--brand-600)) !important;
        color: white !important;
        border-radius: var(--border-radius-full) !important;
        border: none !important;
    }
}

.sidebar {
    width: 200px; /* Even more compact for professional SaaS */
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: var(--space-sm); /* Tighter padding */
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
    flex-shrink: 0; /* Prevent shrinking */
}

.sidebar:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md); /* Smaller */
    padding-bottom: var(--space-sm); /* Smaller */
    border-bottom: 1px solid var(--brand-100); /* Thinner */
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem; /* Much smaller */
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.025em;
}

#addDatasetBtn {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    color: white;
    border: none;
    border-radius: var(--border-radius-full);
    width: 28px; /* Much smaller */
    height: 28px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

#addDatasetBtn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-lg);
}

#dataset-list .dataset-item {
    padding: var(--space-sm); /* Smaller padding */
    cursor: pointer;
    border-radius: var(--border-radius-md);
    margin-bottom: var(--space-xs); /* Less margin */
    font-weight: 600;
    font-size: 0.85rem; /* Smaller text */
    transition: all 0.3s ease;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

#dataset-list .dataset-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s ease;
}

#dataset-list .dataset-item:hover {
    background: var(--brand-50);
    border-color: var(--brand-200);
    transform: translateX(4px);
}

#dataset-list .dataset-item:hover::before {
    left: 100%;
}

#dataset-list .dataset-item.active {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    color: white;
    border-color: var(--brand-700);
    box-shadow: var(--shadow-md);
    transform: translateX(8px);
}

/* Series list styling removed for cleaner Chart Sets interface */

.main-content {
    flex-grow: 1;
    padding: var(--space-lg); /* Reduced padding */
    overflow-y: auto;
    background: transparent;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    position: relative; /* For proper scrolling */
}

/* Desktop toolbar above spreadsheet */
.desktop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-lg);
    padding: 10px 12px;
    box-shadow: var(--shadow-md);
}
.desktop-toolbar .toolbar-left,
.desktop-toolbar .toolbar-center,
.desktop-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.desktop-toolbar label,
.desktop-toolbar .date-sep {
    color: var(--gray-800);
    font-weight: 700;
}
.desktop-date-input {
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #111827;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.desktop-date-input::placeholder { color: #6b7280; }
.desktop-date-input:focus {
    outline: none;
    border-color: rgba(59,130,246,0.7);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
.desktop-toolbar .filter-controls .filter-btn {
    padding: 8px 14px; /* Increase size for desktop usability */
    font-weight: 600;
}

/* Ensure desktop toolbar never shows on mobile */
@media (max-width: 768px) {
    .desktop-toolbar { display: none !important; }
}

/* Table wrapper handles scroll; keep table header sticky */
.table-wrapper {
    /* Only this container should scroll vertically */
    overflow-y: auto;
    overflow-x: hidden;         /* avoid subtle horizontal scrollbar */
    position: relative;
    height: auto;
    max-height: 100%;           /* clamp to parent container */
    flex: 1 1 auto;
    min-height: 0;              /* prevent overflow in flex column */
    overscroll-behavior: contain; /* prevent scroll chaining to body */
    /* Card visuals moved from table to wrapper for proper clipping */
    background: var(--surface-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
}

/* Decorative top accent bar on wrapper (instead of table) */
.table-wrapper::before {
    content: '';
    position: sticky; /* stays pinned to top of scroll area */
    top: 0;
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-600), var(--brand-700));
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
    z-index: 31; /* above header bg */
}

/* Make header truly sticky within table wrapper */
.table-wrapper thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Professional SaaS Empty State */
.data-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    text-align: center;
    padding: var(--space-2xl);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    border-radius: var(--border-radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.data-empty-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
}

.empty-state-icon {
    margin-bottom: var(--space-lg);
    opacity: 0.8;
    color: rgba(255, 255, 255, 0.7);
    transform: scale(1.2); /* Slightly larger for impact */
    transition: transform 0.3s ease;
}

.data-empty-state:hover .empty-state-icon {
    transform: scale(1.25);
}

.data-empty-state h3 {
    font-size: 1.375rem;
    font-weight: 600; /* Professional weight */
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: var(--space-sm);
    letter-spacing: -0.025em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.data-empty-state p {
    font-size: 0.9375rem;
    line-height: 1.5;
    max-width: 420px;
    margin-bottom: var(--space-xl);
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.data-empty-state .btn {
    margin-top: var(--space-md);
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: all 0.3s ease;
}

.data-empty-state .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.placeholder {
    text-align: center;
    padding-top: 100px;
    color: #888;
}

.placeholder h2 {
    font-size: 1.8em;
    margin-bottom: 10px;
}

/* Spreadsheet Styles */
.spreadsheet-container {
    width: 100%;
    overflow-x: visible;
    flex-grow: 1; /* Take remaining space */
    height: auto; /* allow content-driven height on desktop */
    max-height: none; /* don't clamp; inner wrapper manages scroll */
    padding: 0; /* No padding, let content fill space */
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;    /* visuals handled by wrapper */
    overflow: visible;          /* allow sticky header to work properly */
    position: relative;
}

/* removed top bar from table; now on .table-wrapper::before */

th, td {
    padding: var(--space-lg) var(--space-xl);
    border: none;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

/* Sticky table header inside the scrollable wrapper */
thead {
    position: sticky;
    top: 0;
    z-index: 30;
    display: table-header-group; /* ensure proper table semantics */
}

thead th {
    background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
    font-weight: 700;
    position: sticky; /* keep individual cells sticky for wide support */
    top: 0;
    z-index: 30;
    color: var(--brand-800);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--brand-200);
}

/* Keep the new-entry row fixed just below the sticky header */
#new-entry-row {
    position: sticky;
    top: var(--sticky-header-offset, 64px);
    z-index: 29; /* below header and accent bar */
    background: var(--surface-primary);
}
#new-entry-row td { background: var(--surface-primary); }

tbody tr {
    transition: all 0.3s ease;
}

tbody tr:nth-of-type(even) {
    background: rgba(255, 255, 255, 0.3);
}

tbody tr:hover {
    background: var(--brand-50);
    transform: scale(1.01);
    box-shadow: var(--shadow-md);
    z-index: 1;
    position: relative;
}

td[contenteditable="true"] {
    cursor: cell;
}

td[contenteditable="true"]:focus {
    background-color: #e2efff;
    outline: 2px solid #007bff;
    box-shadow: 0 0 5px rgba(0,123,255,0.5);
}

td.changed {
    background-color: #e2efff; /* Changed to blue */
    position: relative;
}

/* Adds a small triangle to the corner of changed cells */
td.changed::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    border-style: solid;
    border-width: 6px;
    border-color: #007bff transparent transparent transparent; /* Changed to blue */
}

td.invalid {
    background-color: #ffe2e2;
}

th.add-column-cell {
    width: 40px;
    text-align: center;
}

#addSeriesBtn {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1.4em;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.spreadsheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 10px;
}

.filter-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-btn {
    padding: 5px 15px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #333; /* Added for visibility */
    border-radius: 5px;
    cursor: pointer;
}

.filter-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

#new-entry-row td {
    background-color: #f8f9fa;
    position: sticky;
    top: 48px; /* Height of thead th */
    z-index: 9;
}

#new-entry-row input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#new-entry-row button {
    width: 100%;
    padding: 8px;
    border: none;
    background-color: #28a745;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}

#saveChangesBtn {
    padding: 8px 20px;
    font-size: 0.9em;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.dashboard-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: visible; /* Allow controls to show */
    min-height: 40px; /* Smaller but not too small */
}

.dashboard-controls::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-400), var(--brand-500), var(--brand-600));
}

/* Compact toolbar alignment */
.dashboard-controls .control-group label{color:var(--text-600);font-weight:600}
.dashboard-controls select{background:#fff}
.chart-navigation .nav-btn{border-radius:999px}

/* Override for compact chart selectors */
.chart-list-item {
    font-size: 0.7rem;
    padding: 2px 6px;
    height: 18px; /* Ultra small height */
}

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

.control-group label {
    font-weight: 500;
    font-size: 0.8rem; /* Smaller */
    margin: 0;
}

.control-group select {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--border-radius-sm);
    border: 1px solid #ccc;
    font-size: 0.8rem;
    min-height: 32px;
}

.chart-navigation {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-list {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.chart-list-item {
    padding: 2px 8px; /* Very minimal padding */
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem; /* Smaller text */
    transition: background-color 0.2s;
    height: 20px; /* Even smaller height */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
}

.chart-list-item:hover {
    background-color: #e9ecef;
}

.chart-list-item.active { 
    background-color: var(--brand-600); 
    color: #fff;
    font-weight: 600;
}


#chartNameDisplay {
    font-weight: 600;
    font-size: 1.1em;
    padding: 0 10px;
    text-align: center;
    min-width: 150px; /* Give it some space */
}

.nav-btn {
    padding: 6px 12px;
    border-radius: 5px;
    border: 1px solid #007bff;
    background-color: #007bff;
    color: white;
    cursor: pointer;
}

.nav-btn:disabled {
    background-color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

#saveChangesBtn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

hr {
    border: 0;
    height: 1px;
    background: #ccc;
    margin: 40px 0;
}

/* Form Section styles */
.management-container {
    max-width: 1200px;
    margin: auto;
    text-align: center;
}

.form-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    text-align: left;
    display: inline-block;
    vertical-align: top;
    width: 48%;
    min-width: 320px;
    margin: 1%;
    box-sizing: border-box;
}

/* Form group styles consolidated below with settings section */

button {
    padding: var(--space-md) var(--space-lg);
    border: none;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    color: white;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

button:hover {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
} 

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2.5em;
    cursor: pointer;
    color: #aaa;
    line-height: 1;
}

.modal-body .form-group {
    margin-bottom: 15px;
}

.modal-body label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.modal-body input,
.modal-body select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white; /* Ensure select has a background */
    font-size: 1em; /* Consistent font size */
}

.modal-body button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    font-size: 1.1em;
    cursor: pointer;
} 

#chartFilterControls{display:inline-flex;border:1px solid var(--border);border-radius:999px;overflow:hidden;background:#fff}
#chartFilterControls .filter-btn{padding:6px 12px;font-size:.85em;border:none;background:transparent;color:var(--text-600);cursor:pointer}
#chartFilterControls .filter-btn.active{background:var(--brand-600);color:#fff}

#toggleLabelsBtn{padding:6px 12px;font-size:.75em !important;border:1px solid var(--border);background:#fff;color:var(--text-700);border-radius:999px;cursor:pointer}
/* Save Status Styles */
.save-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-status {
    font-size: 0.9em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-height: 20px;
    display: flex;
    align-items: center;
}

.save-status.saving {
    color: #007bff;
    background-color: #e2efff;
}

.save-status.success {
    color: #28a745;
    background-color: #e8f5e8;
}

.save-status.error {
    color: #dc3545;
    background-color: #ffe2e2;
}

.nav-brand a {
    text-decoration: none;
    font-weight: bold;
    color: #333;
    font-size: 1.5em;
    margin-right: 2rem;
}

.mb-4 { margin-bottom: 1.5rem; }

/* Modern Authentication */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--space-lg) 8px; /* Match our consistent 8px horizontal padding */
    position: relative;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="a" cx=".5" cy=".5" r=".5"><stop offset="0%" stop-color="%23667eea" stop-opacity=".1"/><stop offset="100%" stop-color="%23764ba2" stop-opacity=".05"/></radialGradient></defs><rect width="100%" height="100%" fill="url(%23a)"/></svg>');
    pointer-events: none;
}

.auth-card {
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-2xl) var(--space-lg); /* Reduce horizontal padding for consistency */
    width: 100%;
    max-width: 600px; /* Increased from 480px for better width utilization */
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-600), var(--brand-700));
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
}

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

.auth-header h1 {
    color: var(--gray-800);
    margin-bottom: var(--space-md);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--gray-600);
    font-size: 1rem;
    line-height: 1.6;
    font-weight: 500;
}

.auth-form {
    margin-bottom: 2rem;
}

.auth-footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.text-muted {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.link-muted {
    color: #007bff;
    text-decoration: none;
    font-size: 0.9rem;
}

.link-muted:hover {
    text-decoration: underline;
}

.btn-full {
    width: 100%;
}

/* Demo Controls (for wireframe testing) */
.demo-controls {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 2px dashed #dee2e6;
}

.demo-controls h4 {
    margin-bottom: 0.5rem;
    color: #495057;
}

.demo-controls p {
    margin-bottom: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
}

.demo-controls .btn {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Modern Settings Container - Fixed width to prevent snapping */
.settings-container {
    max-width: 800px; /* Consistent fixed width */
    width: 100%;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    max-height: calc(100vh - 140px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center all children horizontally */
}

.settings-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-600), var(--brand-700));
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    z-index: 1;
}

.settings-container h1 {
    font-size: 2.25rem; /* Reduced from 3rem */
    font-weight: 700; /* Reduced from 800 */
    color: var(--gray-800);
    margin-bottom: var(--space-md);
    letter-spacing: -0.025em; /* Less aggressive */
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center; /* Center heading */
    width: 100%; /* Take full width */
}

.settings-container .subtitle {
    color: #718096;
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    text-align: center; /* Center subtitle */
    width: 100%; /* Take full width */
}

/* Modern Tab Navigation */
.settings-tabs {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: var(--space-2xl);
    display: flex;
    gap: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    padding: var(--space-xs);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    width: 100%; /* Take full width */
    justify-content: center; /* Center tabs */
}

/* Remove sticky positioning to fix floating tabs */

.settings-tabs .tab {
    padding: var(--space-lg) var(--space-xl);
    background: rgba(255, 255, 255, 0.3);
    border: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
    cursor: pointer;
    border-radius: var(--border-radius-lg);
    transition: all 0.3s ease;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    min-height: 44px;
}

.settings-tabs .tab:hover {
    color: var(--brand-600);
    background: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
}

.settings-tabs .tab.active {
    color: white;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Tab Content - Fixed width to prevent snapping */
.tab-content {
    display: none;
    width: 100%;
    box-sizing: border-box;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease-in;
}

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

/* Modern Settings Sections */
.settings-section {
    background: var(--surface-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%; /* Constrain section width */
    box-sizing: border-box;
}

.settings-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-400), var(--brand-500), var(--brand-600));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.settings-section:hover::before {
    opacity: 1;
}

.settings-section:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.settings-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.settings-section h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: inherit;
    font-weight: 500;
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), var(--shadow-lg);
    transform: translateY(-2px);
}

.form-group input:disabled,
.form-group textarea:disabled {
    background-color: #f7fafc;
    color: #718096;
    cursor: not-allowed;
    border-color: #e2e8f0;
}

.form-group small {
    display: block;
    color: #718096;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.form-value {
    display: inline-block;
    padding: 0.5rem 0;
    color: #4a5568;
    font-weight: 500;
}

/* Modern Buttons */
.btn {
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--border-radius-lg);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: block; /* Change to block for centering */
    text-align: center; /* Center the text */
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    width: 70%; /* 70% of container width */
    max-width: 210px; /* 70% of previous 300px max-width */
    margin: 0 auto; /* Center the button itself */
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

.btn-secondary {
    background-color: var(--brand-600);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--brand-700);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background-color: #c53030;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: inline-block; /* Allow buttons to size to their text content */
    width: auto; /* Allow buttons to size to their text content */
    min-width: auto; /* Remove any minimum width constraints */
}

/* Icon-only buttons (for prev/next navigation) */
.btn-icon {
    padding: var(--space-sm) var(--space-md);
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
}

.btn-icon:hover {
    background-color: var(--gray-200);
    color: var(--gray-900);
    transform: translateY(-1px);
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-icon:disabled:hover {
    background-color: var(--gray-100);
    transform: none;
}

/* Navigation buttons - consistent styling */
.nav-btn {
    padding: var(--space-sm) var(--space-md);
    min-width: 40px;
    background-color: var(--gray-100);
    color: var(--gray-700);
    border: none;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
    background-color: var(--gray-200);
    color: var(--gray-900);
    transform: translateY(-1px);
}

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

/* Organization Membership Info */
.membership-info {
    background-color: #f7fafc;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    font-weight: 600;
    color: #4a5568;
}

.info-row .value {
    color: #2d3748;
    font-weight: 500;
}

/* Enhanced Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-admin {
    background-color: #fed7d7;
    color: #c53030;
}

.badge-member {
    background-color: #bee3f8;
    color: #2b6cb0;
}

.badge-pending {
    background-color: #faf089;
    color: #744210;
}

/* Multi-org Section */
.org-list {
    margin-top: 1rem;
}

.org-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.org-item.current {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

.org-switch {
    color: #007bff;
    text-decoration: none;
}

.org-switch:hover {
    text-decoration: underline;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
}

/* Areas Management */
.areas-list {
    margin-bottom: 1.5rem;
}

.area-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
}

.area-name {
    font-weight: 500;
}

.area-actions {
    display: flex;
    gap: 0.5rem;
}

/* Team Management */
.invite-form {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 6px;
    margin-bottom: 2rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 100px;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Enhanced Role Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 9999px;
    line-height: 1;
}

.badge-admin {
    background-color: #dc2626;
    color: white;
}

.badge-member {
    background-color: #059669;
    color: white;
}

.badge-viewer {
    background-color: #7c3aed;
    color: white;
}

/* Action Button Enhancements */
.action-buttons .btn {
    transition: all 0.2s ease;
    border-radius: 6px;
}

.action-buttons .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-buttons .btn:active {
    transform: translateY(0);
}

/* Loading States */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Notification Styles */
.notification {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Table Row Hover Effects */
.table-row {
    transition: all 0.2s ease;
}

.table-row:hover {
    background-color: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    animation: spin 1s linear infinite;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Invite Form Grid - NUCLEAR OPTION */
.invite-form-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.invite-form-grid .form-group {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 0 !important;
}

.invite-form-grid .form-group input,
.invite-form-grid .form-group select {
    width: 100% !important;
    height: 48px !important;
    font-size: 16px !important;
    padding: 0.875rem 1rem !important;
    box-sizing: border-box !important;
}

.invite-form-grid button,
.invite-form-grid .btn {
    width: 100% !important;
    height: 44px !important;
    padding: 0.75rem !important;
    font-size: 0.95rem !important;
    box-sizing: border-box !important;
}

/* Desktop: switch to 3-column grid */
@media (min-width: 769px) {
    .invite-form-grid {
        display: grid !important;
        grid-template-columns: 2fr 1fr auto !important;
        gap: 1rem !important;
        align-items: end !important;
    }
    
    .invite-form-grid .form-group {
        width: auto !important;
        max-width: none !important;
    }
    
    .invite-form-grid .form-group input,
    .invite-form-grid .form-group select {
        width: 100% !important;
        height: auto !important;
    }
    
    .invite-form-grid button,
    .invite-form-grid .btn {
        width: auto !important;
        height: auto !important;
    }
}

/* Mobile: Stack invite form vertically - Moved to main mobile media query below to avoid conflicts */

/* Enhanced Team Table */
.team-section {
    margin-top: 2rem;
    overflow-x: auto; /* Allow horizontal scroll if needed */
    width: 100%;
    box-sizing: border-box;
}

.team-table {
    width: 100%;
    min-width: 600px; /* Minimum width for readability */
    max-width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    table-layout: fixed; /* Prevent table from expanding container */
}

.table-header {
    background-color: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

.table-header th,
.table-row td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

/* Define fixed column widths for consistent layout */
.team-table th:nth-child(1),
.team-table td:nth-child(1) {
    width: 30%; /* Name column */
}

.team-table th:nth-child(2),
.team-table td:nth-child(2) {
    width: 35%; /* Email column */
}

.team-table th:nth-child(3),
.team-table td:nth-child(3) {
    width: 15%; /* Role column */
}

.team-table th:nth-child(4),
.team-table td:nth-child(4) {
    width: 20%; /* Actions column */
    text-align: center;
}

.table-row:hover {
    background-color: #f7fafc;
}

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

/* Pending Invitations Styling */
.pending-invitations {
    background-color: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.pending-invitations h4 {
    color: #92400e;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pending-invitations h4::before {
    content: "⏳";
    font-size: 1.2em;
}

.pending-invite-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: white;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid #fbbf24;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pending-invite-item:last-child {
    margin-bottom: 0;
}

.pending-invite-email {
    font-weight: 500;
    color: #374151;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    flex: 1;
    min-width: 0;
}

.pending-invite-actions {
    display: flex;
    gap: 0.5rem;
}

/* Responsive Design */
/* Modern Loading States */
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

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

.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
}

.floating {
    animation: float 3s ease-in-out infinite;
}

.pulsing {
    animation: pulse 2s ease-in-out infinite;
}

/* Enhanced Scrollbars - Desktop Only */
@media (hover: hover) and (pointer: fine) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
        border-radius: 4px;
        transition: all 0.3s ease;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    }
}

/* Hide scrollbars on mobile for cleaner look */
@media (hover: none) and (pointer: coarse) {
    ::-webkit-scrollbar {
        display: none;
    }
    
    * {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Selection Styling */
::selection {
    background: var(--brand-500);
    color: white;
}

::-moz-selection {
    background: var(--brand-500);
    color: white;
}

/* Focus Indicators */
*:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}

/* Mobile-First Responsive Design */
@media (max-width: 768px) {
    body {
        background: linear-gradient(135deg, #dc2626 0%, #ea580c 50%, #2563eb 100%);
    }
    
    /* Professional header on tablet */
    .page-header {
        padding: var(--space-sm) 0;
        margin-bottom: var(--space-sm);
        text-align: left; /* Professional left alignment */
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .page-header h1 {
        font-size: 1.375rem; /* Between desktop and mobile */
        margin-bottom: 0;
        font-weight: 600;
    }
    
    .page-subtitle {
        font-size: 0.8125rem; /* Between desktop and mobile */
        color: rgba(255, 255, 255, 0.7);
    }
    
    /* Hide top navigation on mobile - we'll use bottom nav */
    nav {
        display: none;
    }
    
    /* Mobile bottom navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface-primary);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding: var(--space-sm) 0;
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-bottom-nav .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: var(--space-sm);
        text-decoration: none;
        color: var(--gray-600);
        font-size: 0.75rem;
        font-weight: 600;
        transition: all 0.3s ease;
        min-height: 44px;
        justify-content: center;
    }
    
    .mobile-bottom-nav .nav-item.active {
        color: var(--brand-600);
        background: var(--brand-50);
        border-radius: var(--border-radius-lg);
        margin: 0 var(--space-xs);
    }
    
    .mobile-bottom-nav .nav-item .nav-icon {
        font-size: 1.2rem;
        margin-bottom: var(--space-xs);
    }
    
    /* Mobile app container - simplified positioning */
    #app {
        padding: 16px 16px 90px 16px; /* 16px sides, 90px bottom for nav (40px spacing handled by container) */
        overflow-x: hidden;
        margin-top: 0; /* Reset any top margin */
        padding-top: 16px; /* Simple 16px top padding */
    }
    
    /* Mobile container positioning - reduced top gap by 20% */
    .container {
        margin-top: 85px; /* 72px navbar + 13px gap (reduced from 16px by ~20%) */
        padding: 16px 8px 40px 8px; /* Match 8px left/right pattern, 16px top, 40px bottom */
    }
    
    /* Settings container - align with data hub but preserve desktop styling */
    .settings-container {
        margin: 0 !important; /* Remove all margins on mobile for maximum vertical space */
        padding: 12px 8px 20px 8px; /* Reduced bottom padding from 50px to 20px */
        box-sizing: border-box !important;
        width: 100% !important;            /* Fill inner width within #app padding */
        max-width: 100% !important;
        overflow-y: auto;                   /* Enable vertical scrolling */
        overflow-x: hidden;                 /* Prevent horizontal overflow */
        -webkit-overflow-scrolling: touch;  /* Smooth scrolling on iOS */
        /* Preserve desktop border and styling */
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: var(--border-radius-xl) !important;
        background: var(--surface-primary) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        box-shadow: var(--shadow-xl) !important;
        /* Override desktop centering on mobile */
        display: block !important;
        align-items: stretch !important;
    }
    
    /* Mobile data-hub-container styles handled specifically below */
    
    /* Specific mobile page containers */
    .dashboard-container {
        margin-top: 85px; /* 72px navbar + 13px gap (reduced from 16px by ~20%) */
        padding: 16px 8px 50px 8px; /* Match other containers with 50px bottom space */
        min-height: calc(100vh - 85px - 50px); /* Ensure proper height with bottom space */
    }
    
    /* Mobile page header - professional SaaS compact */
    /* Mobile Page Header - Ultra Compact for Data Focus */
    .page-header {
        padding: var(--space-xs) 0 var(--space-xs) 0; /* Minimal vertical padding */
        margin-bottom: var(--space-xs); /* Reduced margin for more data space */
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        /* Reduce overall header height */
        min-height: 36px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .page-header h1 {
        font-size: 1rem; /* Smaller for more data space */
        margin-bottom: 0;
        font-weight: 600;
        line-height: 1.2;
    }
    
    .page-subtitle {
        font-size: 0.7rem; /* Very compact */
        margin-top: 2px; /* Minimal spacing */
        color: rgba(255, 255, 255, 0.65);
        line-height: 1.3;
    }
    
    /* Professional Mobile Data Layout */
    /* Mobile Data Hub - Optimized Layout Hierarchy */
    .data-hub-container {
        flex-direction: column;
        height: auto;
        max-height: none;
        gap: var(--space-xs); /* Minimal gap - Chart Sets closer to header */
        overflow: visible;
        padding: 12px 12px 50px 12px; /* Bottom padding of 50px for visual space */
        margin-top: 16px !important; /* Small gap below navbar */
        display: flex;
        /* Ensure data workspace gets maximum space with bottom padding */
        min-height: calc(100vh - 85px - 50px); /* Simplified calculation with 50px bottom space */
        background: transparent; /* Remove background that's causing white-out */
        border-radius: 0;
        box-shadow: none;
    }
    
    /* Mobile Chart Sets - Compact Dropdown Design */
    .sidebar {
        width: 100%;
        min-width: auto;
        margin: var(--space-xs) 0 var(--space-xs) 0; /* Small top margin for spacing below navbar */
        padding: var(--space-xs); /* Minimal padding all around */
        background: rgba(255, 255, 255, 0.05); /* Very subtle background */
        border-radius: var(--border-radius-sm);
        border: 1px solid rgba(255, 255, 255, 0.08);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        order: -1;
        overflow: hidden; /* Keep container compact */
        max-height: 44px; /* Strict height limit - keep compact */
        box-sizing: border-box;
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        position: relative; /* For dropdown positioning */
    }
    
    /* Mobile Sidebar Header - Perfect Vertical Alignment */
    .sidebar-header {
        display: flex !important;
        align-items: center !important;
        margin: 0 !important;
        margin-bottom: 0 !important; /* Force bottom margin 0 */
        padding: 0 !important;
        padding-bottom: 0 !important; /* Force bottom padding 0 */
        border: none !important;
        flex-shrink: 0;
        gap: var(--space-xs) !important;
        height: 32px !important; /* Match dropdown height for perfect alignment */
        justify-content: flex-start !important; /* Override any space-between */
    }
    
    .sidebar-header h2 {
        font-size: 0.75rem !important;
        font-weight: 600 !important;
        margin: 0 !important;
        color: rgba(255, 255, 255, 0.8) !important;
        white-space: nowrap !important;
        line-height: 1 !important; /* Ensure perfect vertical centering */
    }
    
    #addDatasetBtn {
        padding: 14px !important; /* 14px padding on all sides */
        width: auto !important; /* Auto width to accommodate padding */
        height: auto !important; /* Auto height to accommodate padding */
        font-size: 0.65rem !important;
        background: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        border-radius: var(--border-radius-sm) !important;
        color: rgba(255, 255, 255, 0.85) !important;
        flex-shrink: 0;
        transition: all 0.2s ease;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer;
        line-height: 1 !important; /* Ensure text centers properly */
    }
    
    #addDatasetBtn:hover {
        background: rgba(255, 255, 255, 0.15);
        color: rgba(255, 255, 255, 0.95);
        transform: scale(1.1);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    /* Mobile Dropdown Selector - Controlled Positioning */
    .dataset-selector-wrapper {
        flex: 1;
        display: block;
        position: relative; /* For absolute positioning of dropdown */
        z-index: 100; /* High z-index to appear above everything */
    }
    
    .dataset-dropdown {
        width: 100%;
        height: 32px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: var(--border-radius-sm);
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.8125rem;
        font-weight: 500;
        padding: 0 var(--space-sm);
        outline: none;
        appearance: none;
        cursor: pointer;
        transition: all 0.2s ease;
        
        /* Custom dropdown arrow */
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='rgba(255,255,255,0.7)' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 8px center;
        background-repeat: no-repeat;
        background-size: 16px;
        padding-right: 32px;
        
        /* Mobile-specific dropdown behavior - Simplified */
        -webkit-appearance: none;
        -moz-appearance: none;
        position: relative;
        z-index: 10;
    }
    
    .dataset-dropdown:focus {
        border-color: var(--chart-primary);
        background: rgba(255, 255, 255, 0.15);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    /* Dropdown Options - Force Downward with Absolute Positioning */
    .dataset-dropdown option {
        background: white !important;
        color: #1f2937 !important;
        padding: 12px 16px !important;
        font-size: 0.875rem !important;
        font-weight: 500 !important;
        border: none !important;
        min-height: 44px !important;
        line-height: 1.4 !important;
    }
    
    .dataset-dropdown option:hover,
    .dataset-dropdown option:focus {
        background: #f3f4f6 !important;
        color: #111827 !important;
    }
    
    .dataset-dropdown option:checked,
    .dataset-dropdown option[selected] {
        background: var(--chart-primary) !important;
        color: white !important;
    }
    
    /* Force dropdown to expand downward on mobile - Last resort */
    @media (max-width: 768px) {
        .dataset-dropdown {
            /* Try forcing with CSS transform */
            transform-origin: top left !important;
        }
        
        /* Alternative: Hide native dropdown and show custom list */
        .dataset-dropdown:focus + .custom-dropdown-list {
            display: block !important;
            position: absolute !important;
            top: 100% !important;
            left: 0 !important;
            right: 0 !important;
            background: white !important;
            border: 1px solid rgba(0, 0, 0, 0.1) !important;
            border-radius: var(--border-radius-sm) !important;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
            z-index: 1000 !important;
            max-height: 200px !important;
            overflow-y: auto !important;
        }
    }
    
    /* Hide desktop list on mobile */
    .dataset-list-desktop {
        display: none;
    }
    
    .dataset-item {
        font-size: 0.85rem;
        padding: var(--space-sm);
        margin-bottom: var(--space-xs);
        width: 100%;
        display: block;
    }
    
    /* Series list mobile styling removed */
    
    /* Sidebar header spacing handled by main mobile rule above */
    
    .sidebar-header h2 {
        font-size: 1.1rem;
    }
    
    #addDatasetBtn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    /* Mobile Dataset Pills - Compact Horizontal Design */
    .dataset-item {
        font-size: 0.8125rem; /* Compact text for pills */
        padding: var(--space-xs) var(--space-sm); /* Minimal pill padding */
        min-height: 32px; /* Compact height for horizontal layout */
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--border-radius-full); /* Full pill shape */
        transition: all 0.2s ease;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        margin: 0; /* No margins in horizontal layout */
        white-space: nowrap; /* Prevent text wrapping */
        flex-shrink: 0; /* Don't shrink pills */
        min-width: fit-content;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.85);
    }
    
    .dataset-item:hover,
    .dataset-item:active {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.25);
        transform: scale(1.02);
        color: rgba(255, 255, 255, 0.95);
    }
    
    .dataset-item.active {
        background: var(--chart-primary);
        color: white;
        border-color: var(--chart-primary);
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        transform: scale(1.05);
    }
    
    /* Professional Mobile Data Workspace */
    .main-content {
        padding: 0; /* Remove padding for full-width content */
        flex: 1;
        overflow-y: auto; /* Enable vertical scrolling */
        -webkit-overflow-scrolling: touch;
        min-height: 50vh; /* Reduced to allow more scrolling space */
        background: rgba(255, 255, 255, 0.08);
        border-radius: var(--border-radius-lg);
        border: 1px solid rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        margin: 0 0 var(--space-md) 0; /* Remove side margins */
        box-sizing: border-box; /* Ensure proper sizing */
    }
    
    /* Mobile Spreadsheet - Touch Optimized */
    /* Mobile Spreadsheet - Clean Data-First Design */
    .spreadsheet-container {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: 100%;
        min-height: 55vh; /* Increased space due to compressed Chart Sets */
        padding: 0; /* Remove padding to prevent overflow */
        
        /* Clean, data-focused styling - override desktop glassmorphism */
        background: rgba(255, 255, 255, 0.95) !important; /* Clean white background */
        backdrop-filter: none !important; /* Remove glassmorphism for clarity */
        -webkit-backdrop-filter: none !important;
        border: 1px solid rgba(0, 0, 0, 0.1) !important; /* Subtle functional border */
        border-radius: var(--border-radius-sm); /* Minimal rounding */
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important; /* Subtle functional shadow */
        
        /* Optimize for data workflow */
        color: var(--gray-900);
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    }
    
    /* Mobile Table - Clean Data-First Design */
    table {
        min-width: 100%;
        font-size: 0.875rem;
        background: white !important; /* Clean white table background */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: var(--border-radius-sm);
        overflow: hidden;
    }
    
    table th,
    table td {
        padding: var(--space-sm);
        min-width: 80px;
        white-space: nowrap;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05); /* Clean subtle borders */
        color: var(--gray-900); /* High contrast text */
    }
    
    /* Touch-friendly input fields - Clean styling */
    table input[type="text"],
    table input[type="number"],
    table input[type="date"] {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: var(--space-xs) var(--space-sm);
        min-height: 44px;
        border: 1px solid rgba(0, 0, 0, 0.15);
        border-radius: var(--border-radius-sm);
        background: white;
        color: var(--gray-900);
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    
    table input:focus {
        outline: none;
        border-color: var(--chart-primary);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    /* Clean mobile table headers */
    table th {
        background: rgba(0, 0, 0, 0.03) !important; /* Very subtle gray */
        font-weight: 600;
        font-size: 0.8125rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        color: var(--gray-700);
        border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    }
    
    th, td {
        padding: var(--space-md);
        font-size: 0.875rem;
        white-space: nowrap;
    }
    
    /* Mobile form controls */
    .spreadsheet-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: stretch;
    }
    
    .filter-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .filter-btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }
    
    /* Hide desktop controls on mobile */
    .desktop-controls {
        display: none;
    }
    
    /* Mobile Compact Control Bar */
    .mobile-control-bar {
        display: flex !important;
        background: var(--surface-primary);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: var(--border-radius-lg);
        padding: var(--space-xs) var(--space-xs); /* Reduced horizontal padding */
        margin: 0; /* 0 margin top and bottom as requested */
        box-shadow: var(--shadow-lg);
        position: relative;
        z-index: 10;
        gap: 2px; /* Small gap between items to prevent overlap */
    }
    
    .control-bar-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--space-xs) var(--space-xs); /* Reduced padding */
        border-radius: var(--border-radius-md);
        cursor: pointer;
        transition: all 0.2s ease;
        min-height: 44px; /* Touch target */
        gap: 2px; /* Reduced gap */
        min-width: 0; /* Allow shrinking */
    }
    
    .control-bar-item:hover {
        background: var(--brand-50);
        color: var(--brand-600);
    }
    
    .control-bar-item.active {
        background: var(--brand-100);
        color: var(--brand-700);
    }
    
    .control-icon {
        font-size: 1.1rem;
        flex-shrink: 0;
    }
    
    .control-label {
        font-size: 0.7rem; /* Smaller font */
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60px; /* Reduced max width */
        flex-shrink: 1; /* Allow shrinking */
    }
    
    .control-arrow {
        font-size: 0.7rem;
        opacity: 0.7;
        flex-shrink: 0;
    }
    
    /* Settings item (no label/arrow) */
    .control-bar-item[data-overlay="settings"] .control-label,
    .control-bar-item[data-overlay="settings"] .control-arrow {
        display: none;
    }
    
    /* Mobile Overlays - Removed stacking context to fix z-index issues */
    
    .control-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--surface-primary);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
        box-shadow: var(--shadow-xl);
        transform: translateY(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 9999; /* Very high z-index to be above all stacking contexts */
        max-height: 50vh;
        overflow-y: auto;
        pointer-events: none; /* Prevent interaction when hidden */
        visibility: hidden; /* Hide completely when not active */
    }
    
    .control-overlay.active {
        transform: translateY(0);
        pointer-events: auto; /* Re-enable interaction when active */
        visibility: visible; /* Show when active */
    }
    
    .overlay-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-lg);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .overlay-header h3 {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--text-900);
    }
    
    .overlay-close {
        background: none;
        border: none;
        font-size: 1.2rem;
        cursor: pointer;
        padding: var(--space-xs);
        border-radius: var(--border-radius-full);
        color: var(--gray-600);
        transition: all 0.2s ease;
        min-height: 44px;
        min-width: 44px;
    }
    
    .overlay-close:hover {
        background: var(--gray-100);
        color: var(--gray-900);
    }
    
    .overlay-content {
        padding: var(--space-md) var(--space-lg) var(--space-md) var(--space-lg); /* Reduced bottom padding to match container */
    }
    
    .overlay-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 9998; /* High z-index but lower than overlay */
    }
    
    .overlay-backdrop.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile overlay controls */
    #mobileDatasetSelector {
        width: 100%;
        padding: var(--space-sm) var(--space-md); /* Reduced vertical padding */
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: var(--border-radius-md);
        background: var(--surface-secondary);
        color: var(--text-900);
        font-size: 0.9rem; /* Slightly smaller font */
        min-height: 44px;
        -webkit-appearance: none; /* Remove default styling */
        appearance: none;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 0.5rem center;
        background-repeat: no-repeat;
        background-size: 1.5em 1.5em;
        padding-right: 2.5rem;
    }
    
    #mobileTimeFilters {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-sm);
    }
    
    #mobileTimeFilters .filter-btn {
        min-height: 44px;
        font-size: 0.9rem;
        border-radius: var(--border-radius-md);
    }
    
    #mobileChartList {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
    }
    
    #mobileChartList .chart-list-item {
        padding: var(--space-sm) var(--space-md); /* Reduced vertical padding */
        border-radius: var(--border-radius-md);
        background: var(--surface-secondary);
        border: 1px solid rgba(255, 255, 255, 0.1);
        cursor: pointer;
        transition: all 0.2s ease;
        min-height: 44px;
        display: flex;
        align-items: center;
        font-size: 0.85rem; /* Slightly smaller font */
    }
    
    #mobileChartList .chart-list-item:hover,
    #mobileChartList .chart-list-item.active {
        background: var(--brand-100);
        color: var(--brand-700);
        border-color: var(--brand-200);
    }
    
    .overlay-btn {
        width: 100%;
        padding: var(--space-md);
        margin-bottom: var(--space-sm);
        background: var(--surface-secondary);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: var(--border-radius-md);
        color: var(--text-900);
        font-size: 0.9rem;
        cursor: pointer;
        transition: all 0.2s ease;
        min-height: 44px;
    }
    
    .overlay-btn:hover {
        background: var(--brand-100);
        color: var(--brand-700);
        border-color: var(--brand-200);
    }
    
    /* Chart navigation removed - using compact control bar instead */
    
    /* Extra small screens - even more compact */
    @media (max-width: 380px) {
        .control-label {
            font-size: 0.65rem;
            max-width: 50px;
        }
        
        .control-icon {
            font-size: 1rem;
        }
        
        .mobile-control-bar {
            padding: 2px;
        }
        
        .control-bar-item {
            padding: var(--space-xs) 2px;
            gap: 1px;
        }
        
        .control-arrow {
            display: none; /* Hide arrows on very small screens */
        }
    }
    
    .control-group {
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-sm);
        align-items: center;
    }
    
    .control-group label {
        font-size: 0.8rem;
    }
    
    .control-group select {
        font-size: 0.8rem;
        padding: var(--space-xs) var(--space-sm);
    }
    
    .control-group button {
        font-size: 0.8rem;
        padding: var(--space-xs) var(--space-sm);
        min-height: 36px; /* Slightly larger for better touch targets */
        min-width: 36px;
    }
    
    /* Ensure form inputs are touch-friendly on mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: var(--space-md);
    }
    
    /* Mobile button sizing for better touch targets */
    .btn {
        min-height: 44px; /* Apple's recommended touch target size */
        padding: var(--space-md) var(--space-lg);
    }
    
    .btn-sm {
        min-height: 36px;
        padding: var(--space-sm) var(--space-md);
    }
    
    #chartFilterControls {
        display: flex !important; /* Ensure filters show */
    }
    
    .chart-list {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-xs);
        width: 100%;
    }
    
    .chart-list-item {
        font-size: 0.7rem;
        padding: 2px 6px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--border-radius-sm);
        min-width: 45px;
    }
    
    /* Mobile settings - removed duplicate rule, handled above */
    
    .settings-container h1 {
        font-size: 1.75rem;
        text-align: left !important; /* Left-align on mobile */
    }
    
    .settings-container .subtitle {
        text-align: left !important; /* Left-align on mobile */
    }
    
    .settings-tabs {
        flex-direction: row;
        background: rgba(255, 255, 255, 0.2);
        border-radius: var(--border-radius-lg);
        position: relative;
        top: auto;
        z-index: auto;
        margin-bottom: var(--space-lg);
        overflow-x: auto; /* Allow horizontal scrolling if needed */
        -webkit-overflow-scrolling: touch;
    }
    
    .settings-tabs .tab {
        flex: 1; /* Equal width tabs */
        text-align: center;
        border-radius: 0;
        border-right: 1px solid rgba(255, 255, 255, 0.2);
        padding: var(--space-md) var(--space-sm);
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        white-space: nowrap;
        min-width: fit-content;
        background: rgba(255, 255, 255, 0.2);
        color: var(--gray-700);
    }
    
    .settings-tabs .tab:first-child {
        border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
    }
    
    .settings-tabs .tab:last-child {
        border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
        border-right: none;
    }
    
    .settings-tabs .tab.active {
        background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
        border-left: none;
        color: white;
        font-weight: 700;
    }
    
    /* For very small screens, make tabs even more compact */
    @media (max-width: 400px) {
        .settings-tabs .tab {
            font-size: 0.65rem;
            padding: 6px 8px;
        }
    }
    
    .settings-section {
        padding: var(--space-lg);
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    /* Mobile forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: var(--space-md);
        font-size: 1rem; /* Prevent zoom on iOS */
    }
    
    /* Mobile invite form - simplified approach */
    .invite-form-grid .form-group {
        width: 100%;
        margin-bottom: 0;
    }
    
    .invite-form-grid .form-group input,
    .invite-form-grid .form-group select {
        height: 48px;
        font-size: 16px;
        padding: 0.875rem 1rem;
    }
    
    .invite-form-grid button,
    .invite-form-grid .btn {
        height: 44px;
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    
    /* Pending invitations mobile optimization */
    .pending-invite-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    .pending-invite-email {
        width: 100% !important;
        font-size: 0.9rem !important;
    }
    
    .pending-invite-actions {
        width: 100% !important;
        justify-content: flex-end !important;
    }
    
    .btn {
        padding: var(--space-md) var(--space-lg);
        font-size: 0.95rem;
        min-height: 44px; /* Touch target size */
        width: 70%; /* 70% width on mobile too */
        max-width: 196px; /* 70% of previous 280px max-width */
    }
    
    /* Team Management - Mobile responsive handled by .invite-form-grid class above */
    
    /* Compact team management labels */
    #team-tab .settings-section .form-group label {
        font-size: 0.8rem !important;
        margin-bottom: 0.3rem !important;
    }
    
    /* Mobile Team Table - Responsive Card Layout */
    .team-table {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .team-table thead {
        display: none !important;
    }
    
    .team-table tbody {
        display: block !important;
    }
    
    .team-table tr {
        display: block !important;
        border: 1px solid #e2e8f0 !important;
        margin-bottom: 1rem !important;
        padding: 1rem !important;
        border-radius: 8px !important;
        background: white !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }
    
    .team-table td {
        display: block !important;
        padding: 0.5rem 0 !important;
        border: none !important;
        position: relative !important;
        padding-left: 35% !important;
        font-size: 0.875rem !important;
        white-space: normal !important;
    }
    
    .team-table td:before {
        content: attr(data-label) !important;
        position: absolute !important;
        left: 0 !important;
        width: 30% !important;
        font-weight: 600 !important;
        color: #374151 !important;
        font-size: 0.75rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.05em !important;
    }
    
    .member-name:before { content: "Name" !important; }
    .member-email:before { content: "Email" !important; }
    .member-role:before { content: "Role" !important; }
    .member-actions:before { content: "Actions" !important; }
    
    .action-buttons {
        display: flex !important;
        gap: 0.5rem !important;
        margin-top: 0.5rem !important;
        justify-content: flex-start !important;
    }
    
    .team-table .btn {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
        min-height: 32px !important;
        flex: 1 !important;
        max-width: 120px !important;
    }
    
    /* Adjust team section spacing */
    .team-section {
        margin-top: 1rem !important;
    }
    
    .team-section h4 {
        font-size: 0.9rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Mobile professional empty state */
    .data-empty-state {
        padding: var(--space-xl) var(--space-md);
        margin: 0 var(--space-xs); /* Small side margins on mobile */
    }
    
    .data-empty-state h3 {
        font-size: 1.1875rem; /* Proportional mobile size */
    }
    
    .data-empty-state p {
        font-size: 0.875rem; /* Compact mobile size */
        max-width: 320px; /* Smaller max-width for mobile */
    }
    
    .empty-state-icon {
        transform: scale(1.1); /* Slightly smaller on mobile */
    }
    
    .data-empty-state:hover .empty-state-icon {
        transform: scale(1.15); /* Reduced hover effect on mobile */
    }
    
    /* Mobile chart container */
    .chart-container {
        padding: var(--space-lg);
        margin-top: var(--space-md);
        min-height: 300px; /* Ensure adequate height on mobile */
    }
    
    /* Mobile chart canvas optimizations */
    .chart-container canvas {
        max-height: 350px; /* Prevent charts from being too tall on mobile */
    }
    
    .chart-container:hover {
        box-shadow: var(--shadow-xl); /* Reduce shadow on mobile for performance */
    }
    
    /* Mobile auth card optimization */
    .auth-card {
        max-width: 100%; /* Full width on mobile */
        margin: 0; /* Remove any margin */
        padding: var(--space-xl) var(--space-md); /* Reduce padding on mobile */
    }
    
    .auth-header h1 {
        font-size: 2rem; /* Smaller title on mobile */
    }
}

/* Tablet breakpoint */
@media (max-width: 1024px) and (min-width: 769px) {
    .data-hub-container {
        height: calc(100vh - 160px);
    }
    
    .sidebar {
        width: 220px; /* Proportionally smaller for tablet */
    }
    
    .settings-container {
        max-width: 800px;
        padding: var(--space-xl);
    }
}

/* Touch improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-links a,
    .dataset-item,
    .filter-btn,
    .chart-list-item,
    .settings-tabs .tab {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .dataset-item:hover,
    .nav-links a:hover,
    .settings-section:hover {
        transform: none;
    }
    
    /* Better touch scrolling */
    .sidebar,
    .main-content,
    .settings-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* Formatted value cells */
.formatted-cell {
    text-align: right;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

/* Currency formatting */
.formatted-cell[data-unit="$"] {
    color: var(--success-600);
    font-weight: 600;
}

/* Time formatting */
.formatted-cell[data-unit="hours"],
.formatted-cell[data-unit="minutes"],
.formatted-cell[data-unit="seconds"] {
    color: var(--brand-600);
}

/* Count formatting */
.formatted-cell[data-unit="items"],
.formatted-cell[data-unit="units"],
.formatted-cell[data-unit="pieces"] {
    color: var(--gray-700);
}

/* Percentage formatting */
.formatted-cell[data-unit="%"],
.formatted-cell[data-unit="percent"] {
    color: var(--warning-600);
}

/* Input field formatting */
.series-value-input[data-unit="$"] {
    text-align: right;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

/* Unit categories in dropdown */
optgroup {
    font-weight: 600;
    color: var(--gray-700);
}

optgroup option {
    font-weight: normal;
    color: var(--gray-900);
}

/* Textarea styles now unified with form-group inputs above */

/* ===================================
   MOBILE DATA ENTRY MODAL STYLES
   =================================== */

.mobile-entry-modal {
    z-index: 1100;
}

.mobile-entry-content {
    width: 85vw;
    max-width: 380px;
    max-height: 75vh;
    margin: 12.5vh auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    border: 1px solid #e5e7eb;
}

.mobile-entry-header {
    background: #3b82f6;
    color: white;
    padding: 16px;
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid #dc2626;
}

.mobile-entry-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.mobile-entry-body {
    padding: 0;
    background: white;
    max-height: calc(75vh - 70px);
    overflow-y: auto;
    overflow-x: visible; /* Ensure horizontal content isn't clipped */
}

/* ===================================
   MOBILE DATA ENTRY MODAL STYLES
   =================================== */

/* Date Picker Section */
.date-picker-section {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    overflow: visible;
    position: relative;
}

.date-picker-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 10px;
}

.date-picker-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

.date-nav-btn {
    background: #f8fafc;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #374151;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
}

.date-nav-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
}

.date-nav-btn:active {
    transform: scale(0.95);
}

.date-display-container {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    padding: 0;
    flex: 1;
    max-width: 180px;
    min-width: 140px;
}

.date-display-container:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.date-input {
    border: none;
    background: transparent;
    padding: 12px;
    font-size: 14px;
    color: #374151;
    width: 100%;
    text-align: center;
}

.date-input:focus {
    outline: none;
}

/* Series Input Section */
.series-input-section {
    padding: 16px;
}

.series-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.series-input-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.entry-mode-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 2px;
}

.mode-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.series-input-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.series-input-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    width: 100%;
}

.series-input-item.has-value {
    border-color: #667eea;
    background: #f0f4ff;
}

.series-input-item.invalid {
    border-color: #ef4444;
    background: #fef2f2;
}

.series-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.series-name {
    font-weight: 500;
    color: #374151;
    font-size: 13px;
}

.series-unit {
    font-size: 12px;
    color: #6b7280;
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
}

.series-value-input {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.series-value-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.series-value-input.invalid {
    border-color: #ef4444;
}

.series-value-input.invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.validation-message {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
    display: none;
}

.series-input-item.invalid .validation-message {
    display: block;
}

/* Action Buttons */
.mobile-entry-actions {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
    display: flex;
    gap: 10px;
}

.mobile-entry-actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    transition: all 0.2s ease;
}

.mobile-entry-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-entry-actions .btn-secondary {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.mobile-entry-actions .btn-secondary:hover {
    background: #e2e8f0;
    color: #475569;
}

.mobile-entry-actions .btn-primary {
    background: #3b82f6;
    color: white;
    border: 1px solid #3b82f6;
}

.mobile-entry-actions .btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.mobile-entry-actions .btn-primary:disabled {
    background: #94a3b8;
    border-color: #94a3b8;
}

/* Loading State */
.mobile-entry-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.mobile-entry-loading p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
    .mobile-entry-content {
        width: 95vw;
        height: 85vh;
        max-height: 85vh;
        margin: 7.5vh auto;
        border-radius: 12px;
    }
    
    .mobile-entry-header {
        border-radius: 12px 12px 0 0;
        padding: 16px;
    }
    
    .date-picker-section {
        padding: 16px;
    }
    
    .series-input-section {
        padding: 16px;
    }
    
    .mobile-entry-actions {
        padding: 16px;
    }
    
    .date-picker-controls {
        gap: 8px;
    }
    
    .date-display-container {
        min-width: 140px;
    }
    
    .entry-mode-toggle {
        display: none; /* Hide on very small screens */
    }
}

/* ===================================
   MOBILE DATA MANAGEMENT STYLES
   =================================== */

/* Mobile filter controls */
.mobile-filters {
    flex-wrap: wrap;
    gap: 8px;
}

.mobile-filters span {
    width: 100%;
    font-size: 12px;
    margin-bottom: 4px;
}

.mobile-filters .filter-btn {
    flex: 1;
    min-width: 60px;
    padding: 8px 4px;
    font-size: 11px;
}

/* Mobile add entry button */
.mobile-add-entry-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.mobile-add-entry-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.mobile-add-entry-btn:active {
    transform: translateY(0);
}

/* Mobile data preview */
.mobile-data-preview {
    background: white;
    padding: 16px 20px;
    margin-top: 0;
}

.data-preview-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.data-preview-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.data-preview-header p {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
}

.data-preview-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.data-preview-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
}

.data-preview-item.has-data {
    border-color: #d1fae5;
    background: #ecfdf5;
}

.data-preview-item.no-data {
    border-color: #fee2e2;
    background: #fef2f2;
}

.preview-date {
    font-weight: 500;
    font-size: 14px;
    color: #374151;
    margin-bottom: 4px;
}

.preview-values {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

.preview-value {
    display: inline-block;
    margin-right: 8px;
}

.mobile-hint {
    margin-top: 16px;
    padding: 12px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    text-align: center;
}

.mobile-hint p {
    margin: 0;
    font-size: 12px;
    color: #4338ca;
}

/* Mobile compact layout */
.mobile-data-view {
    padding: 0;
}

.mobile-dataset-header {
    text-align: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.mobile-dataset-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

.mobile-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px; /* Reduced padding to prevent overflow */
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    gap: 8px; /* Reduced gap */
}

.mobile-add-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-add-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.mobile-filters-compact {
    display: flex;
    gap: 4px;
}

.filter-btn {
    background: white;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
}

.filter-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.mobile-series-selector-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
    margin: 0; /* Ensure no margin causing overlap */
}

.selector-label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    flex-shrink: 0;
}

.selector-dropdown {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 200px;
}

.selector-dropdown:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Interactive preview items */
.data-preview-item.clickable {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.data-preview-item.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.data-preview-item.clickable:active {
    transform: translateY(0);
}

.preview-edit-hint {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    margin-top: 8px;
    opacity: 0.7;
    font-style: italic;
}

/* Responsive adjustments for spreadsheet header */
@media (max-width: 768px) {
    .spreadsheet-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .filter-controls {
        order: 2;
    }
    
    .save-controls {
        order: 1;
    }
    
    .spreadsheet-container h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }
}
