/* ============================================
   DESIGN SYSTEM - 8PX GRID
   ============================================ */
:root {
    /* 8px Grid Spacing Scale */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-7: 56px;
    --space-8: 64px;

    /* Typography Scale (8px based) */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 20px;
    --text-xl: 24px;
    --text-2xl: 28px;
    --text-3xl: 32px;
    --text-4xl: 36px;

    /* Component Standards */
    --btn-sm: var(--space-1) var(--space-2);
    --btn-md: var(--space-2) var(--space-3);
    --btn-lg: var(--space-2) var(--space-4);

    --card-padding: var(--space-3);
    --card-gap: var(--space-3);
    --card-radius: var(--space-1);

    --input-padding: var(--space-2);
    --form-gap: var(--space-3);
    --label-margin: var(--space-1);

    --sidebar-width: 280px;
    --main-padding: var(--space-4);
    --section-gap: var(--space-4);

    /* PREMIUM COLOR PALETTE - Government Professional + Beautiful */
    /* Primary Blues - Trust & Authority */
    --color-primary: #2563eb;
    --color-primary-light: #3b82f6;
    --color-primary-dark: #1e40af;
    --color-primary-darker: #1e3a8a;
    --color-primary-bg: #eff6ff;
    --color-primary-border: #bfdbfe;

    /* Success Greens - Compliance & Achievement */
    --color-success: #059669;
    --color-success-light: #10b981;
    --color-success-dark: #047857;
    --color-success-bg: #d1fae5;
    --color-success-border: #6ee7b7;

    /* Warning Ambers - Attention & Priority */
    --color-warning: #d97706;
    --color-warning-light: #f59e0b;
    --color-warning-dark: #b45309;
    --color-warning-bg: #fef3c7;
    --color-warning-border: #fcd34d;

    /* Error Reds - Violations & Urgency */
    --color-error: #dc2626;
    --color-error-light: #ef4444;
    --color-error-dark: #b91c1c;
    --color-error-bg: #fee2e2;
    --color-error-border: #fca5a5;

    /* Accent Purples - Analytics & Insights */
    --color-purple: #7c3aed;
    --color-purple-light: #8b5cf6;
    --color-purple-dark: #6d28d9;
    --color-purple-bg: #ede9fe;
    --color-purple-border: #c4b5fd;

    /* Neutral Grays - Professional Foundation */
    --color-text: #0f172a;
    --color-text-medium: #334155;
    --color-text-light: #64748b;
    --color-text-lighter: #94a3b8;
    --color-text-lightest: #cbd5e1;

    /* Backgrounds - Subtle Depth */
    --color-bg: #f8fafc;
    --color-bg-alt: #f1f5f9;
    --color-bg-light: #ffffff;
    --color-bg-dark: #0f172a;

    /* Borders - Subtle Separation */
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-border-dark: #cbd5e1;

    /* Sidebar - Deep Professional */
    --color-sidebar: #0f172a;
    --color-sidebar-hover: #1e293b;
    --color-sidebar-active: #2563eb;

    /* PREMIUM SHADOWS - Depth & Elevation */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

    /* Card Shadows - Subtle Glow Effects */
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 10px 20px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.08);

    /* Color Shadows for Premium Feel */
    --shadow-primary: 0 10px 20px -5px rgba(37, 99, 235, 0.2);
    --shadow-success: 0 10px 20px -5px rgba(5, 150, 105, 0.2);
    --shadow-warning: 0 10px 20px -5px rgba(217, 119, 6, 0.2);
    --shadow-error: 0 10px 20px -5px rgba(220, 38, 38, 0.2);
    --shadow-purple: 0 10px 20px -5px rgba(124, 58, 237, 0.2);

    /* ANIMATION TIMING - Smooth & Natural */
    --timing-fast: 150ms;
    --timing-base: 250ms;
    --timing-slow: 350ms;
    --timing-slower: 500ms;

    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* GRADIENTS - Depth & Visual Interest */
    --gradient-primary: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-error: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --gradient-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --gradient-light: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    /* Typography Weights */
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-extrabold: 800;

    /* Brand Color (used in banners and highlights) */
    --brand-primary: #2563eb;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: var(--color-bg);
    line-height: 1.6;
    color: var(--color-text);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body, html {
    width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* Premium Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-bold);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

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

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

::-webkit-scrollbar-track {
    background: var(--color-bg-alt);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border-dark);
    border-radius: 5px;
    transition: background var(--timing-base);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-light);
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gradient-primary);
    padding: var(--space-3);
    position: relative;
    overflow: hidden;
}

#loginScreen::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
}

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

.login-box {
    background: white;
    padding: var(--space-6);
    border-radius: 16px;
    box-shadow: var(--shadow-2xl);
    width: 100%;
    max-width: 424px;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.5s var(--ease-out);
}

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

.login-box h1 {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-2);
    color: var(--color-text);
    font-weight: 700;
    line-height: 1.2;
}

.login-box p {
    color: var(--color-text-light);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.login-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding: var(--space-3);
    color: var(--color-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    animation: fadeIn 0.3s var(--ease-out);
}

.login-progress .loading {
    width: 20px;
    height: 20px;
    border-width: 3px;
}

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

/* ============================================
   FORM STYLES
   ============================================ */
.form-group {
    margin-bottom: var(--form-gap);
}

.form-group label {
    display: block;
    margin-bottom: var(--label-margin);
    color: #475569;
    font-weight: 600;
    font-size: var(--text-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--input-padding);
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: var(--text-base);
    transition: all var(--timing-base) var(--ease-out);
    font-family: inherit;
    background: white;
    color: var(--color-text);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Touch-friendly inputs on mobile */
@media (max-width: 768px) {
    .form-group input,
    .form-group select,
    .form-group textarea,
    .form-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--color-border-dark);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    min-height: 96px;
    resize: vertical;
}

/* Grant Form Styles */
.grant-form {
    max-width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.form-section {
    background: var(--color-bg-alt);
    padding: var(--space-4);
    border-radius: var(--card-radius);
    border: 1px solid var(--color-border);
}

.form-section-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-text);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--color-primary);
}

