/* ============================================
   CSS VARIABLES - LIGHT THEME (DEFAULT)
   ============================================ */
:root {
    /* Backgrounds */
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-secondary: #f8fafc;
    --bg-input: #ffffff;
    --bg-input-secondary: #f8fafc;
    --bg-hover: #f1f5f9;

    /* Text */
    --text-primary: #334155;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-placeholder: #94a3b8;

    /* Borders */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
    --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Scrollbar */
    --scrollbar-track: #e2e8f0;
    --scrollbar-thumb: #94a3b8;
    --scrollbar-thumb-hover: #64748b;

    /* Shift cells - Light mode with gradients and accents */
    --cell-open-bg: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    --cell-open-bg-solid: #dcfce7;
    --cell-open-text: #166534;
    --cell-open-border: #bbf7d0;
    --cell-open-accent: #22c55e;

    --cell-mid-bg: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
    --cell-mid-bg-solid: #fef9c3;
    --cell-mid-text: #854d0e;
    --cell-mid-border: #fef08a;
    --cell-mid-accent: #eab308;

    --cell-close-bg: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    --cell-close-bg-solid: #e0e7ff;
    --cell-close-text: #3730a3;
    --cell-close-border: #c7d2fe;
    --cell-close-accent: #6366f1;

    --cell-off-bg: #f8fafc;
    --cell-off-text: #94a3b8;
    --cell-off-accent: #cbd5e1;

    --cell-pto-bg: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    --cell-pto-bg-solid: #fce7f3;
    --cell-pto-text: #9d174d;
    --cell-pto-border: #fbcfe8;
    --cell-pto-accent: #ec4899;

    --cell-auto-bg: #ffffff;
    --cell-auto-text: #cbd5e1;
    --cell-auto-stripe: #f8fafc;

    /* Interactive */
    --focus-ring: rgba(59, 130, 246, 0.5);
    --tap-highlight: rgba(59, 130, 246, 0.15);

    /* Status colors */
    --status-saving: #f59e0b;
    --status-saved: #10b981;
    --status-error: #dc2626;

    /* Brand colors */
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-primary-light: #dbeafe;
    --brand-secondary: #4f46e5;
    --brand-accent: #14b8a6;
    --brand-accent-hover: #0d9488;
    --brand-accent-light: #ccfbf1;
    --brand-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);

    /* Context menu */
    --context-menu-bg: #ffffff;
    --context-menu-hover: #f1f5f9;
    --context-menu-text: #334155;
    --context-menu-destructive: #dc2626;

    /* Modal */
    --modal-backdrop: rgba(0, 0, 0, 0.5);
    --modal-bg: #ffffff;

    /* Gradients */
    --gradient-header: linear-gradient(to right, #1e293b, #334155);
    --gradient-stats: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --gradient-budget: linear-gradient(to right, #ecfdf5, #d1fae5);
}

/* ============================================
   CSS VARIABLES - DARK THEME
   ============================================ */
[data-theme="dark"] {
    /* Backgrounds */
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-card-secondary: #334155;
    --bg-input: #1e293b;
    --bg-input-secondary: #334155;
    --bg-hover: #334155;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-placeholder: #64748b;

    /* Borders */
    --border-color: #475569;
    --border-hover: #64748b;

    /* Shadows - darker in dark mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.6);

    /* Scrollbar */
    --scrollbar-track: #334155;
    --scrollbar-thumb: #64748b;
    --scrollbar-thumb-hover: #94a3b8;

    /* Shift cells - Dark mode with gradients and accents */
    --cell-open-bg: linear-gradient(135deg, #14532d 0%, #166534 100%);
    --cell-open-bg-solid: #14532d;
    --cell-open-text: #86efac;
    --cell-open-border: #166534;
    --cell-open-accent: #22c55e;

    --cell-mid-bg: linear-gradient(135deg, #713f12 0%, #854d0e 100%);
    --cell-mid-bg-solid: #713f12;
    --cell-mid-text: #fde047;
    --cell-mid-border: #854d0e;
    --cell-mid-accent: #eab308;

    --cell-close-bg: linear-gradient(135deg, #312e81 0%, #3730a3 100%);
    --cell-close-bg-solid: #312e81;
    --cell-close-text: #a5b4fc;
    --cell-close-border: #3730a3;
    --cell-close-accent: #818cf8;

    --cell-off-bg: #1e293b;
    --cell-off-text: #64748b;
    --cell-off-accent: #475569;

    --cell-pto-bg: linear-gradient(135deg, #831843 0%, #9d174d 100%);
    --cell-pto-bg-solid: #831843;
    --cell-pto-text: #f9a8d4;
    --cell-pto-border: #9d174d;
    --cell-pto-accent: #ec4899;

    --cell-auto-bg: #1e293b;
    --cell-auto-text: #475569;
    --cell-auto-stripe: #334155;

    /* Interactive */
    --focus-ring: rgba(96, 165, 250, 0.5);
    --tap-highlight: rgba(96, 165, 250, 0.15);

    /* Status colors - slightly brighter for dark mode */
    --status-saving: #fbbf24;
    --status-saved: #34d399;
    --status-error: #f87171;

    /* Brand colors - adjusted for dark mode */
    --brand-primary: #3b82f6;
    --brand-primary-hover: #2563eb;
    --brand-primary-light: #1e3a5f;
    --brand-secondary: #6366f1;
    --brand-accent: #2dd4bf;
    --brand-accent-hover: #14b8a6;
    --brand-accent-light: #134e4a;
    --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);

    /* Context menu */
    --context-menu-bg: #1e293b;
    --context-menu-hover: #334155;
    --context-menu-text: #f1f5f9;
    --context-menu-destructive: #f87171;

    /* Modal */
    --modal-backdrop: rgba(0, 0, 0, 0.7);
    --modal-bg: #1e293b;

    /* Gradients */
    --gradient-header: linear-gradient(to right, #0f172a, #1e293b);
    --gradient-stats: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    --gradient-budget: linear-gradient(to right, #064e3b, #065f46);
}

/* ============================================
   DARK MODE - OVERRIDE TAILWIND CLASSES
   ============================================ */

/* Body and main container */
[data-theme="dark"] body {
    background-color: var(--bg-body) !important;
}

/* Header card */
[data-theme="dark"] header.bg-white,
[data-theme="dark"] .bg-white {
    background-color: var(--bg-card) !important;
}

/* Border colors */
[data-theme="dark"] .border-slate-200,
[data-theme="dark"] .border-slate-100 {
    border-color: var(--border-color) !important;
}

/* Text colors */
[data-theme="dark"] .text-slate-800,
[data-theme="dark"] .text-slate-700 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-slate-600,
[data-theme="dark"] .text-slate-500 {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-slate-400,
[data-theme="dark"] .text-slate-300 {
    color: var(--text-muted) !important;
}

/* Background colors */
[data-theme="dark"] .bg-slate-50,
[data-theme="dark"] .bg-slate-100 {
    background-color: var(--bg-card-secondary) !important;
}

/* Gradient backgrounds */
[data-theme="dark"] .bg-gradient-to-br.from-slate-50,
[data-theme="dark"] .bg-gradient-to-r.from-slate-50 {
    background: var(--gradient-stats) !important;
}

/* Week header gradient */
[data-theme="dark"] .bg-gradient-to-r.from-slate-800 {
    background: var(--gradient-header) !important;
}

/* Budget row gradient */
[data-theme="dark"] .bg-gradient-to-r.from-emerald-50,
[data-theme="dark"] tr.bg-gradient-to-r.from-emerald-50 {
    background: var(--gradient-budget) !important;
}

[data-theme="dark"] .border-emerald-200 {
    border-color: #065f46 !important;
}

[data-theme="dark"] .text-emerald-700 {
    color: #34d399 !important;
}

/* Weekend columns */
[data-theme="dark"] .bg-orange-50\/70 {
    background-color: rgba(251, 146, 60, 0.08) !important;
}

/* Table headers and cells */
[data-theme="dark"] th.bg-slate-50,
[data-theme="dark"] td.bg-slate-50 {
    background-color: var(--bg-card-secondary) !important;
}

/* Sticky columns need explicit background */
[data-theme="dark"] .sticky.left-0.bg-slate-50,
[data-theme="dark"] .sticky.left-0.bg-white {
    background-color: var(--bg-card-secondary) !important;
}

[data-theme="dark"] tr .sticky.left-0 {
    background-color: var(--bg-card) !important;
}

[data-theme="dark"] tr.bg-blue-50\/30 .sticky.left-0,
[data-theme="dark"] tr.bg-blue-50\/30 {
    background-color: rgba(59, 130, 246, 0.08) !important;
}

/* Manager name input area */
[data-theme="dark"] .bg-slate-50.rounded-lg {
    background-color: var(--bg-card-secondary) !important;
}

/* Inputs */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select:not(.schedule-select):not(.schedule-select-mobile) {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] input::placeholder {
    color: var(--text-placeholder) !important;
}

/* Legend section */
[data-theme="dark"] .rounded-xl.shadow-sm.border.border-slate-200 {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Legend cell previews - keep shift colors but adjust borders */
[data-theme="dark"] .cell-OPEN.rounded-lg {
    background-color: var(--cell-open-bg) !important;
    color: var(--cell-open-text) !important;
    border-color: var(--cell-open-border) !important;
}

[data-theme="dark"] .cell-MID.rounded-lg {
    background-color: var(--cell-mid-bg) !important;
    color: var(--cell-mid-text) !important;
    border-color: var(--cell-mid-border) !important;
}

[data-theme="dark"] .cell-CLOSE.rounded-lg {
    background-color: var(--cell-close-bg) !important;
    color: var(--cell-close-text) !important;
    border-color: var(--cell-close-border) !important;
}

[data-theme="dark"] .cell-OFF.rounded-lg {
    background-color: var(--cell-off-bg) !important;
    color: var(--cell-off-text) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .cell-PTO.rounded-lg {
    background-color: var(--cell-pto-bg) !important;
    color: var(--cell-pto-text) !important;
    border-color: var(--cell-pto-border) !important;
}

/* Legend locked cell preview */
[data-theme="dark"] .bg-blue-100 {
    background-color: rgba(59, 130, 246, 0.2) !important;
}

/* Status indicators */
[data-theme="dark"] .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.15) !important;
}

[data-theme="dark"] .text-blue-600 {
    color: #60a5fa !important;
}

[data-theme="dark"] .bg-purple-50 {
    background-color: rgba(147, 51, 234, 0.15) !important;
}

[data-theme="dark"] .text-purple-600 {
    color: #a78bfa !important;
}

/* Version badge */
[data-theme="dark"] .bg-emerald-100 {
    background-color: rgba(16, 185, 129, 0.2) !important;
}

[data-theme="dark"] .text-emerald-700 {
    color: #34d399 !important;
}

/* Grade badge colors */
[data-theme="dark"] .bg-emerald-50 {
    background-color: rgba(16, 185, 129, 0.15) !important;
}

[data-theme="dark"] .text-emerald-600 {
    color: #34d399 !important;
}

[data-theme="dark"] .bg-amber-50 {
    background-color: rgba(251, 191, 36, 0.15) !important;
}

[data-theme="dark"] .text-amber-600 {
    color: #fbbf24 !important;
}

[data-theme="dark"] .bg-orange-50 {
    background-color: rgba(249, 115, 22, 0.15) !important;
}

[data-theme="dark"] .text-orange-600 {
    color: #fb923c !important;
}

[data-theme="dark"] .bg-red-50 {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

[data-theme="dark"] .text-red-600 {
    color: #f87171 !important;
}

/* Buttons - secondary */
[data-theme="dark"] button.text-slate-600:hover,
[data-theme="dark"] button.text-slate-500:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .hover\:bg-slate-100:hover {
    background-color: var(--bg-hover) !important;
}

/* Red/destructive buttons */
[data-theme="dark"] .text-red-600 {
    color: #f87171 !important;
}

[data-theme="dark"] .hover\:bg-red-50:hover {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

/* Green buttons (export) */
[data-theme="dark"] .hover\:text-green-700:hover {
    color: #34d399 !important;
}

[data-theme="dark"] .hover\:bg-green-50:hover {
    background-color: rgba(16, 185, 129, 0.15) !important;
}

/* Warnings panel */
[data-theme="dark"] .bg-amber-50 {
    background-color: rgba(245, 158, 11, 0.15) !important;
}

[data-theme="dark"] .border-amber-200 {
    border-color: rgba(245, 158, 11, 0.3) !important;
}

[data-theme="dark"] .text-amber-800,
[data-theme="dark"] .text-amber-700 {
    color: #fbbf24 !important;
}

[data-theme="dark"] .text-amber-500 {
    color: #f59e0b !important;
}

/* Avatar colors - keep vibrant */
[data-theme="dark"] .bg-blue-500 { background-color: #3b82f6 !important; }
[data-theme="dark"] .bg-emerald-500 { background-color: #10b981 !important; }
[data-theme="dark"] .bg-purple-500 { background-color: #8b5cf6 !important; }
[data-theme="dark"] .bg-amber-500 { background-color: #f59e0b !important; }
[data-theme="dark"] .bg-rose-500 { background-color: #f43f5e !important; }
[data-theme="dark"] .bg-cyan-500 { background-color: #06b6d4 !important; }
[data-theme="dark"] .bg-indigo-500 { background-color: #6366f1 !important; }
[data-theme="dark"] .bg-teal-500 { background-color: #14b8a6 !important; }

/* Row hover */
[data-theme="dark"] tr:hover .sticky.left-0,
[data-theme="dark"] .hover\:bg-slate-50\/50:hover {
    background-color: var(--bg-hover) !important;
}

/* Modals */
[data-theme="dark"] .settings-modal-content {
    background-color: var(--modal-bg) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .settings-modal-content h2,
[data-theme="dark"] .settings-modal-content h3 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .settings-modal-content .text-slate-400 {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .settings-modal-content input {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Learn more modal items */
[data-theme="dark"] .settings-modal-content .bg-slate-50 {
    background-color: var(--bg-card-secondary) !important;
}

/* Context menu */
[data-theme="dark"] .context-menu {
    background-color: var(--context-menu-bg) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .context-menu-item {
    color: var(--context-menu-text) !important;
}

[data-theme="dark"] .context-menu-item:hover {
    background-color: var(--context-menu-hover) !important;
}

[data-theme="dark"] .context-menu-item.destructive {
    color: var(--context-menu-destructive) !important;
}

/* Toast */
[data-theme="dark"] #toast {
    box-shadow: var(--shadow-lg) !important;
}

/* Quick tips section */
[data-theme="dark"] .bg-gradient-to-br.from-slate-50.to-slate-100 {
    background: var(--gradient-stats) !important;
}

/* Table borders */
[data-theme="dark"] table td,
[data-theme="dark"] table th {
    border-color: var(--border-color) !important;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    -webkit-tap-highlight-color: var(--tap-highlight);
}

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   TYPOGRAPHY - MONOSPACE FOR TIMES/BADGES
   ============================================ */
.font-mono-time {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-feature-settings: 'tnum' on;
}

/* Apply monospace to shift time displays */
.schedule-select,
.schedule-select-mobile,
.custom-text-overlay,
.custom-text-overlay-mobile,
#solverGradeBadge,
.stats-value,
.budget-input,
.budget-input-mobile,
.settings-time-input {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ============================================
   STICKY HEADER
   ============================================ */
.sticky-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 50;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    background-color: rgba(255, 255, 255, 0.97);
}

[data-theme="dark"] .sticky-header {
    background-color: rgba(30, 41, 59, 0.95);
}

/* ============================================
   HEADER LOGO & BRANDING
   ============================================ */
.sticky-header img[alt*="icon"] {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    transition: transform 0.2s ease;
}

.sticky-header img[alt*="icon"]:hover {
    transform: scale(1.05);
}

/* Brand accent utilities */
.text-brand-accent {
    color: var(--brand-accent);
}

.bg-brand-accent {
    background-color: var(--brand-accent);
}

.border-brand-accent {
    border-color: var(--brand-accent);
}

/* Generate button uses brand gradient */
#generateBtn {
    background: var(--brand-gradient) !important;
    transition: all 0.2s ease;
}

#generateBtn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

#generateBtn:active {
    transform: translateY(0);
}

/* ============================================
   SCROLLBAR STYLES & SCROLL PERFORMANCE
   ============================================ */
/* GPU acceleration for smooth scrolling */
.table-scroll,
#calendarContainer {
    /* Enable hardware acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;

    /* iOS momentum scrolling */
    -webkit-overflow-scrolling: touch;
    /* Only contain horizontal overscroll, allow vertical scroll to pass through */
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
}

/* Allow horizontal scroll but let vertical scroll pass through to page */
.table-scroll {
    overflow-x: auto;
    overflow-y: visible;
}

.table-scroll::-webkit-scrollbar {
    height: 6px;
}
.table-scroll::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ============================================
   SCHEDULE SELECT DROPDOWN
   ============================================ */
.schedule-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    width: 100%;
    height: 100%;
    min-height: 52px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease, background-color 0.2s ease, background-image 0.2s ease;
    padding: 14px 4px;
    border-radius: 0;

    /* CSS containment for better scroll performance */
    contain: layout style paint;
    content-visibility: auto;
}

.schedule-select:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.schedule-select:hover {
    filter: brightness(0.97);
}

[data-theme="dark"] .schedule-select:hover {
    filter: brightness(1.1);
}

.schedule-select:active {
    filter: brightness(0.94);
}

[data-theme="dark"] .schedule-select:active {
    filter: brightness(1.15);
}

.schedule-select:disabled {
    opacity: 0.9;
    cursor: not-allowed;
    pointer-events: none;
    font-weight: 700;
}

.manual-override {
    box-shadow: inset 0 0 0 3px #2563eb !important;
    font-weight: 800;
}

/* ============================================
   CELL ICONS
   ============================================ */
.cell-icon {
    position: absolute;
    top: 3px;
    font-size: 10px;
    pointer-events: none;
    z-index: 10;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,0.8));
}

[data-theme="dark"] .cell-icon {
    filter: drop-shadow(0 1px 0 rgba(0,0,0,0.5));
}

.lock-icon { right: 4px; }

/* ============================================
   CUSTOM TEXT OVERLAY (double-click to edit)
   ============================================ */
.custom-text-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: inherit;
    color: inherit;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    z-index: 5;
    padding: 4px;
    text-align: center;
    word-break: break-word;
    line-height: 1.2;
}

.custom-text-overlay:hover {
    filter: brightness(0.95);
}

[data-theme="dark"] .custom-text-overlay:hover {
    filter: brightness(1.1);
}

/* Hide the select dropdown arrow when custom text is shown */
.has-custom-text {
    color: transparent !important;
}

.custom-text-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 2px solid #3b82f6;
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    background: var(--bg-input, #fff);
    color: var(--text-primary, #1e293b);
    z-index: 20;
    padding: 4px;
    outline: none;
}

.custom-text-input::placeholder {
    color: var(--text-placeholder, #94a3b8);
    font-weight: 400;
}

/* Mobile custom text styles */
.shift-cell-wrapper-mobile {
    position: relative;
    flex-shrink: 0;
}

.custom-text-overlay-mobile {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: inherit;
    color: inherit;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    z-index: 5;
    border-radius: 0.5rem;
    padding: 0.375rem;
    text-align: center;
}

/* ============================================
   BUDGET INPUT
   ============================================ */
.budget-input {
    min-height: 44px;
    transition: all 0.15s ease;
    background-color: transparent;
    color: inherit;
}

.budget-input:focus {
    background-color: var(--bg-input);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* iOS Safari font fix */
@supports (-webkit-touch-callout: none) {
    .schedule-select,
    .budget-input,
    input[type="text"],
    input[type="date"],
    textarea {
        font-size: 16px;
    }
}

/* ============================================
   SHIFT CELL COLORS - ENHANCED WITH ACCENTS
   ============================================ */
.cell-OPEN {
    background: var(--cell-open-bg-solid);
    background-image: var(--cell-open-bg);
    color: var(--cell-open-text);
    border-left: 3px solid var(--cell-open-accent) !important;
}

.cell-MID {
    background: var(--cell-mid-bg-solid);
    background-image: var(--cell-mid-bg);
    color: var(--cell-mid-text);
    border-left: 3px solid var(--cell-mid-accent) !important;
}

.cell-CLOSE {
    background: var(--cell-close-bg-solid);
    background-image: var(--cell-close-bg);
    color: var(--cell-close-text);
    border-left: 3px solid var(--cell-close-accent) !important;
}

.cell-OFF {
    background-color: var(--cell-off-bg);
    color: var(--cell-off-text);
    border-left: 3px solid var(--cell-off-accent) !important;
}

.cell-PTO {
    background: var(--cell-pto-bg-solid);
    background-image: var(--cell-pto-bg);
    color: var(--cell-pto-text);
    border-left: 3px solid var(--cell-pto-accent) !important;
}

.cell-AUTO {
    background-color: var(--cell-auto-bg);
    color: var(--cell-auto-text);
    border-left: 3px solid transparent !important;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        var(--cell-auto-stripe) 4px,
        var(--cell-auto-stripe) 8px
    );
}

/* ============================================
   ANIMATIONS
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

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

/* Cell fill animation - plays when shift is assigned */
@keyframes cellFillIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    40% {
        opacity: 1;
        transform: scale(1.03);
        filter: brightness(1.15);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1);
    }
}

.cell-OPEN,
.cell-MID,
.cell-CLOSE,
.cell-OFF,
.cell-PTO {
    animation: cellFillIn 0.3s ease-out;
}

/* ============================================
   MICRO-INTERACTIONS - SUCCESS ANIMATIONS
   ============================================ */

/* Generate button success pulse */
@keyframes generateSuccessPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
    }
    25% {
        transform: scale(1.02);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3), 0 8px 12px -1px rgba(16, 185, 129, 0.25);
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.15), 0 10px 15px -1px rgba(16, 185, 129, 0.2);
    }
    75% {
        transform: scale(1.02);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1), 0 8px 12px -1px rgba(16, 185, 129, 0.15);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
    }
}

.generate-success-pulse {
    animation: generateSuccessPulse 0.6s ease-out;
}

/* Generate button success state (temporarily green) */
@keyframes generateSuccessColor {
    0%, 100% {
        background: linear-gradient(to right, #2563eb, #4f46e5);
    }
    30%, 70% {
        background: linear-gradient(to right, #059669, #10b981);
    }
}

.generate-success-flash {
    animation: generateSuccessColor 1s ease-out;
}

/* Cell lock feedback animation */
@keyframes lockBounce {
    0%, 100% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.3);
    }
    50% {
        transform: scale(0.9);
    }
    70% {
        transform: scale(1.15);
    }
}

@keyframes cellLockFlash {
    0% {
        box-shadow: inset 0 0 0 3px #2563eb;
    }
    50% {
        box-shadow: inset 0 0 0 4px #3b82f6, 0 0 12px rgba(59, 130, 246, 0.4);
    }
    100% {
        box-shadow: inset 0 0 0 3px #2563eb;
    }
}

.lock-icon-animate {
    animation: lockBounce 0.4s ease-out;
}

.cell-lock-flash {
    animation: cellLockFlash 0.5s ease-out;
}

/* Unlock animation */
@keyframes unlockFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}

.lock-icon-unlock {
    animation: unlockFade 0.3s ease-out forwards;
}

/* Schedule grade badge celebration */
@keyframes gradeCelebrate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.grade-celebrate {
    animation: gradeCelebrate 0.3s ease-out;
}

/* ============================================
   BUDGET INPUT VALIDATION STATES
   ============================================ */

/* Invalid state - red border with shake */
.budget-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
    animation: budgetShake 0.4s ease;
}

@keyframes budgetShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* Warning state - amber border */
.budget-warning {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2) !important;
}

/* Valid state - brief green flash */
.budget-valid {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
    transition: all 0.3s ease;
}

/* Inline validation messages */
.budget-validation-msg {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 20;
    animation: validationFadeIn 0.2s ease;
}

@keyframes validationFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.budget-validation-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.budget-validation-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

[data-theme="dark"] .budget-validation-error {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
    border-color: rgba(220, 38, 38, 0.3);
}

[data-theme="dark"] .budget-validation-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

/* Ensure table cells can show overflow for validation messages */
td:has(.budget-input) {
    position: relative;
    overflow: visible;
}

/* ============================================
   GRID INTERACTION HINTS
   ============================================ */
.grid-hints {
    transition: opacity 0.2s ease;
}

.grid-hints kbd {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .grid-hints {
    background-color: rgba(51, 65, 85, 0.5) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .grid-hints kbd {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

/* Hide hints on print */
@media print {
    .grid-hints {
        display: none !important;
    }
}

/* ============================================
   CONTEXT MENU
   ============================================ */
.context-menu {
    position: fixed;
    background: var(--context-menu-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    min-width: 180px;
    z-index: 1000;
    border: 1px solid var(--border-color);
    will-change: transform, opacity;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--context-menu-text);
    transition: background 0.15s;
}

.context-menu-item:hover {
    background: var(--context-menu-hover);
}
.context-menu-item.destructive {
    color: var(--context-menu-destructive);
}
.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* ============================================
   MOBILE ACTION SHEET
   ============================================ */
.mobile-action-sheet {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.mobile-action-sheet.hidden {
    display: none;
}

.mobile-action-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(2px);
}

.mobile-action-sheet-content {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: 1rem 1rem 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    animation: actionSheetSlideUp 0.25s ease-out;
}

@keyframes actionSheetSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.mobile-action-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-action-sheet-items {
    padding: 0.5rem 0;
}

.mobile-action-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.mobile-action-item:hover,
.mobile-action-item:active {
    background: var(--bg-hover);
}

.mobile-action-item.destructive {
    color: var(--context-menu-destructive);
}

.mobile-action-item span:first-child {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

/* Mobile action button (three dots) */
.mobile-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: var(--bg-card-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

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

/* ============================================
   UNDO/REDO HEADER BUTTONS
   ============================================ */
#headerUndoBtn,
#headerRedoBtn {
    transition: all 0.15s ease;
}

#headerUndoBtn:not(:disabled):hover,
#headerRedoBtn:not(:disabled):hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

#headerUndoBtn:not(:disabled):active,
#headerRedoBtn:not(:disabled):active {
    transform: scale(0.95);
}

/* Dark mode */
[data-theme="dark"] #headerUndoBtn,
[data-theme="dark"] #headerRedoBtn {
    color: var(--text-secondary);
}

[data-theme="dark"] #headerUndoBtn:not(:disabled):hover,
[data-theme="dark"] #headerRedoBtn:not(:disabled):hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================
   SAVE INDICATOR
   ============================================ */
.save-indicator {
    transition: all 0.3s ease;
}

#toast {
    will-change: transform, opacity;
}

.save-indicator.saving { color: var(--status-saving); }
.save-indicator.saved { color: var(--status-saved); }
.save-indicator.error { color: var(--status-error); }

/* ============================================
   STATS CARD
   ============================================ */
.stats-card {
    background: var(--gradient-stats);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    text-align: center;
}

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

.stats-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================
   SETTINGS MODAL
   ============================================ */
.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.settings-modal.hidden {
    display: none;
}

.settings-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(2px);
}

.settings-modal-content {
    position: relative;
    background: var(--modal-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-modal);
    max-width: 28rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    animation: modalSlideIn 0.2s ease-out;
    border: 1px solid var(--border-color);
}

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

.settings-time-input {
    width: 5rem;
    padding: 0.5rem 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-input-secondary);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.settings-time-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px var(--focus-ring);
    background: var(--bg-input);
}

.settings-time-input::placeholder {
    color: var(--text-placeholder);
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.theme-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Sun icon visible in dark mode, moon in light mode */
.theme-toggle .sun-icon {
    display: none;
}
.theme-toggle .moon-icon {
    display: block;
}

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

/* ============================================
   MOBILE CARD VIEW
   ============================================ */
@media (max-width: 767px) {
    /* Hide table view on mobile */
    .desktop-table-view {
        display: none !important;
    }

    /* Show mobile card view */
    .mobile-card-view {
        display: block !important;
    }

    /* Week card container */
    .week-card-mobile {
        background: var(--bg-card);
        border-radius: 0.75rem;
        border: 1px solid var(--border-color);
        margin-bottom: 1rem;
        overflow: hidden;
    }

    /* Week header */
    .week-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        background: var(--gradient-header);
    }

    .week-header-mobile h3 {
        color: white;
        font-weight: 700;
        font-size: 1rem;
        margin: 0;
    }

    .week-header-mobile span {
        color: #94a3b8;
        font-size: 0.75rem;
        font-weight: 500;
    }

    /* Day carousel container */
    .day-carousel {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Allow vertical page scrolling while still supporting horizontal swipe */
        touch-action: pan-y pinch-zoom;
    }

    .day-carousel::-webkit-scrollbar {
        display: none;
    }

    /* Individual day card */
    .day-card {
        flex: 0 0 100%;
        scroll-snap-align: start;
        padding: 1rem;
        background: var(--bg-card);
        min-height: 200px;
    }

    .day-card.weekend {
        background: linear-gradient(135deg, var(--bg-card) 0%, rgba(251, 146, 60, 0.05) 100%);
    }

    .day-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem;
        border-bottom: 1px solid var(--border-color);
    }

    .day-name {
        font-weight: 700;
        font-size: 1.125rem;
        color: var(--text-primary);
    }

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

    /* Budget section in day card */
    .day-card-budget {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.625rem 0.75rem;
        margin-bottom: 0.75rem;
        background: var(--gradient-budget);
        border-radius: 0.5rem;
    }

    .day-card-budget label {
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        color: #059669;
    }

    [data-theme="dark"] .day-card-budget label {
        color: #34d399;
    }

    .budget-input-mobile {
        width: 5rem;
        padding: 0.375rem 0.5rem;
        text-align: center;
        font-weight: 600;
        font-size: 0.875rem;
        border: 1px solid var(--border-color);
        border-radius: 0.375rem;
        background: var(--bg-input);
        color: var(--text-primary);
    }

    /* Shifts container */
    .day-card-shifts {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Shift row in card */
    .shift-row-mobile {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-color);
    }

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

    .manager-info-mobile {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 1;
        min-width: 0;
    }

    .avatar-mobile {
        width: 2rem;
        height: 2rem;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
        font-weight: 600;
        color: white;
        flex-shrink: 0;
    }

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

    .lock-icon-mobile {
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    /* Shift select in mobile card */
    .schedule-select-mobile {
        min-height: 2.25rem;
        padding: 0.375rem 0.75rem;
        border-radius: 0.5rem;
        font-size: 0.8rem;
        font-weight: 600;
        min-width: 4.5rem;
        text-align: center;
        border: 1px solid var(--border-color);
        background: var(--bg-input);
        color: var(--text-primary);
        cursor: pointer;
        flex-shrink: 0;
    }

    /* Apply shift cell colors to mobile select with accents */
    .schedule-select-mobile.cell-OPEN {
        background: var(--cell-open-bg-solid);
        color: var(--cell-open-text);
        border-color: var(--cell-open-border);
        border-left: 3px solid var(--cell-open-accent);
    }

    .schedule-select-mobile.cell-MID {
        background: var(--cell-mid-bg-solid);
        color: var(--cell-mid-text);
        border-color: var(--cell-mid-border);
        border-left: 3px solid var(--cell-mid-accent);
    }

    .schedule-select-mobile.cell-CLOSE {
        background: var(--cell-close-bg-solid);
        color: var(--cell-close-text);
        border-color: var(--cell-close-border);
        border-left: 3px solid var(--cell-close-accent);
    }

    .schedule-select-mobile.cell-OFF {
        background: var(--cell-off-bg);
        color: var(--cell-off-text);
        border-left: 3px solid var(--cell-off-accent);
    }

    .schedule-select-mobile.cell-PTO {
        background: var(--cell-pto-bg-solid);
        color: var(--cell-pto-text);
        border-color: var(--cell-pto-border);
        border-left: 3px solid var(--cell-pto-accent);
    }

    .schedule-select-mobile.cell-AUTO {
        background: var(--cell-auto-bg);
        color: var(--cell-auto-text);
        border-left: 3px solid transparent;
    }

    .schedule-select-mobile.manual-override {
        box-shadow: inset 0 0 0 2px #3b82f6;
    }

    /* Carousel navigation dots */
    .carousel-dots {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem 0;
        background: var(--bg-card-secondary);
    }

    .carousel-dot {
        width: 0.5rem;
        height: 0.5rem;
        border-radius: 50%;
        background: var(--border-color);
        border: none;
        padding: 0;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .carousel-dot.active {
        background: #3b82f6;
        transform: scale(1.25);
    }

    .carousel-dot:hover {
        background: #64748b;
    }

    .carousel-dot.active:hover {
        background: #2563eb;
    }

    /* Mobile Roster Editor */
    .mobile-roster-section {
        background: var(--bg-card);
        border-radius: 0.75rem;
        border: 1px solid var(--border-color);
        margin-bottom: 1rem;
        overflow: hidden;
    }

    .mobile-roster-toggle {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.875rem 1rem;
        background: var(--bg-card-secondary);
        border: none;
        cursor: pointer;
        color: var(--text-primary);
        font-weight: 600;
        font-size: 0.875rem;
    }

    .mobile-roster-toggle:active {
        background: var(--border-color);
    }

    .mobile-roster-toggle-text {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-roster-toggle-text svg {
        color: var(--text-secondary);
    }

    .mobile-roster-chevron {
        color: var(--text-secondary);
        font-size: 0.875rem;
        transition: transform 0.2s ease;
    }

    .mobile-roster-content {
        padding: 0.75rem;
        border-top: 1px solid var(--border-color);
    }

    .mobile-roster-content.hidden {
        display: none;
    }

    .mobile-roster-row {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.625rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-roster-row:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .mobile-roster-row:first-child {
        padding-top: 0;
    }

    .mobile-roster-inputs {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.375rem;
    }

    .mobile-roster-name-input {
        width: 100%;
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--text-primary);
        background: var(--bg-card);
        outline: none;
    }

    .mobile-roster-name-input:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    }

    .mobile-roster-role-input {
        width: 100%;
        padding: 0.375rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        font-size: 0.75rem;
        color: var(--text-secondary);
        background: var(--bg-card);
        outline: none;
    }

    .mobile-roster-role-input:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    }

    .mobile-roster-name-input::placeholder,
    .mobile-roster-role-input::placeholder {
        color: var(--text-secondary);
        opacity: 0.6;
    }
}

/* Hide mobile view on desktop */
@media (min-width: 768px) {
    .mobile-card-view {
        display: none !important;
    }

    .desktop-table-view {
        display: block !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    @page {
        size: letter portrait;
        margin: 0.2in;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        color: black !important;
    }

    /* Force light mode colors for print */
    :root {
        --bg-body: white !important;
        --bg-card: white !important;
        --text-primary: black !important;
    }

    /* Hide everything except the schedule */
    header,
    #warningsPanel,
    #contextMenu,
    #toast,
    .settings-modal,
    #learnMoreModal,
    #statsContainer,
    footer,
    .theme-toggle,
    .advanced-toggle,
    #advancedControls,
    .mobile-card-view {
        display: none !important;
    }

    /* Hide legend section (contains export buttons) */
    .max-w-\[1400px\] > div:not(#calendarContainer) {
        display: none !important;
    }

    /* Show only the calendar container */
    .max-w-\[1400px\] {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    #calendarContainer {
        display: block !important;
        font-size: 5.5pt !important;
    }

    /* Compact week cards */
    #calendarContainer > div {
        page-break-inside: avoid;
        margin-bottom: 2px !important;
        box-shadow: none !important;
        border: 1px solid #94a3b8 !important;
        border-radius: 3px !important;
    }

    #calendarContainer table {
        min-width: 0 !important;
    }

    #calendarContainer th,
    #calendarContainer td {
        padding: 1px 2px !important;
        border-width: 1px !important;
    }

    #calendarContainer .p-2,
    #calendarContainer .p-3 {
        padding: 1px 2px !important;
    }

    /* Week header - very compact */
    #calendarContainer .bg-gradient-to-r.from-slate-700 {
        padding: 1px 6px !important;
    }

    #calendarContainer .bg-gradient-to-r.from-slate-700 h3 {
        font-size: 6pt !important;
    }

    #calendarContainer .bg-gradient-to-r.from-slate-700 span {
        font-size: 5pt !important;
    }

    /* Manager name column - narrower */
    #calendarContainer th:first-child,
    #calendarContainer td:first-child {
        width: 55px !important;
        min-width: 55px !important;
        max-width: 55px !important;
    }

    /* Compact select dropdowns */
    .schedule-select {
        min-height: 14px !important;
        padding: 0 !important;
        font-size: 5pt !important;
    }

    /* Budget row - compact */
    #calendarContainer .budget-input {
        min-height: 12px !important;
        font-size: 5pt !important;
        padding: 0 !important;
    }

    /* Remove overflow scroll for print */
    .table-scroll {
        overflow: visible !important;
    }

    /* Hide avatars for more space */
    #calendarContainer [data-avatar-id] {
        display: none !important;
    }

    /* Hide role input/display in print */
    #calendarContainer [data-roster-role-display],
    #calendarContainer input[placeholder="e.g., Store Manager"] {
        display: none !important;
    }

    /* Week 1 roster cell - flatten the card style */
    #calendarContainer .bg-slate-50.rounded-lg {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    /* Week 1 roster - remove stacking, single line */
    #calendarContainer .space-y-1 {
        display: block !important;
    }

    #calendarContainer .space-y-1 > * {
        margin: 0 !important;
    }

    /* Name inputs - clean display */
    #calendarContainer input[type="text"] {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        box-shadow: none !important;
        font-size: 5pt !important;
        height: auto !important;
        min-height: 0 !important;
    }

    /* Roster cell - remove gaps */
    #calendarContainer .flex.items-center.gap-2,
    #calendarContainer .flex.items-center.gap-3 {
        gap: 0 !important;
    }

    /* Hide lock icons */
    #calendarContainer .cell-icon {
        display: none !important;
    }

    /* Compact all rows uniformly */
    #calendarContainer tr {
        height: auto !important;
    }

    #calendarContainer td {
        height: auto !important;
        vertical-align: middle !important;
    }
}

