        :root {
            --primary: #6366f1;
            --primary-hover: #4f46e5;
            --bg-dark: #0f172a;
            --bg-card: #1e293b;
            --text-main: #f8fafc;
            --text-muted: #94a3b8;
            --border: #334155;
            --success: #10b981;
            --danger: #ef4444;
            --warning: #f59e0b;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
        }

        body {
            background-color: var(--bg-dark);
            color: var(--text-main);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* Utils */
        .hidden {
            display: none !important;
        }

        .flex {
            display: flex;
        }

        .flex-col {
            flex-direction: column;
        }

        .items-center {
            align-items: center;
        }

        .justify-between {
            justify-content: space-between;
        }

        .justify-center {
            justify-content: center;
        }

        .gap-2 {
            gap: 0.5rem;
        }

        .gap-4 {
            gap: 1rem;
        }

        .p-4 {
            padding: 1rem;
        }

        .p-6 {
            padding: 1.5rem;
        }

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

        .mt-4 {
            margin-top: 1rem;
        }

        .text-sm {
            font-size: 0.875rem;
        }

        .font-bold {
            font-weight: 700;
        }

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

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

        .w-full {
            width: 100%;
        }

        /* Components */
        .btn {
            background: var(--primary);
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
        }

        .btn:hover {
            background: var(--primary-hover);
            transform: translateY(-1px);
        }

        .btn-outline {
            background: transparent;
            border: 1px solid var(--primary);
            color: white;
        }

        .btn-outline:hover {
            background: rgba(99, 102, 241, 0.1);
        }

        .btn-danger {
            background: var(--danger);
        }

        .btn-danger:hover {
            background: #dc2626;
        }

        .input-group {
            margin-bottom: 1rem;
        }

        .input-label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--text-muted);
            font-size: 0.875rem;
        }

        .form-input,
        .form-select {
            width: 100%;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text-main);
            padding: 0.75rem;
            border-radius: 0.5rem;
            transition: border-color 0.2s;
        }

        .form-input:focus,
        .form-select:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
        }

        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 1rem;
            padding: 2rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }

        /* Layout */
        .app-container {
            display: flex;
            flex: 1;
        }

        .sidebar {
            width: 250px;
            background: var(--bg-card);
            border-right: 1px solid var(--border);
            padding: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .main-content {
            flex: 1;
            padding: 2rem;
            overflow-y: auto;
        }

        .nav-item {
            padding: 0.75rem 1rem;
            border-radius: 0.5rem;
            color: var(--text-muted);
            cursor: pointer;
            transition: all 0.2s;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .nav-item:hover,
        .nav-item.active {
            background: rgba(99, 102, 241, 0.1);
            color: var(--primary);
        }

        /* Table */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }

        .data-table th,
        .data-table td {
            text-align: left;
            padding: 1rem;
            border-bottom: 1px solid var(--border);
        }

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

        .data-table tr:hover {
            background: rgba(255, 255, 255, 0.02);
        }

        /* Login */
        .auth-container {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            background: linear-gradient(135deg, var(--bg-dark) 0%, #1e1b4b 100%);
        }

        .auth-box {
            width: 100%;
            max-width: 400px;
        }

        /* Modal */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(4px);
            z-index: 50;
        }

        .modal-content {
            background: var(--bg-card);
            width: 90%;
            max-width: 800px;
            max-height: 90vh;
            overflow-y: auto;
            padding: 2rem;
            border-radius: 1rem;
            border: 1px solid var(--border);
        }

        /* Grid Form Layout */
        .grid-form {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1rem;
        }

        .grid-form.cols-3 {
            grid-template-columns: 1fr 1fr 1fr;
        }

        .grid-form .input-group {
            margin-bottom: 0;
            /* Let gap handle spacing */
        }

        @media (max-width: 768px) {

            .grid-form,
            .grid-form.cols-3 {
                grid-template-columns: 1fr;
            }

            .grid-form .input-group {
                margin-bottom: 1rem;
            }
        }

        /* Animations */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .fade-in {
            animation: fadeIn 0.3s ease-out;
        }

        .toast {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            padding: 1rem 2rem;
            border-radius: 0.5rem;
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-main);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            z-index: 100;
            transform: translateY(100px);
            transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .toast.show {
            transform: translateY(0);
        }

        .toast.success {
            border-left: 4px solid var(--success);
        }

        .toast.error {
            border-left: 4px solid var(--danger);
        }

        /* Action Buttons Desktop */
        .action-buttons-wrapper {
            display: flex;
            gap: 0.5rem;
            align-items: center;
        }

        /* Enforce right alignment on desktop */
        @media (min-width: 769px) {
            #header-actions {
                display: flex;
                justify-content: flex-end;
                flex: 1;
            }
        }

        .action-btn {
            white-space: nowrap;
        }

        /* Responsive Sidebar & Overlay */
        .menu-btn {
            display: none;
            background: transparent;
            border: none;
            color: var(--text-main);
            font-size: 1.5rem;
            cursor: pointer;
            padding: 0.5rem;
        }

        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 49;
            backdrop-filter: blur(2px);
            opacity: 0;
            transition: opacity 0.3s;
        }

        .sidebar-overlay.show {
            display: block;
            opacity: 1;
        }

        @media (max-width: 768px) {
            .menu-btn {
                display: block;
            }

            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                bottom: 0;
                z-index: 50;
                transform: translateX(-100%);
                transition: transform 0.3s ease-in-out;
                box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
            }

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

            .main-content {
                width: 100%;
                padding: 1rem;
            }

            /* Ensure forms stack nicely if not already covered */
            .grid-form {
                grid-template-columns: 1fr !important;
            }

            .modal-content {
                width: 95%;
                padding: 1rem;
            }

            /* Smaller Buttons for Mobile */
            .btn,
            .btn-outline,
            .btn-danger {
                padding: 0.5rem 1rem !important;
                font-size: 0.875rem !important;
                /* text-sm */
            }

            /* Header Specific Mobile Styles */
            .main-dashboard-header {
                flex-direction: column !important;
                align-items: stretch !important;
                gap: 1rem !important;
            }

            .main-dashboard-header>div:first-child {
                width: 100%;
                justify-content: flex-start;
            }
        }

        /* Analytics Responsive */
        .analytics-layout {
            display: flex;
            gap: 1rem;
            height: calc(100vh - 150px);
        }

        .analytics-sidebar {
            width: 250px;
            display: flex;
            flex-direction: column;
            padding: 1rem;
            flex-shrink: 0;
        }

        @media (max-width: 768px) {
            .analytics-layout {
                flex-direction: column;
                height: auto;
            }

            .analytics-sidebar {
                width: 100%;
                height: auto;
                max-height: 200px;
            }

            #header-actions .btn,
            #header-actions .btn-outline {
                /* Remove forced flex: 1, let them size naturally or via grid */
                width: 100%;
                margin-bottom: 0.5rem;
                justify-content: center;
            }

            #header-actions {
                display: block;
                /* Let wrapper handle layout */
            }

            .action-buttons-wrapper {
                display: grid;
                grid-template-columns: 1fr 1fr;
                /* 2 cols on mobile */
                gap: 0.5rem;
                width: 100%;
            }

            .action-buttons-wrapper .btn-primary-mobile {
                grid-column: 1 / -1;
                /* Make primary action full width */
            }

            /* Analytics Controls Mobile */
            .analytics-controls {
                flex-direction: column !important;
                align-items: stretch !important;
                gap: 0.5rem !important;
                margin-top: 1rem;
            }

            .analytics-spacer {
                display: none !important;
            }

            .analytics-controls .btn,
            .analytics-controls .btn-outline {
                width: 100%;
            }

            .analytics-controls .input-group {
                min-width: auto !important;
                width: 100%;
                margin-bottom: 0.5rem;
            }

            /* Analytics Layout Fixes */
            .analytics-main-wrapper {
                overflow: visible !important;
                height: auto !important;
            }

            .analytics-results-card {
                flex: none !important;
                height: auto !important;
                min-height: 300px;
                overflow: visible !important;
            }
        }

        /* Analytics Base Styles */
        .analytics-main-wrapper {
            display: flex;
            flex-direction: column;
            width: 100%;
            overflow: hidden;
            gap: 1rem;
        }

        .analytics-results-card {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 0;
            overflow: hidden;
        }