.form-label {
    display: block;
    margin-bottom: var(--label-margin);
    color: var(--color-text-medium);
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
}

.form-input {
    width: 100%;
    padding: var(--input-padding);
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: var(--text-base);
    transition: all var(--timing-base) var(--ease-out);
    font-family: inherit;
    background: white;
    color: var(--color-text);
}

.form-input:hover {
    border-color: var(--color-border-dark);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.form-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 2px solid var(--color-border);
}

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

/* ============================================
   BUTTONS
   ============================================ */
button {
    padding: var(--btn-md);
    border-radius: 8px;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--timing-base) var(--ease-out);
    border: none;
    font-family: inherit;
    position: relative;
    overflow: hidden;
    letter-spacing: -0.01em;
    touch-action: manipulation; /* Better touch handling */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

/* Touch-friendly button sizes on mobile */
@media (max-width: 768px) {
    button {
        min-height: 44px; /* Minimum touch target size */
        padding: 12px var(--space-3);
    }
}

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

button:active::before {
    width: 300px;
    height: 300px;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.submit-btn,
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

.submit-btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-primary), var(--shadow-lg);
    transform: translateY(-2px) scale(1.02);
}

.submit-btn {
    width: 100%;
    padding: var(--btn-lg);
    font-size: var(--text-base);
}

.btn-sm {
    padding: var(--btn-sm);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--btn-lg);
    font-size: var(--text-base);
}

.btn-secondary {
    background: var(--color-text-light);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-text-medium);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-success);
}

.btn-success:hover:not(:disabled) {
    box-shadow: var(--shadow-success), var(--shadow-lg);
    transform: translateY(-2px) scale(1.02);
}

.btn-danger {
    background: var(--gradient-error);
    color: white;
    box-shadow: var(--shadow-error);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: var(--shadow-error), var(--shadow-lg);
    transform: translateY(-2px) scale(1.02);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-border);
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-bg-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   ALERTS & NOTIFICATIONS
   ============================================ */
.error,
.alert-error {
    color: var(--color-error);
    text-align: center;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--color-error-bg);
    border-radius: var(--space-1);
    font-size: var(--text-sm);
}

.alert-success {
    color: #059669;
    background: #d1fae5;
    padding: var(--space-2);
    border-radius: var(--space-1);
    margin-bottom: var(--space-3);
}

.alert-info {
    color: #0369a1;
    background: #e0f2fe;
    padding: var(--space-2);
    border-radius: var(--space-1);
    margin-bottom: var(--space-3);
}

.alert-warning {
    color: #d97706;
    background: #fef3c7;
    padding: var(--space-2);
    border-radius: var(--space-1);
    margin-bottom: var(--space-3);
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-dark);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    transition: transform var(--timing-slow) var(--ease-out);
    z-index: 1000;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-header {
    padding: var(--space-4) var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: var(--space-1);
    position: relative;
    z-index: 1;
}

.sidebar-header h2 {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: white;
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: var(--text-xs);
    color: var(--color-text-lighter);
    margin-top: var(--space-1);
    line-height: 1.4;
    font-weight: var(--font-medium);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px var(--space-3);
    margin: 4px var(--space-2);
    cursor: pointer;
    color: var(--color-text-lightest);
    font-size: var(--text-sm);
    text-decoration: none;
    transition: all var(--timing-base) var(--ease-out);
    border-radius: 10px;
    font-weight: var(--font-medium);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: white;
    border-radius: 0 3px 3px 0;
    transition: height var(--timing-base) var(--ease-out);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(4px);
}

.nav-item:hover::before {
    height: 60%;
}

.nav-item.active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-primary);
    font-weight: var(--font-semibold);
}

.nav-item.active::before {
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
}

.nav-emoji {
    font-size: var(--text-lg);
    margin-right: var(--space-2);
    width: 24px;
    display: inline-block;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    padding: var(--main-padding);
    min-height: 100vh;
    flex: 1;
    max-width: 100%;
}

.page-header {
    background: white;
    padding: var(--space-4);
    border-radius: 16px;
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border-light);
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-text);
    letter-spacing: -0.025em;
    margin-bottom: 0;
    line-height: 1.2;
}

/* ============================================
   CONTENT PAGES
   ============================================ */
.page-content {
    display: none;
}

.page-content.active {
    display: block;
}

/* ============================================
   CARDS AND STATS - ENTERPRISE GRADE
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--card-gap);
    margin-bottom: var(--section-gap);
}

.stat-card {
    background: white;
    padding: var(--space-4);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    transition: all var(--timing-slow) var(--ease-out);
    border: 1px solid var(--color-border-light);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, var(--stat-gradient-end, rgba(37, 99, 235, 0.08)) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--timing-slow) var(--ease-out);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--shadow-card-hover);
    border-color: var(--stat-gradient-start, var(--color-primary));
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--stat-gradient-start, var(--color-primary)), var(--stat-gradient-end, var(--color-primary-dark)));
    opacity: 0;
    transition: opacity var(--timing-base) var(--ease-out);
}

.stat-card:hover::before {
    opacity: 1;
}

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

.stat-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--stat-icon-bg, rgba(37, 99, 235, 0.1));
    transition: all var(--timing-slow) var(--ease-bounce);
    position: relative;
    z-index: 1;
}

.stat-icon-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: var(--stat-icon-bg, rgba(37, 99, 235, 0.1));
    opacity: 0;
    transition: opacity var(--timing-base) var(--ease-out);
}

.stat-card:hover .stat-icon-wrapper {
    transform: scale(1.15) rotate(5deg);
}

.stat-card:hover .stat-icon-wrapper::before {
    opacity: 1;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0; }
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: var(--font-semibold);
    background: var(--color-success-bg);
    color: var(--color-success-dark);
    letter-spacing: -0.01em;
}

.stat-trend.down {
    background: var(--color-error-bg);
    color: var(--color-error-dark);
}

.stat-value {
    font-size: 40px;
    font-weight: var(--font-bold);
    color: var(--color-text);
    margin-bottom: 4px;
    line-height: 1;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.stat-label {
    color: var(--color-text-light);
    font-size: 14px;
    font-weight: var(--font-medium);
    letter-spacing: -0.01em;
}

.stat-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border-light);
    font-size: 12px;
    color: var(--color-text-light);
}

/* Stat Card Color Variants - Premium Edition */
.stat-card.primary {
    --stat-gradient-start: #2563eb;
    --stat-gradient-end: #1e40af;
    --stat-icon-bg: rgba(37, 99, 235, 0.12);
    --stat-icon-bg-hover: rgba(37, 99, 235, 0.18);
}