/* ============================================
   ROTATE DEVICE OVERLAY
   Shows on mobile portrait, hidden on landscape and desktop
   ============================================ */

.rotate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.rotate-overlay-content {
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 2.5rem 2rem;
    margin: 1rem;
    text-align: center;
    box-shadow: var(--shadow-modal);
    max-width: 320px;
    animation: rotateOverlayFadeIn 0.3s ease-out;
}

@keyframes rotateOverlayFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.rotate-phone-icon {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    animation: rotatePhonePulse 2s ease-in-out infinite;
}

@keyframes rotatePhonePulse {
    0%, 100% {
        transform: rotate(-10deg);
    }
    50% {
        transform: rotate(10deg);
    }
}

.rotate-message {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.rotate-dismiss-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.rotate-dismiss-btn:active {
    transform: scale(0.98);
}

/* Show overlay only on mobile portrait (unless dismissed) */
@media (max-width: 767px) and (orientation: portrait) {
    .rotate-overlay:not(.dismissed) {
        display: flex;
    }
}

/* Always hide on landscape or desktop */
@media (min-width: 768px), (orientation: landscape) {
    .rotate-overlay {
        display: none !important;
    }
}

/* ============================================
   WELCOME MODAL
   ============================================ */

.welcome-modal-content {
    text-align: center;
}

[data-theme="dark"] .welcome-modal-content .from-green-50,
[data-theme="dark"] .welcome-modal-content .from-blue-50,
[data-theme="dark"] .welcome-modal-content .from-purple-50 {
    background: var(--bg-card-secondary) !important;
}

[data-theme="dark"] .welcome-modal-content .border-green-100,
[data-theme="dark"] .welcome-modal-content .border-blue-100,
[data-theme="dark"] .welcome-modal-content .border-purple-100 {
    border-color: var(--border-color) !important;
}

/* ============================================
   FOOTER
   ============================================ */

footer a {
    transition: color 0.15s ease;
}

[data-theme="dark"] footer {
    color: var(--text-muted);
}

[data-theme="dark"] footer a:hover {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] footer .text-slate-300 {
    color: var(--border-color) !important;
}

/* ============================================
   EMPTY STATE
   ============================================ */

[data-theme="dark"] .border-dashed {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .border-dashed .bg-slate-100 {
    background-color: var(--bg-card-secondary) !important;
}

[data-theme="dark"] .border-dashed .bg-slate-50 {
    background-color: var(--bg-card-secondary) !important;
}

/* ============================================
   CONFLICT RESOLUTION & WARNINGS
   ============================================ */

/* Conflict highlight animation */
.conflict-highlight {
    animation: conflictPulse 1.5s ease-in-out infinite !important;
    position: relative;
    z-index: 10;
}

@keyframes conflictPulse {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.4), 0 0 8px rgba(245, 158, 11, 0.3);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.6), 0 0 15px rgba(245, 158, 11, 0.4);
    }
}

/* Warning item container */
.warning-item {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .warning-item {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(245, 158, 11, 0.3);
}

/* Warning header layout */
.warning-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.warning-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-width: 0;
}

.warning-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Show button */
.warning-show-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.warning-show-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-1px);
}

.warning-show-btn:active {
    transform: translateY(0);
}

/* Expand button */
.warning-expand-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.expand-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
}

/* Fixes section */
.warning-fixes {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(245, 158, 11, 0.3);
}

.fix-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.fix-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* Fix button */
.fix-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.fix-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

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

/* Dark mode fix button */
[data-theme="dark"] .fix-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

[data-theme="dark"] .fix-btn:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .warning-header {
        flex-wrap: wrap;
    }

    .warning-message {
        order: 1;
        flex-basis: calc(100% - 2rem);
    }

    .warning-actions {
        order: 2;
        margin-top: 0.375rem;
    }

    .fix-buttons {
        flex-direction: column;
    }

    .fix-btn {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   VIEWPORT-BASED SCALING FOR SCHEDULE TABLE
   Ensures the table always fits the viewport
   ============================================ */

/* Desktop: Scale table to fit viewport width */
@media (min-width: 768px) {
    .schedule-table {
        table-layout: fixed;
        width: 100%;
    }

    /* Manager column - fixed width */
    .schedule-table th:first-child,
    .schedule-table td:first-child {
        width: clamp(100px, 12vw, 160px);
    }

    /* Day columns - equal distribution of remaining space */
    .schedule-table th:not(:first-child),
    .schedule-table td:not(:first-child) {
        width: calc((100% - clamp(100px, 12vw, 160px)) / 7);
    }

    /* Scale font sizes with viewport */
    .schedule-table {
        font-size: clamp(0.7rem, 0.9vw, 0.875rem);
    }

    .schedule-table th {
        padding: clamp(0.375rem, 0.6vw, 0.75rem);
    }

    .schedule-table td {
        padding: clamp(0.25rem, 0.4vw, 0.5rem);
    }

    /* Scale shift select dropdowns */
    .schedule-table .schedule-select {
        font-size: clamp(0.65rem, 0.85vw, 0.8rem);
        padding: clamp(0.25rem, 0.4vw, 0.5rem);
        min-height: clamp(1.75rem, 2.5vw, 2.25rem);
    }

    /* Scale manager name inputs */
    .schedule-table input[type="text"] {
        font-size: clamp(0.7rem, 0.9vw, 0.875rem);
    }

    /* Ensure container doesn't overflow */
    .table-scroll {
        overflow-x: hidden;
        width: 100%;
    }

    #calendarContainer {
        max-width: 100%;
        overflow-x: hidden;
    }
}