.stat-card.success {
    --stat-gradient-start: #10b981;
    --stat-gradient-end: #059669;
    --stat-icon-bg: rgba(5, 150, 105, 0.12);
    --stat-icon-bg-hover: rgba(5, 150, 105, 0.18);
}

.stat-card.warning {
    --stat-gradient-start: #f59e0b;
    --stat-gradient-end: #d97706;
    --stat-icon-bg: rgba(217, 119, 6, 0.12);
    --stat-icon-bg-hover: rgba(217, 119, 6, 0.18);
}

.stat-card.purple {
    --stat-gradient-start: #8b5cf6;
    --stat-gradient-end: #7c3aed;
    --stat-icon-bg: rgba(124, 58, 237, 0.12);
    --stat-icon-bg-hover: rgba(124, 58, 237, 0.18);
}

.stat-card.error {
    --stat-gradient-start: #ef4444;
    --stat-gradient-end: #dc2626;
    --stat-icon-bg: rgba(220, 38, 38, 0.12);
    --stat-icon-bg-hover: rgba(220, 38, 38, 0.18);
}

/* Dashboard Charts */
.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--card-gap);
    margin-bottom: var(--section-gap);
}

.chart-card {
    background: white;
    padding: var(--space-4);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border-light);
    transition: all var(--timing-slow) var(--ease-out);
    max-height: 400px;
    overflow: hidden;
}

.chart-card canvas {
    max-height: 250px;
    width: 100% !important;
    height: auto !important;
}

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

.chart-card h3 {
    font-size: 18px;
    font-weight: var(--font-semibold);
    color: var(--color-text);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.02em;
}

/* Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.activity-item {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: 8px;
    transition: background 0.2s;
}

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

.activity-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--color-bg-light);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--color-text);
    font-size: 14px;
    margin-bottom: 2px;
}

.activity-description {
    font-size: 13px;
    color: var(--color-text-light);
}

.activity-time {
    font-size: 12px;
    color: var(--color-text-light);
    white-space: nowrap;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--section-gap);
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: white;
    border: 2px solid var(--color-border-light);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--timing-base) var(--ease-out);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.quick-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.05), transparent);
    transition: left var(--timing-slow) var(--ease-out);
}

.quick-action-btn:hover::before {
    left: 100%;
}

.quick-action-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-md);
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--color-bg-light);
}

.quick-action-text {
    flex: 1;
}

.quick-action-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
    margin-bottom: 2px;
}

.quick-action-subtitle {
    font-size: 12px;
    color: var(--color-text-light);
}

/* ============================================
   TABLES
   ============================================ */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-3);
}

table {
    width: 100%;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--color-border-light);
    min-width: 600px; /* Minimum width for readability */
}

th {
    background: var(--color-bg-alt);
    padding: var(--space-3);
    text-align: left;
    font-weight: var(--font-semibold);
    color: var(--color-text-medium);
    border-bottom: 2px solid var(--color-border);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
    color: var(--color-text);
}

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

tbody tr {
    transition: all var(--timing-base) var(--ease-out);
}

tbody tr:hover {
    background: var(--color-bg-alt);
    transform: scale(1.002);
}

/* ============================================
   VIDEOS TABLE - MOBILE RESPONSIVE CARDS
   ============================================ */
.videos-mobile-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.video-card-mobile {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--timing-base) var(--ease-out);
}

.video-card-mobile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.video-card-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    background: var(--color-bg-alt);
}

.video-filename-mobile {
    flex: 1;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    color: var(--color-text);
    word-break: break-word;
    line-height: 1.4;
}

.video-status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    white-space: nowrap;
    flex-shrink: 0;
}

.video-card-body {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

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

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

.video-info-label {
    font-size: var(--text-sm);
    color: var(--color-text-medium);
    font-weight: var(--font-medium);
}

.video-info-value {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: var(--font-semibold);
}

.video-violations {
    color: var(--color-error);
    font-size: var(--text-base);
}

.video-card-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-alt);
}

.video-review-btn {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--timing-base) var(--ease-out);
}

.video-review-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.video-no-action {
    color: var(--color-text-light);
    font-size: var(--text-sm);
    font-style: italic;
    text-align: center;
    display: block;
    padding: var(--space-2);
}

/* Desktop: Hide mobile cards */
@media (min-width: 769px) {
    .videos-mobile-container {
        display: none;
    }
}

/* Mobile: Hide table, show cards */
@media (max-width: 768px) {
    .videos-table {
        display: none;
    }

    .table-wrapper {
        overflow-x: visible;
    }
}

/* ============================================
   VIOLATIONS TABLE - MOBILE RESPONSIVE CARDS
   ============================================ */