/* Ensure body doesn't allow horizontal scroll */
body {
    overflow-x: hidden;
}

.max-w-\[1400px\] {
    max-width: min(1400px, 100vw - 1.5rem);
}

/* ============================================
   HEADER CONTROLS - UNIFORM INPUT SIZING
   ============================================ */
/* Ensure start date and employees inputs have identical heights */
#startDate,
#managerCount {
    height: 3rem !important; /* 48px - same as h-12 */
    min-height: 3rem !important;
    max-height: 3rem !important;
    padding: 0.75rem !important; /* Same padding all around */
    box-sizing: border-box !important;
    line-height: 1.5rem !important;
    /* iOS Safari specific fixes */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0.5rem;
}

/* Enlarge date picker for easier interaction */
#startDate {
    font-size: 1rem !important;
    font-weight: 500;
    min-width: 160px;
    padding: 0.625rem 0.875rem !important;
}

/* Select dropdown arrow for custom appearance */
#managerCount {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem !important;
}

/* iOS Safari specific - use @supports for touch devices */
@supports (-webkit-touch-callout: none) {
    #startDate,
    #managerCount {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        line-height: 48px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Date input needs special handling on iOS */
    #startDate {
        -webkit-appearance: none;
        min-width: 140px;
    }
}

/* Mobile: Ensure consistent sizing on touch devices */
@media (max-width: 768px) {
    #startDate,
    #managerCount {
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
    }
}