.violations-mobile-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.violation-card-mobile {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--timing-base) var(--ease-out);
    cursor: pointer;
}

.violation-card-mobile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.violation-card-mobile:active {
    transform: translateY(0);
}

.violation-card-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    background: var(--color-bg-alt);
}

.violation-address-mobile {
    flex: 1;
    font-weight: var(--font-bold);
    font-size: var(--text-base);
    color: var(--color-text);
    word-break: break-word;
    line-height: 1.4;
}

.violation-status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: capitalize;
}

.violation-card-body {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.violation-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-2);
}

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

.violation-info-label {
    font-size: var(--text-sm);
    color: var(--color-text-medium);
    font-weight: var(--font-medium);
    flex-shrink: 0;
    min-width: 80px;
}

.violation-info-value {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: var(--font-semibold);
    text-align: right;
    word-break: break-word;
}

.violation-description {
    font-weight: var(--font-normal);
    color: var(--color-text-medium);
}

.violation-fine {
    color: var(--color-error);
    font-size: var(--text-base);
}

.violation-card-footer {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-primary-bg);
    text-align: center;
}

.violation-view-details {
    color: var(--color-primary);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

/* ============================================
   GRANT DATA TABLE - MOBILE RESPONSIVE CARDS
   ============================================ */
.grant-mobile-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.grant-card-mobile {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--timing-base) var(--ease-out);
    cursor: pointer;
}

.grant-card-mobile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.grant-card-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    background: var(--color-bg-alt);
}

.grant-title-mobile {
    flex: 1;
    font-weight: var(--font-bold);
    font-size: var(--text-base);
    color: var(--color-text);
    word-break: break-word;
    line-height: 1.4;
}

.grant-status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: capitalize;
}

.grant-card-body {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.grant-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-2);
}

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

.grant-info-label {
    font-size: var(--text-sm);
    color: var(--color-text-medium);
    font-weight: var(--font-medium);
    flex-shrink: 0;
    min-width: 100px;
}

.grant-info-value {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: var(--font-semibold);
    text-align: right;
    word-break: break-word;
}

.grant-card-footer {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-success-bg);
    text-align: center;
}

.grant-view-details {
    color: var(--color-success);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Desktop: Hide mobile cards */
@media (min-width: 769px) {
    .grant-mobile-container {
        display: none;
    }
}

/* Mobile: Hide table, show cards */
@media (max-width: 768px) {
    .grants-table {
        display: none;
    }
}
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Desktop: Hide mobile cards */
@media (min-width: 769px) {
    .violations-mobile-container {
        display: none;
    }
}

/* Mobile: Hide table, show cards */
@media (max-width: 768px) {
    .violations-table {
        display: none;
    }
}

/* ============================================
   VIOLATION DETAIL PAGE - MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    /* Violation detail grid - single column */
    .violation-detail-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-2);
    }

    /* Violation detail cards */
    .violation-detail-card {
        padding: var(--space-2);
        margin-bottom: var(--space-2);
    }

    .violation-detail-card h2 {
        font-size: var(--text-lg);
        margin-bottom: var(--space-2);
    }

    /* Card headers with buttons */
    .violation-card-header-mobile {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .violation-card-header-mobile h2 {
        margin-bottom: 0;
    }

    .violation-action-btn {
        width: 100%;
        padding: var(--space-2) var(--space-3);
    }

    /* Property and violation info grids */
    .display-grid.gap-2 {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    /* Button groups */
    .flex.gap-2 {
        flex-direction: column;
        gap: var(--space-2);
    }

    .flex.gap-2 button {
        width: 100%;
    }

    /* Image gallery responsive */
    .violation-images-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: var(--space-2);
    }

    /* History timeline mobile */
    .violation-history-timeline {
        padding-left: var(--space-3);
    }

    /* Info rows in cards */
    .violation-info-grid {
        grid-template-columns: 1fr;
    }

    .violation-info-item {
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--color-border-light);
        word-break: break-word;
    }

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

    .violation-edit-btn-wrapper {
        margin-top: var(--space-2);
    }

    .violation-edit-btn {
        width: 100%;
    }

    .display-grid.gap-2 > div {
        padding: var(--space-1) 0;
        border-bottom: 1px solid var(--color-border-light);
    }

    .display-grid.gap-2 > div:last-child {
        border-bottom: none;
    }

    /* Full code text section */
    .col-span-full {
        grid-column: 1 / -1;
        margin-top: var(--space-2);
    }

    .col-span-full .text-sm {
        font-size: var(--text-xs);
        padding: var(--space-2);
    }
}

/* ============================================
   CODEBOOK PAGE - MOBILE RESPONSIVE
   ============================================ */
.codebook-mobile-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.codebook-card-mobile {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--timing-base) var(--ease-out);
}

.codebook-card-mobile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.codebook-card-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-bg-alt);
}

.codebook-code-mobile {
    font-weight: var(--font-bold);
    font-size: var(--text-lg);
    color: var(--color-primary);
    font-family: monospace;
}

.codebook-status-active {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    background: var(--color-success-bg);
    color: var(--color-success-dark);
}

.codebook-status-inactive {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    background: var(--color-bg-alt);
    color: var(--color-text-light);
}

.codebook-card-body {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.codebook-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-2);
}

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

.codebook-info-label {
    font-size: var(--text-sm);
    color: var(--color-text-medium);
    font-weight: var(--font-medium);
    flex-shrink: 0;
    min-width: 100px;
}

.codebook-info-value {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: var(--font-semibold);
    text-align: right;
    word-break: break-word;
}

.codebook-fine {
    color: var(--color-error);
    font-size: var(--text-base);
}

.codebook-card-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-alt);
    display: flex;
    gap: var(--space-2);
}

.codebook-edit-btn,
.codebook-delete-btn {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    border: none;
    border-radius: 8px;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--timing-base) var(--ease-out);
}