/* ============================================
   MOBILE HEADER ROW 2 - Prevent wrapping
   ============================================ */

/* Compact controls on mobile to prevent Row 2 wrapping */
@media (max-width: 767px) {
    /* Reduce input heights on mobile */
    #startDate,
    #managerCount {
        height: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 16px !important; /* Keep 16px to prevent iOS zoom */
    }

    /* Narrower date input on mobile */
    #startDate {
        min-width: 115px !important;
        max-width: 130px !important;
    }

    /* Narrower team dropdown on mobile - remove custom arrow to prevent overlap */
    #managerCount {
        min-width: 50px !important;
        max-width: 65px !important;
        padding-right: 0.5rem !important;
        /* Reset to native dropdown appearance on mobile portrait */
        background-image: none !important;
        -webkit-appearance: menulist !important;
        -moz-appearance: menulist !important;
        appearance: menulist !important;
    }

    /* Smaller action buttons on mobile */
    .sticky-header [onclick*="Modal"],
    .sticky-header [onclick*="export"] {
        padding: 0.375rem 0.5rem !important;
    }

    /* Tighter gaps in Row 2 */
    .sticky-header .border-t {
        gap: 0.375rem !important;
    }

    /* Smaller grade badge */
    #solverGradeBadge {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.65rem !important;
    }
}

/* Extra compact for very small screens (iPhone SE, Galaxy S8+, etc.) */
@media (max-width: 374px) {
    /* Row 1: Allow title container to shrink */
    .sticky-header > div:first-child > div:first-child {
        min-width: 0;
        flex-shrink: 1;
    }

    /* Row 1: Allow title to truncate */
    .sticky-header h1 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1.25rem !important; /* text-xl = 20px */
    }

    /* Prevent button from shrinking */
    .sticky-header #generateBtn {
        flex-shrink: 0;
    }

    #startDate {
        min-width: 100px !important;
        max-width: 110px !important;
    }

    #managerCount {
        min-width: 45px !important;
    }

    /* Even smaller action buttons */
    .sticky-header [onclick*="Modal"],
    .sticky-header [onclick*="export"] {
        padding: 0.25rem 0.375rem !important;
    }

    .sticky-header [onclick*="Modal"] svg,
    .sticky-header [onclick*="export"] svg {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }
}

/* ============================================
   ONBOARDING CAROUSEL
   ============================================ */

.onboarding-content {
    position: relative;
    padding: 1.5rem 1.5rem 1.25rem;
}

.onboarding-carousel {
    position: relative;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-card {
    display: none;
    width: 100%;
    animation: onboardingFadeIn 0.3s ease-out;
}

.onboarding-card.active {
    display: block;
}

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

/* Progress dots */
.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.onboarding-dot:hover {
    background: var(--text-muted);
}

.onboarding-dot.active {
    background: #3b82f6;
    transform: scale(1.25);
}

/* Landscape mobile adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .onboarding-content {
        padding: 1rem 1.5rem 1rem;
    }

    .onboarding-carousel {
        min-height: 120px;
    }

    .onboarding-card .w-20 {
        width: 3.5rem !important;
        height: 3.5rem !important;
    }

    .onboarding-card .h-10 {
        width: 1.5rem !important;
        height: 1.5rem !important;
    }

    .onboarding-card h2 {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem !important;
    }

    .onboarding-card p {
        font-size: 0.875rem !important;
    }

    .onboarding-card .mb-5 {
        margin-bottom: 0.75rem !important;
    }

    /* Reduce dot/button spacing */
    .onboarding-content .mt-6 {
        margin-top: 0.75rem !important;
    }

    .onboarding-content .mb-6 {
        margin-bottom: 0.75rem !important;
    }
}

/* Dark mode support */
[data-theme="dark"] .onboarding-content h2 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .onboarding-content p {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .onboarding-dot {
    background: var(--border-color);
}

[data-theme="dark"] .onboarding-dot:hover {
    background: var(--text-muted);
}

[data-theme="dark"] .onboarding-dot.active {
    background: #60a5fa;
}

/* ============================================
   MOBILE STATUS INDICATORS
   ============================================ */

/* Compact badges on mobile */
@media (max-width: 640px) {
    /* Reduce badge padding on mobile */
    #autoSaveIndicator span,
    #historyInfo span,
    #lockedInfo span,
    #solverInfo span {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.65rem !important;
        gap: 0.25rem !important;
    }

    /* Smaller icons */
    #autoSaveIndicator svg,
    #historyInfo svg {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }
}

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

/* ============================================
   ACCESSIBILITY: Reduced Motion Preferences
   Respects users who have motion sensitivity
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    /* Disable all animations globally */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Specific elements that should appear instantly */
    .fade-in,
    .generate-success,
    .lock-bounce,
    .unlock-fade,
    .budget-invalid,
    .budget-valid,
    .conflict-highlight {
        animation: none !important;
    }

    /* Keep functional visual feedback without motion */
    .budget-invalid {
        border-color: #dc2626 !important;
        box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
    }

    .conflict-highlight {
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.5) !important;
    }

    /* Modals and sheets appear instantly */
    .settings-modal-content,
    .mobile-action-sheet-content,
    .rotate-overlay-content,
    .onboarding-card {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    /* Disable smooth scrolling */
    html,
    .day-carousel {
        scroll-behavior: auto !important;
    }
}

/* ============================================
   MOBILE: Touch Target Improvements (44x44px min)
   ============================================ */
@media (max-width: 767px) {
    /* Header action buttons - expand tap area */
    .sticky-header button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem;
    }

    /* Carousel dots - expand touch area without changing visual */
    .carousel-dot {
        position: relative;
    }

    .carousel-dot::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 44px;
        height: 44px;
    }

    /* Add spacing between dots to prevent overlap */
    .carousel-dots {
        gap: 1.25rem;
        padding: 0.75rem 0;
    }

    /* Mobile shift select - ensure minimum tap target */
    .schedule-select-mobile {
        min-height: 44px;
    }

    /* Mobile roster toggle */
    .mobile-roster-toggle {
        min-height: 48px;
    }

    /* Budget input on mobile cards */
    .budget-input-mobile {
        min-height: 44px;
    }

    /* Date and team count inputs */
    #startDate,
    #managerCount {
        min-height: 44px !important;
    }

    /* Mobile action sheet items */
    .mobile-action-item {
        min-height: 48px;
    }
}

/* ============================================
   MOBILE: Swipe Feedback Indicator
   ============================================ */
.swipe-feedback {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.swipe-feedback.left {
    left: 1rem;
}

.swipe-feedback.right {
    right: 1rem;
}

.swipe-feedback.visible {
    opacity: 1;
}

/* ============================================
   ANIMATED HEADER ICON
   ============================================ */
.header-icon {
    flex-shrink: 0;
}

/* Subtle float animation on idle */
.icon-calendar {
    animation: iconFloat 4s ease-in-out infinite;
}

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

/* Calendar rings have a subtle bounce */
.calendar-ring {
    transform-origin: center;
    animation: ringBounce 3s ease-in-out infinite;
}

.calendar-ring:nth-child(4) {
    animation-delay: 0.15s;
}

@keyframes ringBounce {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.92); }
}

/* Grid lines "draw in" on page load */
.grid-line {
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    animation: lineDrawIn 0.4s ease-out forwards;
}

.grid-line-1 { animation-delay: 0.2s; }
.grid-line-2 { animation-delay: 0.35s; }
.grid-line-3 { animation-delay: 0.5s; }

@keyframes lineDrawIn {
    to { stroke-dashoffset: 0; }
}

/* Sparkle twinkle animation */
.sparkle {
    animation: sparkleTwinkle 2s ease-in-out infinite;
    transform-origin: 40px 8px;
}

@keyframes sparkleTwinkle {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1) rotate(0deg);
    }
    25% {
        opacity: 1;
        transform: scale(1.15) rotate(10deg);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9) rotate(-5deg);
    }
    75% {
        opacity: 1;
        transform: scale(1.1) rotate(5deg);
    }
}

/* Hover: sparkle gets excited */
.header-icon:hover .sparkle {
    animation: sparkleExcited 0.3s ease-out forwards;
}

@keyframes sparkleExcited {
    0% { transform: scale(1); }
    50% { transform: scale(1.4) rotate(15deg); }
    100% { transform: scale(1.2) rotate(5deg); }
}

/* When generating, icon "works" - calendar wobbles */
.header-icon.generating .calendar-body {
    animation: calendarWork 0.3s ease-in-out infinite;
}

@keyframes calendarWork {
    0%, 100% { transform: rotateY(0deg); }
    50% { transform: rotateY(3deg); }
}

/* ============================================
   BRANDED TITLE WITH GRADIENT
   ============================================ */