.codebook-edit-btn {
    background: var(--color-primary);
    color: white;
}

.codebook-edit-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.codebook-delete-btn {
    background: var(--color-error);
    color: white;
}

.codebook-delete-btn:hover {
    background: var(--color-error-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Desktop: Hide mobile cards */
@media (min-width: 769px) {
    .codebook-mobile-container {
        display: none;
    }
}

/* Mobile: Hide table, show cards */
@media (max-width: 768px) {
    .codebook-table {
        display: none;
    }

    /* Codebook upload grid - single column on mobile */
    .codebook-upload-grid {
        grid-template-columns: 1fr !important;
    }

    .codebook-upload-card {
        padding: var(--space-3);
    }

    /* Page header buttons stack on mobile */
    .codebook-page-header .flex.gap-2 {
        flex-direction: column;
        width: 100%;
    }

    .codebook-page-header .flex.gap-2 > * {
        width: 100%;
    }

    /* Processing queue responsive */
    #processingQueueContainer {
        overflow-x: auto;
    }
}

/* ============================================
   VIDEO REVIEW PAGE - MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    /* Video review metadata grid */
    .video-review-info-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-2);
    }

    .video-review-info-item {
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--color-border-light);
    }

    .video-review-info-item:last-child {
        border-bottom: none;
    }

    .video-review-metadata {
        padding: var(--space-2);
    }

    .video-review-metadata h1 {
        font-size: var(--text-xl);
    }

    /* Video review violations container */
    .video-review-violations {
        padding: var(--space-2);
    }

    .video-review-violations h2 {
        font-size: var(--text-lg);
    }

    /* Video review group cards */
    .video-review-group {
        padding: var(--space-2);
        margin-bottom: var(--space-3);
    }

    /* Address group header */
    .video-review-group .flex.flex-col {
        gap: var(--space-2);
    }

    .video-review-group .grid.grid-cols-1.md\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* Image grids */
    .video-review-images-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-2) !important;
    }

    /* Violation detail cards */
    .video-review-violations-list > div {
        padding: var(--space-2);
    }

    .video-review-violations-list .flex.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    /* Risk assessment badges */
    .video-review-violations-list .flex.items-center.gap-3.flex-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .video-review-violations-list .flex.items-center.gap-2 {
        width: 100%;
        justify-content: space-between;
    }

    /* Code mapping sections */
    .video-review-violations-list .space-y-2 {
        gap: var(--space-2);
    }

    .video-review-violations-list .flex.items-start.justify-between {
        flex-direction: column;
        gap: var(--space-2);
    }

    .video-review-violations-list .flex.items-center.gap-3 {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    /* Action buttons */
    .video-review-actions {
        flex-direction: column;
        gap: var(--space-2);
    }

    .video-review-action-btn {
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    /* Rank summary */
    .video-review-summary {
        padding: var(--space-2);
    }

    .video-review-summary-content {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .video-review-summary-header {
        width: 100%;
        justify-content: center;
    }

    .video-review-summary-stat {
        width: 100%;
        justify-content: center;
    }

    .video-review-violations .flex.items-center.justify-between.flex-wrap {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .video-review-violations .flex.items-center.gap-2 {
        width: 100%;
        justify-content: space-between;
    }

    /* Property address card */
    .video-review-group .bg-blue-50 {
        padding: var(--space-2);
    }

    .video-review-group .text-lg {
        font-size: var(--text-base);
    }

    /* Back button */
    .video-review-metadata + button,
    .video-review-metadata button {
        width: 100%;
        margin-bottom: var(--space-2);
    }
}

/* ============================================
   CALENDAR PAGE - MOBILE RESPONSIVE
   ============================================ */
.calendar-mobile-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.calendar-card-mobile {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--timing-base) var(--ease-out);
}

.calendar-card-mobile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.calendar-card-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    background: var(--color-bg-alt);
}

.calendar-date-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: var(--space-2);
    background: var(--color-primary);
    color: white;
    border-radius: 8px;
    flex-shrink: 0;
}

.calendar-date-day {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    line-height: 1;
}

.calendar-date-month {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    margin-top: 2px;
}

.calendar-title-mobile {
    flex: 1;
    min-width: 0;
}

.calendar-title-text {
    font-weight: var(--font-bold);
    font-size: var(--text-base);
    color: var(--color-text);
    margin-bottom: 4px;
    word-break: break-word;
}

.calendar-time-text {
    font-size: var(--text-xs);
    color: var(--color-text-light);
}

.calendar-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
    white-space: nowrap;
    flex-shrink: 0;
}

.calendar-card-body {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.calendar-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-2);
}

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

.calendar-info-label {
    font-size: var(--text-sm);
    color: var(--color-text-medium);
    font-weight: var(--font-medium);
    flex-shrink: 0;
    min-width: 90px;
}

.calendar-info-value {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: var(--font-normal);
    text-align: right;
    word-break: break-word;
}

.calendar-violation-link {
    color: var(--color-primary);
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    font-size: var(--text-sm);
    cursor: pointer;
    font-weight: var(--font-medium);
}

.calendar-violation-link:hover {
    color: var(--color-primary-dark);
}

.calendar-no-violation {
    color: var(--color-text-light);
    font-style: italic;
}

.calendar-card-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-alt);
    display: flex;
    gap: var(--space-2);
}

.calendar-edit-btn,
.calendar-delete-btn {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    border: none;
    border-radius: 8px;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--timing-base) var(--ease-out);
}

.calendar-edit-btn {
    background: var(--color-primary);
    color: white;
}

.calendar-edit-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.calendar-delete-btn {
    background: var(--color-error);
    color: white;
}