.app-title {
    background: linear-gradient(135deg, #1e40af 0%, #4f46e5 50%, #2563eb 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleShimmer 8s ease-in-out infinite;
}

@keyframes titleShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Hover effect - brief pop */
.app-title:hover {
    animation: titlePop 0.2s ease-out forwards, titleShimmer 8s ease-in-out infinite;
}

@keyframes titlePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Dark mode - lighter gradient */
[data-theme="dark"] .app-title {
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #3b82f6 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Dark mode icon adjustments */
[data-theme="dark"] .calendar-body {
    fill: #1e3a5f;
    stroke: #475569;
}

[data-theme="dark"] .grid-line {
    stroke: #475569;
}

[data-theme="dark"] .calendar-ring {
    fill: #3b82f6;
}

/* ============================================
   PAGE ENTRANCE ANIMATIONS
   ============================================ */

/* Header slides in from top */
.sticky-header {
    animation: headerSlideIn 0.5s ease-out;
}

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

/* Grid container fades in with slight scale */
#calendarContainer {
    animation: gridFadeIn 0.6s ease-out 0.2s both;
}

@keyframes gridFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Enhanced fade-in for week cards - now slides up */
.fade-in {
    animation: weekSlideIn 0.4s ease-out both;
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .icon-calendar,
    .calendar-ring,
    .sparkle,
    .app-title {
        animation: none;
    }

    .sticky-header,
    #calendarContainer,
    .fade-in {
        animation-duration: 0.01s;
    }

    .grid-line {
        stroke-dashoffset: 0;
        animation: none;
    }
}

/* ============================================
   CUSTOM DATE PICKER
   ============================================ */

.date-picker-wrapper {
    position: relative;
}

.date-picker-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.date-picker-toggle:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.date-picker-toggle:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.date-picker-icon {
    width: 1rem;
    height: 1rem;
    color: var(--brand-primary);
    flex-shrink: 0;
}

.date-picker-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-width: 3.5rem;
}

.date-picker-chevron {
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.date-picker-toggle[aria-expanded="true"] .date-picker-chevron {
    transform: rotate(180deg);
}

/* Dropdown panel */
.date-picker-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    z-index: 60;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    padding: 0.75rem;
    min-width: 260px;
    animation: datePickerSlideIn 0.2s ease-out;
}

.date-picker-dropdown.hidden {
    display: none;
}

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

/* Header */
.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.date-picker-month {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.date-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.date-nav-btn svg {
    width: 1rem;
    height: 1rem;
}

/* Day labels */
.date-picker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.125rem;
    margin-bottom: 0.25rem;
}

.day-label {
    text-align: center;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.25rem;
}

.day-label.sunday-label {
    color: var(--brand-primary);
}

/* Date grid */
.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.125rem;
}

.date-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* Non-Sunday dates - disabled appearance */
.date-cell:not(.sunday) {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.4;
}

/* Sunday dates - selectable */
.date-cell.sunday {
    color: var(--brand-primary);
    font-weight: 600;
    border: 1px solid transparent;
}

.date-cell.sunday:hover {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary);
}

/* Selected Sunday */
.date-cell.sunday.selected {
    background: var(--brand-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    animation: dateSelectPulse 0.3s ease-out;
}

@keyframes dateSelectPulse {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Today indicator */
.date-cell.today::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brand-accent);
}

.date-cell.sunday.selected.today::after {
    background: white;
}

/* Other month dates */
.date-cell.other-month {
    opacity: 0.25;
}