.calendar-delete-btn:hover {
    background: var(--color-error-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Desktop: Hide mobile cards */
@media (min-width: 769px) {
    .calendar-mobile-container {
        display: none;
    }
}

/* Mobile: Hide table, show cards */
@media (max-width: 768px) {
    .calendar-table {
        display: none;
    }

    /* Calendar page header */
    .calendar-page-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .calendar-add-btn {
        width: 100%;
    }

    /* Calendar events container */
    .bg-white.p-4.rounded.mt-3 {
        padding: var(--space-2);
    }
}

/* ============================================
   SECTIONS & CONTAINERS
   ============================================ */
.content-section {
    background: white;
    padding: var(--space-4);
    border-radius: 16px;
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border-light);
    transition: all var(--timing-base) var(--ease-out);
}

.content-section:hover {
    box-shadow: var(--shadow-md);
}

.content-section h2,
.content-section h3 {
    margin-bottom: var(--space-3);
    color: var(--color-text);
    font-weight: var(--font-bold);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.content-section h2 {
    font-size: var(--text-xl);
}

.content-section h3 {
    font-size: var(--text-lg);
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}

/* ============================================
   MODALS
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: var(--space-3);
    animation: fadeIn var(--timing-base) var(--ease-out);
}

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

.modal-content {
    background: white;
    padding: var(--space-5);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--color-border-light);
    animation: slideUp var(--timing-slow) var(--ease-out);
}

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

.modal-header h3 {
    font-size: var(--text-xl);
    font-weight: 700;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-xl);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
    color: var(--color-text-light);
}

.modal-close:hover {
    color: var(--color-text);
    transform: none;
    box-shadow: none;
}

.modal-body {
    margin-bottom: var(--space-3);
}

.modal-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
}

/* ============================================
   BADGES & STATUS
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
    transition: all var(--timing-base) var(--ease-out);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success-dark);
    border: 1px solid var(--color-success-border);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-dark);
    border: 1px solid var(--color-warning-border);
}

.badge-danger {
    background: var(--color-error-bg);
    color: var(--color-error-dark);
    border: 1px solid var(--color-error-border);
}

.badge-info {
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
    border: 1px solid var(--color-primary-border);
}

.badge-primary {
    background: var(--color-primary-bg);
    color: var(--color-primary);
    border: 1px solid var(--color-primary-border);
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-light) 0%,
        var(--color-border-light) 50%,
        var(--color-bg-light) 100%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
}

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

/* ============================================
   UTILITY CLASSES (8px GRID)
   ============================================ */
.hidden {
    display: none !important;
}

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

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }

/* Margin Bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

/* Margin Top */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

/* Margin Horizontal */
.mx-1 { margin-left: var(--space-1); margin-right: var(--space-1); }
.mx-2 { margin-left: var(--space-2); margin-right: var(--space-2); }
.mx-3 { margin-left: var(--space-3); margin-right: var(--space-3); }

/* Margin Vertical */
.my-1 { margin-top: var(--space-1); margin-bottom: var(--space-1); }
.my-2 { margin-top: var(--space-2); margin-bottom: var(--space-2); }
.my-3 { margin-top: var(--space-3); margin-bottom: var(--space-3); }

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

/* Padding Horizontal */
.px-1 { padding-left: var(--space-1); padding-right: var(--space-1); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }

/* Padding Vertical */
.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* Gap */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }


/* ============================================
   ADDITIONAL UTILITY CLASSES FOR REFACTORING
   ============================================ */
.cursor-pointer { cursor: pointer; }
.rounded { border-radius: var(--space-1); }
.rounded-lg { border-radius: var(--space-2); }

.bg-white { background: white; }
.bg-gray-50 { background: var(--color-bg-light); }
.bg-gray-100 { background: #f1f5f9; }
.bg-primary { background: var(--color-primary) !important; }
.bg-secondary { background: #6b7280 !important; }
.bg-success { background: #10b981 !important; }
.bg-purple { background: var(--brand-primary) !important; }

/* Button hover states for utility classes */
button.bg-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
}

button.bg-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

button.bg-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
    transition: all 0.2s ease;
}

button.bg-purple:hover {
    background: #1e3a8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(30, 64, 175, 0.2);
    transition: all 0.2s ease;
}

.text-white { color: white; }
.text-gray-600 { color: #475569; }
.text-gray-900 { color: var(--color-text); }
.text-warning { color: #f59e0b; }

.w-full { width: 100%; }
.max-w-7xl { max-width: 1400px; }
.max-w-full { max-width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.ml-3 { margin-left: var(--space-3); }

.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}
.shadow-sm { box-shadow: var(--shadow-sm); }
.border-2 { border: 2px solid var(--color-border); }
.border-dashed { border-style: dashed; }
.transition-transform { transition: transform 0.2s; }
.display-grid { display: grid; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.max-h-48 { max-height: 200px; }
.h-96 { height: 600px; }
.h-10 { height: 42px; }
.text-4xl { font-size: var(--text-4xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.flex-1 { flex: 1; }

/* Responsive images and media */
img {
    max-width: 100%;
    height: auto;
}

video {
    max-width: 100%;
    height: auto;
}

iframe {
    max-width: 100%;
    height: auto;
}

/* Image gallery responsive */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-2);
}

@media (max-width: 768px) {
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--space-2);
    }
}

@media (max-width: 480px) {
    .image-gallery {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-1);
    }
}

.btn-pad-sm { padding: 16px 20px; }
.btn-pad-md { padding: 16px 24px; }

/* Responsive images and media */
img {
    max-width: 100%;
    height: auto;
}

video {
    max-width: 100%;
    height: auto;
}

iframe {
    max-width: 100%;
    height: auto;
}

/* Image gallery responsive */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-2);
}

/* Responsive handling for inline styled elements */
[style*="max-width"] {
    max-width: 100% !important;
}

@media (max-width: 768px) {
    [style*="max-width: 800px"],
    [style*="max-width: 900px"],
    [style*="max-width: 1000px"],
    [style*="max-width: 700px"] {
        max-width: calc(100% - var(--space-4)) !important;
        margin-left: var(--space-2) !important;
        margin-right: var(--space-2) !important;
    }

    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--space-2);
    }

    .h-96 {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .image-gallery {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-1);
    }

    .h-96 {
        height: 300px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
*:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

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

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

/* ============================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ============================================ */

/* Tablet and below (1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .main-content {
        padding: var(--space-3);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

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

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

    .page-header {
        padding: var(--space-3);
    }

    .login-box {
        padding: var(--space-4);
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }

    .modal-content {
        max-width: 90%;
    }
}

/* Desktop - ensure sidebar is visible and main content has proper margin */
@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0) !important;
        position: fixed;
        left: 0;
        top: 0;
    }

    .main-content {
        margin-left: var(--sidebar-width) !important;
    }

    .mobile-overlay {
        display: none !important;
    }
}

/* Tablet portrait and below (768px) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding: var(--space-2);
        padding-top: calc(var(--space-2) + 60px); /* Add space for mobile menu toggle button */
    }

    .page-header {
        margin-top: 0; /* Remove extra margin since we have padding-top on main-content */
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-header {
        padding: var(--space-3);
        margin-bottom: var(--space-3);
    }

    .page-header.flex {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .page-title {
        font-size: var(--text-xl);
    }

    .login-box {
        padding: var(--space-3);
        max-width: 100%;
    }

    .login-box h1 {
        font-size: var(--text-2xl);
    }

    .content-section {
        padding: var(--space-2);
        margin-bottom: var(--space-2);
    }

    .modal-content {
        padding: var(--space-3);
        margin: var(--space-2);
        max-width: calc(100% - var(--space-4));
        max-height: calc(100vh - var(--space-4));
    }

    /* Table responsiveness */
    table {
        font-size: var(--text-xs);
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table thead,
    table tbody,
    table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    th, td {
        padding: var(--space-1) var(--space-2);
        word-wrap: break-word;
    }

    /* Responsive table wrapper */
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    .stat-card {
        padding: var(--space-2);
    }

    .stat-value {
        font-size: var(--text-2xl);
    }

    /* Stack buttons vertically on mobile */
    .modal-footer {
        flex-direction: column-reverse;
        gap: var(--space-2);
    }

    .modal-footer button {
        width: 100%;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: var(--space-2);
    }

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

    /* Flex layouts */
    .flex {
        flex-wrap: wrap;
    }

    .flex.justify-between:not(.flex-wrap) {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .flex.gap-2:not(.flex-nowrap),
    .flex.gap-3:not(.flex-nowrap) {
        flex-direction: column;
    }

    /* Responsive grid layouts */
    .grid-2fr-1fr {
        grid-template-columns: 1fr !important;
    }

    /* Page header actions */
    .page-header .flex.justify-between {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .page-header .flex.justify-between > button {
        width: 100%;
    }

    /* Map responsive */
    #violationMap {
        height: 400px !important;
    }

    /* Search inputs */
    .flex.gap-2.items-end {
        flex-direction: column;
        align-items: stretch;
    }

    .flex.gap-2.items-end > * {
        width: 100%;
    }

    /* Card layouts with flex */
    .bg-white.p-4.rounded {
        padding: var(--space-2);
    }

    /* Video detail page responsive */
    .video-detail-container {
        flex-direction: column;
    }

    /* Violation detail two-column layout */
    .violation-detail-grid {
        grid-template-columns: 1fr !important;
    }

    /* Violation detail cards */
    .violation-detail-card {
        padding: var(--space-2);
    }

    .violation-detail-card h2 {
        font-size: var(--text-lg);
    }

    /* Violation card headers with buttons */
    .violation-card-header-mobile {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .violation-card-header-mobile .violation-action-btn {
        width: 100%;
    }

    /* Property and violation info grids */
    .display-grid.gap-2 {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    /* Button groups in violation detail */
    .flex.gap-2 {
        flex-direction: column;
    }

    .flex.gap-2 button {
        width: 100%;
    }

    /* Button groups */
    button + button {
        margin-top: var(--space-2);
    }

    /* Images and media */
    img {
        max-width: 100%;
        height: auto;
    }

    video {
        max-width: 100%;
        height: auto;
    }

    iframe {
        max-width: 100%;
    }

    /* Typography adjustments */
    h1 {
        font-size: var(--text-2xl);
    }

    h2 {
        font-size: var(--text-xl);
    }

    h3 {
        font-size: var(--text-lg);
    }
}

/* Mobile landscape and below (640px) */
@media (max-width: 640px) {
    .main-content {
        padding: var(--space-2);
        padding-top: calc(var(--space-2) + 60px); /* Maintain space for mobile menu toggle */
    }

    .page-header {
        padding: var(--space-2);
    }

    .content-section {
        padding: var(--space-2);
    }

    .stat-card {
        padding: var(--space-2);
    }

    .modal-content {
        padding: var(--space-2);
        margin: var(--space-2);
        border-radius: 12px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .stats-grid {
        gap: var(--space-2);
    }
}

/* Small mobile (480px) */
@media (max-width: 480px) {
    :root {
        --text-base: 14px;
        --text-sm: 12px;
        --text-xs: 11px;
    }

    .main-content {
        padding: var(--space-1);
        padding-top: calc(var(--space-2) + 60px); /* Maintain space for mobile menu toggle */
    }

    .page-header {
        padding: var(--space-2);
        border-radius: 12px;
    }

    .content-section {
        padding: var(--space-2);
        border-radius: 12px;
    }

    .stat-card {
        padding: var(--space-2);
    }

    .stat-value {
        font-size: var(--text-xl);
    }

    .page-title {
        font-size: var(--text-lg);
    }

    .login-box {
        padding: var(--space-3);
        border-radius: 12px;
    }

    .login-box h1 {
        font-size: var(--text-xl);
    }

    .modal-content {
        padding: var(--space-2);
        margin: var(--space-1);
        border-radius: 12px;
    }

    th, td {
        padding: 6px 8px;
        font-size: 11px;
    }

    button {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
    }

    .btn-pad-sm,
    .btn-pad-md {
        padding: var(--space-2) var(--space-3);
    }
}

/* Large screens (1280px+) */
@media (min-width: 1280px) {
    .main-content {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
    }

    .modal-content {
        max-width: 700px;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 1001;
    background: var(--color-primary);
    color: white;
    padding: var(--space-2);
    border-radius: var(--space-1);
    box-shadow: var(--shadow-md);
    min-width: 44px;
    min-height: 44px;
    border: none;
    cursor: pointer;
    transition: all var(--timing-base) var(--ease-out);
}

/* Ensure mobile menu toggle doesn't overlap on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

.mobile-menu-toggle:hover {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    transition: opacity var(--timing-base) var(--ease-out);
}

@media (max-width: 768px) {
    .mobile-overlay.active {
        display: block;
        animation: fadeIn var(--timing-base) var(--ease-out);
    }
}

/* Prevent body scroll when sidebar is open on mobile */
@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    :root {
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
        --shadow-xl: none;
    }

    .sidebar,
    .page-header button,
    .mobile-menu-toggle,
    .modal,
    button {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 15mm !important;
    }

    .page-content {
        padding: 0 !important;
    }

    table thead {
        display: table-header-group;
    }

    tr {
        page-break-inside: avoid;
    }

    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    .content-section {
        box-shadow: none;
        border: 1px solid var(--color-border);
        page-break-inside: avoid;
        margin-bottom: var(--space-3) !important;
    }

    .page-header {
        box-shadow: none;
        border-bottom: 2px solid var(--color-border);
    }
}

/* Navigation Micro-Interactions */
    .nav-item {
        position: relative;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-item::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 24px;
        background: var(--color-primary);
        border-radius: 0 4px 4px 0;
        transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-item:hover::before {
        width: 4px;
    }

    .nav-item.active::before {
        width: 4px;
    }

    .nav-emoji {
        display: inline-block;
        transition: transform 0.2s ease;
    }

    .nav-item:hover .nav-emoji {
        transform: scale(1.2);
    }
    

    /* Premium Stat Card Enhancements */
    .stat-card.primary {
        background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
        border-top: 3px solid var(--color-primary);
    }

    .stat-card.success {
        background: linear-gradient(135deg, #ffffff 0%, #d1fae5 100%);
        border-top: 3px solid var(--color-success);
    }

    .stat-card.warning {
        background: linear-gradient(135deg, #ffffff 0%, #fef3c7 100%);
        border-top: 3px solid var(--color-warning);
    }

    .stat-card.purple {
        background: linear-gradient(135deg, #ffffff 0%, #ede9fe 100%);
        border-top: 3px solid var(--color-purple);
    }

    .stat-icon-wrapper {
        position: relative;
    }

    .stat-icon-wrapper::before {
        content: '';
        position: absolute;
        inset: -8px;
        background: currentColor;
        opacity: 0.08;
        border-radius: 50%;
        transition: all 0.3s ease;
    }

    .stat-card:hover .stat-icon-wrapper::before {
        opacity: 0.15;
        transform: scale(1.1);
    }
    

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

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

    .skeleton-text {
        height: 12px;
        border-radius: 4px;
        margin-bottom: 8px;
    }

    .skeleton-title {
        height: 20px;
        border-radius: 4px;
        width: 60%;
        margin-bottom: 12px;
    }

    .skeleton-card {
        height: 120px;
        border-radius: 8px;
    }
    

    /* Toast Notifications */
    .toast {
        min-width: 300px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        padding: 16px 20px;
        display: flex;
        align-items: center;
        gap: 12px;
        animation: slideIn 0.3s ease-out;
        border-left: 4px solid var(--color-success);
    }

    .toast.error {
        border-left-color: var(--color-error);
    }

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

    .toast.info {
        border-left-color: #3b82f6;
    }

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

    .toast-icon {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
    }

    .toast-content {
        flex: 1;
    }

    .toast-title {
        font-weight: 600;
        font-size: 14px;
        color: var(--color-text);
        margin-bottom: 4px;
    }

    .toast-message {
        font-size: 13px;
        color: var(--color-text-light);
    }
    

    /* Visual Separators */
    .section-divider {
        height: 1px;
        background: linear-gradient(90deg, transparent, var(--color-border), transparent);
        margin: var(--space-4) 0;
    }

    .content-divider {
        display: flex;
        align-items: center;
        text-align: center;
        margin: var(--space-3) 0;
        color: var(--color-text-lighter);
        font-size: var(--text-sm);
    }

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

    .content-divider::before {
        margin-right: var(--space-2);
    }

    .content-divider::after {
        margin-left: var(--space-2);
    }
    

    /* Enhanced Badge System */
    .badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 0.025em;
        text-transform: uppercase;
    }

    .badge-primary {
        background: var(--color-primary-bg);
        color: var(--color-primary-dark);
        border: 1px solid var(--color-primary-border);
    }

    .badge-success {
        background: var(--color-success-bg);
        color: var(--color-success-dark);
        border: 1px solid var(--color-success-border);
    }

    .badge-warning {
        background: var(--color-warning-bg);
        color: var(--color-warning-dark);
        border: 1px solid var(--color-warning-border);
    }

    .badge-error, .badge-danger {
        background: var(--color-error-bg);
        color: var(--color-error-dark);
        border: 1px solid var(--color-error-border);
    }

    .badge-icon {
        width: 12px;
        height: 12px;
    }
    
</style>