/* Quick action button */
.date-quick-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--brand-primary-light);
    border: 1px solid var(--brand-primary);
    border-radius: 0.5rem;
    color: var(--brand-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.date-quick-action:hover {
    background: var(--brand-primary);
    color: white;
}

.quick-action-icon {
    width: 1rem;
    height: 1rem;
}

/* ============================================
   CUSTOM HEADCOUNT PICKER
   ============================================ */

.headcount-picker {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.headcount-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.headcount-btn:hover:not(:disabled) {
    border-color: var(--brand-primary);
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

.headcount-btn:active:not(:disabled) {
    transform: scale(0.92);
}

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

.headcount-btn svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* Counter display */
.headcount-display {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 1.75rem;
    background: var(--bg-input-secondary);
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
}

.headcount-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: transform 0.2s ease, color 0.2s ease;
}

/* Animation when value changes */
.headcount-value.changing {
    animation: headcountBounce 0.3s ease-out;
    color: var(--brand-primary);
}

@keyframes headcountBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Team preview - mini avatars */
.headcount-preview {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border-color);
}

.mini-avatar {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 700;
    color: white;
    margin-left: -0.375rem;
    transition: all 0.25s ease;
}

.mini-avatar:first-child {
    margin-left: 0;
}

/* Avatar colors */
.mini-avatar:nth-child(1) { background: #3b82f6; }
.mini-avatar:nth-child(2) { background: #10b981; }
.mini-avatar:nth-child(3) { background: #8b5cf6; }
.mini-avatar:nth-child(4) { background: #f59e0b; }
.mini-avatar:nth-child(5) { background: #f43f5e; }
.mini-avatar:nth-child(6) { background: #06b6d4; }
.mini-avatar:nth-child(7) { background: #6366f1; }
.mini-avatar:nth-child(8) { background: #3b82f6; }
.mini-avatar:nth-child(9) { background: #10b981; }
.mini-avatar:nth-child(10) { background: #8b5cf6; }

/* Avatar enter animation */
.mini-avatar.entering {
    animation: avatarEnter 0.25s ease-out forwards;
}

@keyframes avatarEnter {
    from {
        opacity: 0;
        transform: scale(0.5) translateX(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

/* Avatar exit animation */
.mini-avatar.exiting {
    animation: avatarExit 0.2s ease-out forwards;
}

@keyframes avatarExit {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* Hover effect on preview - spread out */
.headcount-preview:hover .mini-avatar {
    margin-left: 0;
}

/* Hide preview on small screens */
@media (max-width: 640px) {
    .headcount-preview {
        display: none;
    }
}

/* Mobile: bottom sheet for date picker */
@media (max-width: 767px) {
    .date-picker-dropdown {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        border-radius: 1rem 1rem 0 0;
        max-width: none;
        animation: datePickerSlideUp 0.25s ease-out;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    @keyframes datePickerSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .headcount-btn {
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* ============================================
   CELEBRATION EFFECTS
   ============================================ */

/* Confetti container */
.celebration-confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    animation: confettiFall 2.5s ease-out forwards;
}

.confetti-piece:nth-child(1) { left: 10%; background: #22c55e; animation-delay: 0s; }
.confetti-piece:nth-child(2) { left: 20%; background: #3b82f6; animation-delay: 0.1s; border-radius: 50%; }
.confetti-piece:nth-child(3) { left: 30%; background: #f59e0b; animation-delay: 0.15s; }
.confetti-piece:nth-child(4) { left: 40%; background: #ec4899; animation-delay: 0.05s; border-radius: 50%; }
.confetti-piece:nth-child(5) { left: 50%; background: #8b5cf6; animation-delay: 0.2s; }
.confetti-piece:nth-child(6) { left: 60%; background: #14b8a6; animation-delay: 0.08s; border-radius: 50%; }
.confetti-piece:nth-child(7) { left: 70%; background: #f43f5e; animation-delay: 0.12s; }
.confetti-piece:nth-child(8) { left: 80%; background: #06b6d4; animation-delay: 0.18s; border-radius: 50%; }
.confetti-piece:nth-child(9) { left: 90%; background: #eab308; animation-delay: 0.07s; }

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg) scale(0.5);
        opacity: 0;
    }
}

.confetti-piece:nth-child(odd) {
    animation-name: confettiFallDrift;
}

@keyframes confettiFallDrift {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) translateX(-30px) rotate(-720deg);
        opacity: 0;
    }
}

/* Enhanced generate button hover */
#generateBtn {
    position: relative;
    overflow: hidden;
}

#generateBtn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

#generateBtn:hover::before {
    width: 300px;
    height: 300px;
}

#generateBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(37, 99, 235, 0.4);
}

#generateBtn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px -3px rgba(37, 99, 235, 0.3);
}

/* Sparkle icon animation on generate button hover */
#generateBtn:hover svg {
    animation: buttonSparkle 0.4s ease-out;
}

@keyframes buttonSparkle {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.1); }
    50% { transform: rotate(10deg) scale(1.2); }
    75% { transform: rotate(-5deg) scale(1.1); }
    100% { transform: rotate(0deg) scale(1); }
}

/* Enhanced cell hover - subtle lift */
.schedule-select:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1;
}

/* Enhanced toast entrance */
#toast:not(.translate-y-24) {
    animation: toastBounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toastBounceIn {
    0% {
        transform: translateY(100px);
        opacity: 0;
    }
    60% {
        transform: translateY(-5px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Enhanced grade badge celebration */
#solverGradeBadge.celebrating {
    animation: gradeCelebrateEnhanced 0.8s ease-out;
}

@keyframes gradeCelebrateEnhanced {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    20% {
        transform: scale(1.3);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    40% {
        transform: scale(0.95);
    }
    60% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Grid success ripple effect */
.schedule-success-ripple .schedule-select {
    animation: cellSuccessRipple 0.5s ease-out;
    animation-fill-mode: both;
}

@keyframes cellSuccessRipple {
    0% {
        filter: brightness(1);
    }
    30% {
        filter: brightness(1.1);
    }
    100% {
        filter: brightness(1);
    }
}

/* ============================================
   CLOUD SAVE PROMPT
   ============================================ */
.animate-slide-up {
    animation: cloudPromptSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

#cloudSavePrompt {
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] #cloudSavePrompt {
    background: rgba(30, 41, 59, 0.95);
    border-color: var(--border-color);
}

[data-theme="dark"] #cloudSavePrompt h4 {
    color: var(--text-primary);
}

[data-theme="dark"] #cloudSavePrompt p {
    color: var(--text-secondary);
}

/* ============================================
   MOBILE RESPONSIVE IMPROVEMENTS
   Breakpoint: max-width 640px (sm in Tailwind)
   ============================================ */

@media (max-width: 640px) {
    /* ----------------------------------------
       TOUCH TARGETS - 44px minimum
       ---------------------------------------- */

    /* Context menu items - larger tap area */
    .context-menu-item {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 15px;
    }

    /* Date picker toggle button */
    .date-picker-toggle {
        min-height: 44px;
        padding: 0 12px;
    }

    /* Headcount buttons - already 2.5rem at 767px, ensure 44px at 640px */
    .headcount-btn {
        width: 44px;
        height: 44px;
    }

    .headcount-btn svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    /* Headcount display - match button height */
    .headcount-display {
        height: 44px;
        width: 2.5rem;
    }

    /* Date navigation buttons in date picker dropdown */
    .date-nav-btn {
        width: 44px;
        height: 44px;
    }

    .date-nav-btn svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    /* Date cells in picker grid */
    .date-cell {
        height: 44px;
        font-size: 0.875rem;
    }

    /* Quick action button in date picker */
    .date-quick-action {
        min-height: 48px;
        padding: 12px;
        font-size: 0.875rem;
    }

    /* Theme toggle button */
    .theme-toggle {
        width: 44px;
        height: 44px;
    }

    /* Settings time inputs */
    .settings-time-input {
        min-height: 44px;
        padding: 10px 12px;
    }

    /* Mobile action button (three dots) */
    .mobile-action-btn {
        width: 44px;
        height: 44px;
    }

    /* ----------------------------------------
       HEADER CONTROLS - Responsive layout
       ---------------------------------------- */

    /* Tighten header padding on small screens */
    .sticky-header {
        padding: 12px;
    }

    /* App title - slightly smaller on very small screens */
    .app-title {
        font-size: 1.375rem;
    }

    /* Header icon - slightly smaller */
    .header-icon svg {
        width: 36px;
        height: 36px;
    }

    /* Generate button - compact on mobile */
    #generateBtn {
        min-width: 140px;
        height: 44px;
        padding: 0 12px;
        font-size: 0.875rem;
        gap: 6px;
    }

    #generateBtn svg {
        width: 16px;
        height: 16px;
    }

    /* Row 2 controls - allow wrap */
    .sticky-header > div:last-of-type:not(.hidden) {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Date picker wrapper - compact */
    .date-picker-wrapper {
        flex-shrink: 0;
    }

    /* Date picker value - shorter format expected */
    .date-picker-value {
        min-width: auto;
        font-size: 0.8125rem;
    }

    /* ----------------------------------------
       OVERFLOW PREVENTION
       ---------------------------------------- */

    /* Prevent horizontal scroll on body */
    body {
        overflow-x: hidden;
    }

    /* Main container max width */
    .max-w-\[1400px\] {
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Schedule grid wrapper - horizontal scroll with momentum */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
    }

    /* Ensure table doesn't cause page overflow */
    #calendarContainer {
        max-width: 100%;
        overflow-x: visible;
    }

    /* ----------------------------------------
       MODAL SIZING - Full width on mobile
       ---------------------------------------- */

    /* Settings modal - full width with margins */
    .settings-modal {
        padding: 0;
        align-items: flex-end;
    }

    .settings-modal-content {
        max-width: 100%;
        width: 100%;
        margin: 0;
        border-radius: 1rem 1rem 0 0;
        max-height: 90vh;
        padding: 20px 16px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    /* Modal backdrop - ensure no tap through */
    .settings-modal-backdrop {
        -webkit-tap-highlight-color: transparent;
    }

    /* Mobile action sheet - already positioned, just ensure safe area */
    .mobile-action-sheet-content {
        max-width: 100%;
        border-radius: 1rem 1rem 0 0;
    }

    /* Rotate overlay content */
    .rotate-overlay-content {
        margin: 16px;
        max-width: calc(100% - 32px);
    }

    /* ----------------------------------------
       TOAST NOTIFICATIONS
       ---------------------------------------- */

    /* Toast - positioned at bottom, above safe area */
    #toast {
        left: 12px !important;
        right: 12px !important;
        bottom: calc(16px + env(safe-area-inset-bottom)) !important;
        max-width: calc(100% - 24px) !important;
    }

    /* ----------------------------------------
       CONTEXT MENU - Full width bottom sheet
       ---------------------------------------- */

    .context-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-width: 100%;
        border-radius: 1rem 1rem 0 0;
        padding: 8px 0;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        animation: contextMenuSlideUp 0.2s ease-out;
    }

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

    /* Context menu divider - full width */
    .context-menu-divider {
        margin: 8px 0;
    }

    /* ----------------------------------------
       DATE PICKER DROPDOWN - Bottom sheet
       ---------------------------------------- */

    .date-picker-dropdown {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    /* Grid should fit comfortably */
    .date-picker-grid {
        gap: 4px;
    }

    /* ----------------------------------------
       SPACING IMPROVEMENTS
       ---------------------------------------- */

    /* Week cards */
    .week-card-mobile {
        margin-bottom: 12px;
    }

    /* Day card padding */
    .day-card {
        padding: 16px;
    }

    /* Day card header */
    .day-card-header {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    /* Shift rows in mobile card */
    .shift-row-mobile {
        padding: 10px 0;
    }

    /* Manager info - more readable */
    .manager-name-mobile {
        font-size: 0.9375rem;
    }

    /* Avatar size increase for better visibility */
    .avatar-mobile {
        width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }

    /* Budget section */
    .day-card-budget {
        padding: 12px;
        margin-bottom: 12px;
    }

    .budget-input-mobile {
        width: 5.5rem;
        padding: 8px 10px;
        font-size: 1rem;
    }

    /* Mobile roster section */
    .mobile-roster-content {
        padding: 12px;
    }

    .mobile-roster-row {
        padding: 10px 0;
    }

    .mobile-roster-name-input,
    .mobile-roster-role-input {
        padding: 10px 12px;
    }

    /* Stats cards */
    .stats-card {
        padding: 14px;
    }

    .stats-value {
        font-size: 1.375rem;
    }

    .stats-label {
        font-size: 0.6875rem;
    }

    /* Warnings panel */
    #warningsPanel {
        padding: 12px;
        margin-bottom: 12px;
    }

    .warning-item {
        padding: 10px 12px;
    }

    .warning-message {
        font-size: 0.8125rem;
    }

    /* ----------------------------------------
       FORM INPUTS - Larger for touch
       ---------------------------------------- */

    /* Generic input sizing */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    select {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* ----------------------------------------
       FOOTER
       ---------------------------------------- */

    footer {
        padding: 16px 12px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* ============================================
   TABLET RESPONSIVE IMPROVEMENTS
   Breakpoint: 641px - 1024px
   ============================================ */

@media (min-width: 641px) and (max-width: 1024px) {
    /* Moderate sizing adjustments for tablets */

    /* Touch targets still important */
    .context-menu-item {
        min-height: 44px;
        padding: 10px 14px;
    }

    .date-nav-btn {
        width: 40px;
        height: 40px;
    }

    /* Modal sizing */
    .settings-modal-content {
        max-width: 480px;
    }

    /* Stats cards - two column on tablet */
    .stats-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* ============================================
   VERY SMALL SCREENS (iPhone SE, etc)
   Breakpoint: max-width 375px
   ============================================ */

@media (max-width: 375px) {
    /* Even more compact header */
    .sticky-header {
        padding: 10px;
    }

    .app-title {
        font-size: 1.25rem;
    }

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

    /* Generate button - icon only option */
    #generateBtn {
        min-width: 44px;
        padding: 0 10px;
    }

    #generateBtn span {
        display: none;
    }

    /* Date picker value - abbreviate further */
    .date-picker-value {
        font-size: 0.75rem;
    }

    /* Context menu */
    .context-menu-item {
        font-size: 14px;
        padding: 12px 14px;
    }

    /* Day card adjustments */
    .day-card {
        padding: 12px;
    }

    .day-name {
        font-size: 1rem;
    }

    /* Manager info */
    .manager-name-mobile {
        font-size: 0.875rem;
    }

    .avatar-mobile {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    /* Shift select */
    .schedule-select-mobile {
        min-width: 4rem;
        font-size: 0.75rem;
        padding: 8px;
    }
}

/* ============================================
   LANDSCAPE MODE ADJUSTMENTS
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    /* Compact header for landscape */
    .sticky-header {
        padding: 8px 12px;
    }

    /* Smaller generate button */
    #generateBtn {
        height: 40px;
    }

    /* Reduce modal max height */
    .settings-modal-content {
        max-height: 85vh;
    }

    /* Compact date picker */
    .date-picker-dropdown {
        max-height: 70vh;
        overflow-y: auto;
    }

    .date-cell {
        height: 36px;
    }

    /* Compact mobile cards */
    .day-card {
        min-height: auto;
        padding: 10px;
    }
}
