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

        :root {
            /* TakeUp Funnel Theme - Green Accent */
            --primary: #00d672;
            --primary-dark: #00b85f;
            --primary-light: #00e87d;
            --success: #00d672;
            --success-light: #00e87d;
            --warning: #FFC700;
            --danger: #ff4444;
            --danger-light: #ff6666;

            --bg-dark: #0c0c0e;
            --bg-darker: #08080a;
            --bg-card: #151518;
            --bg-card-hover: #1e1e22;
            --bg-elevated: #2a2a30;

            --text: #f5f5f7;
            --text-secondary: #adadb8;
            --text-muted: #8a8a96;

            --border: #3d3d45;
            --border-light: #4d4d55;

            --sidebar-width: 260px;
            --header-height: 80px;

            --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
            --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
            --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
            --shadow-xl: 0 25px 50px rgba(0,0,0,0.6);

            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 0.75rem;
            --radius-xl: 1rem;
        }

        body {
            font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
            background: var(--bg-dark);
            color: var(--text);
            min-height: 100vh;
            overflow-x: hidden;
        }

        /* ==================== ANIMATIONS ==================== */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

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

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

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

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

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

        .animate-fade { animation: fadeIn 0.3s ease; }
        .animate-slide { animation: slideIn 0.3s ease; }
        .animate-slide-up { animation: slideUp 0.4s ease; }

        /* ==================== LOGIN SCREEN ==================== */
        .login-screen {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background:
                radial-gradient(ellipse at top left, rgba(0, 214, 114, 0.15) 0%, transparent 50%),
                radial-gradient(ellipse at bottom right, rgba(0, 214, 114, 0.1) 0%, transparent 50%),
                var(--bg-darker);
        }

        .login-container {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            padding: 3rem;
            width: 100%;
            max-width: 420px;
            box-shadow: var(--shadow-xl);
            animation: slideUp 0.5s ease;
        }

        .login-logo {
            text-align: center;
            margin-bottom: 2.5rem;
        }

        .login-logo-icon {
            width: 80px;
            height: 80px;
            object-fit: contain;
            border-radius: var(--radius-lg);
            margin: 0 auto 1rem;
            display: block;
        }

        .login-logo h1 {
            font-size: 1.75rem;
            font-weight: 700;
            background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .login-logo p {
            color: var(--text-muted);
            font-size: 0.875rem;
            margin-top: 0.5rem;
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-label {
            display: block;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: 0.5rem;
        }

        .form-input {
            width: 100%;
            padding: 0.875rem 1rem;
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            background: var(--bg-darker);
            color: var(--text);
            font-size: 1rem;
            font-family: inherit;
            transition: all 0.2s;
        }

        .form-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(0, 214, 114, 0.2);
        }

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

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: var(--radius-md);
            font-size: 0.875rem;
            font-weight: 600;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            box-shadow: 0 4px 12px rgba(0, 214, 114, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(0, 214, 114, 0.4);
        }

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

        .btn-primary:disabled {
            background: var(--border);
            box-shadow: none;
            cursor: not-allowed;
            transform: none;
        }

        .btn-secondary {
            background: var(--bg-elevated);
            color: var(--text);
            border: 1px solid var(--border);
        }

        .btn-secondary:hover {
            background: var(--bg-card-hover);
            border-color: var(--border-light);
        }

        .btn-danger {
            background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
            color: white;
        }

        .btn-danger:hover {
            box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
        }

        .btn-ghost {
            background: transparent;
            color: var(--text-secondary);
        }

        .btn-ghost:hover {
            background: var(--bg-elevated);
            color: var(--text);
        }

        .btn-sm {
            padding: 0.5rem 1rem;
            font-size: 0.8125rem;
        }

        .btn-lg {
            padding: 1rem 2rem;
            font-size: 1rem;
        }

        .btn-block {
            width: 100%;
        }

        .btn-icon {
            padding: 0.5rem;
            width: 36px;
            height: 36px;
        }

        .login-btn {
            width: 100%;
            padding: 1rem;
            font-size: 1rem;
            margin-top: 0.5rem;
        }

        .alert {
            padding: 0.875rem 1rem;
            border-radius: var(--radius-md);
            font-size: 0.875rem;
            margin-bottom: 1.5rem;
            display: none;
            animation: slideIn 0.3s ease;
        }

        .alert.show {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .alert-error {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid var(--danger);
            color: var(--danger-light);
        }

        .alert-success {
            background: rgba(0, 214, 114, 0.1);
            border: 1px solid var(--success);
            color: var(--success-light);
        }

        /* ==================== APP LAYOUT ==================== */
        .app-screen {
            display: none;
            min-height: 100vh;
        }

        .app-screen.active {
            display: flex;
        }

        /* Sidebar */
        .sidebar {
            width: var(--sidebar-width);
            background: var(--bg-card);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            z-index: 50;
        }

        .sidebar-header {
            padding: 1.25rem 1.5rem;
            border-bottom: 1px solid var(--border);
        }

        .sidebar-logo {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .sidebar-logo-icon {
            width: 40px;
            height: 40px;
            border-radius: var(--radius-md);
            object-fit: contain;
        }

        .sidebar-logo-text {
            font-size: 1.125rem;
            font-weight: 700;
        }

        .sidebar-nav {
            flex: 1;
            padding: 1rem 0;
            overflow-y: auto;
        }

        .nav-section {
            margin-bottom: 1.5rem;
        }

        .nav-section-title {
            padding: 0.5rem 1.5rem;
            font-size: 0.6875rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--text-muted);
        }

        .nav-item {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem 1.5rem;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            border-left: 3px solid transparent;
        }

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

        .nav-item.active {
            background: rgba(0, 214, 114, 0.1);
            color: var(--primary-light);
            border-left-color: var(--primary);
        }

        .nav-item svg {
            width: 20px;
            height: 20px;
            opacity: 0.8;
        }

        .nav-item.active svg {
            opacity: 1;
        }

        .nav-badge {
            margin-left: auto;
            padding: 0.125rem 0.5rem;
            background: var(--primary);
            color: white;
            font-size: 0.6875rem;
            font-weight: 600;
            border-radius: 9999px;
        }

        .sidebar-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--border);
        }

        .subscription-info {
            padding: 0.75rem;
            background: var(--bg-darker);
            border-radius: var(--radius-md);
            margin-bottom: 0.75rem;
            font-size: 0.8125rem;
        }

        .subscription-plan {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.5rem;
        }

        .plan-label {
            color: var(--text-muted);
        }

        .plan-name {
            font-weight: 600;
            color: var(--primary);
        }

        .device-limit {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: var(--text-secondary);
        }

        .device-limit svg {
            color: var(--text-muted);
        }

        .device-limit.warning {
            color: var(--warning);
        }

        .device-limit.warning svg {
            color: var(--warning);
        }

        .upgrade-prompt {
            margin-top: 0.75rem;
            text-align: center;
        }

        .upgrade-prompt .btn {
            width: 100%;
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem;
            background: var(--bg-darker);
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: background 0.2s;
        }

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

        .user-avatar {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
            border-radius: var(--radius-md);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 0.875rem;
        }

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

        .user-name {
            font-size: 0.875rem;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

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

        /* Main Content */
        .main-content {
            flex: 1;
            margin-left: var(--sidebar-width);
            min-height: 100vh;
            background: var(--bg-dark);
        }

        /* Header */
        .header {
            height: var(--header-height);
            background: var(--bg-dark);
            border-bottom: 1px solid var(--border);
            padding: 0 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 40;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .page-title {
            font-size: 1.25rem;
            font-weight: 600;
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .connection-status {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            margin: 0 0.75rem 0.5rem 0.75rem;
            border-radius: var(--radius);
            font-size: 0.8125rem;
            font-weight: 500;
        }

        .connection-status.online {
            background: rgba(0, 214, 114, 0.1);
            color: var(--success);
        }

        .connection-status.offline {
            background: rgba(239, 68, 68, 0.1);
            color: var(--danger);
        }

        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: currentColor;
            animation: pulse 2s infinite;
        }

        /* Page Container */
        .page-container {
            padding: 2rem;
            display: none;
        }

        .page-container.active {
            display: block;
            animation: fadeIn 0.3s ease;
        }

        /* ==================== DASHBOARD ==================== */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
            transition: all 0.2s;
        }

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

        .stat-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1rem;
        }

        .stat-icon {
            width: 48px;
            height: 48px;
            border-radius: var(--radius-md);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
        }

        .stat-icon.blue {
            background: rgba(0, 214, 114, 0.1);
            color: var(--primary-light);
        }

        .stat-icon.green {
            background: rgba(0, 214, 114, 0.1);
            color: var(--success);
        }

        .stat-icon.yellow {
            background: rgba(245, 158, 11, 0.1);
            color: var(--warning);
        }

        .stat-icon.red {
            background: rgba(239, 68, 68, 0.1);
            color: var(--danger);
        }

        .stat-trend {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .stat-trend.up {
            color: var(--success);
        }

        .stat-trend.down {
            color: var(--danger);
        }

        .stat-value {
            font-size: 2rem;
            font-weight: 700;
            margin-bottom: 0.25rem;
        }

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

        .dashboard-grid {
            display: grid;
            grid-template-columns: 2fr 1fr;
            gap: 1.5rem;
        }

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

        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            overflow: hidden;
        }

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

        .card-title {
            font-size: 1rem;
            font-weight: 600;
        }

        .card-body {
            padding: 1.5rem;
        }

        .chart-container {
            height: 300px;
            position: relative;
        }

        /* Activity List */
        .activity-list {
            display: flex;
            flex-direction: column;
        }

        .activity-item {
            display: flex;
            align-items: flex-start;
            gap: 1rem;
            padding: 1rem 0;
            border-bottom: 1px solid var(--border);
        }

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

        .activity-icon {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            flex-shrink: 0;
        }

        .activity-icon.session {
            background: rgba(0, 214, 114, 0.1);
            color: var(--primary-light);
        }

        .activity-icon.user {
            background: rgba(0, 214, 114, 0.1);
            color: var(--success);
        }

        .activity-icon.device {
            background: rgba(245, 158, 11, 0.1);
            color: var(--warning);
        }

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

        .activity-text {
            font-size: 0.875rem;
            margin-bottom: 0.25rem;
        }

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

        /* ==================== DATA TABLES ==================== */
        .table-container {
            overflow-x: auto;
        }

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

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

        .data-table td {
            padding: 1rem 1.5rem;
            font-size: 0.875rem;
            border-bottom: 1px solid var(--border);
            vertical-align: middle;
        }

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

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

        .badge {
            display: inline-flex;
            align-items: center;
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .badge-success {
            background: rgba(0, 214, 114, 0.1);
            color: var(--success);
        }

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

        .badge-danger {
            background: rgba(239, 68, 68, 0.1);
            color: var(--danger);
        }

        .badge-info {
            background: rgba(0, 214, 114, 0.1);
            color: var(--primary-light);
        }

        .badge-neutral {
            background: var(--bg-elevated);
            color: var(--text-secondary);
        }

        .badge-secondary {
            background: var(--bg-elevated);
            color: var(--text-secondary);
        }

        .badge-primary {
            background: rgba(0, 214, 114, 0.15);
            color: var(--primary);
        }

        /* Action Buttons */
        .action-buttons {
            display: flex;
            gap: 0.5rem;
            justify-content: flex-end;
        }

        .icon-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 6px;
            border: 1px solid var(--border);
            background: var(--bg-elevated);
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .icon-btn:hover {
            background: var(--primary);
            border-color: var(--primary);
            color: #000;
        }

        .icon-btn.danger:hover {
            background: var(--danger);
            border-color: var(--danger);
            color: #fff;
        }

        .icon-btn svg {
            width: 16px;
            height: 16px;
        }

        /* Toggle Switch */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 44px;
            height: 24px;
            cursor: pointer;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--text-muted);
            transition: 0.3s;
            border-radius: 24px;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 18px;
            width: 18px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: 0.3s;
            border-radius: 50%;
        }

        .toggle-switch input:checked + .toggle-slider {
            background-color: var(--primary);
        }

        .toggle-switch input:checked + .toggle-slider:before {
            transform: translateX(20px);
        }

        /* Toolbar */
        .table-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            margin-bottom: 1.5rem;
            flex-wrap: wrap;
        }

        .search-box {
            position: relative;
            width: 300px;
        }

        .search-box input {
            width: 100%;
            padding: 0.625rem 1rem 0.625rem 2.5rem;
            background: var(--bg-darker);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text);
            font-size: 0.875rem;
        }

        .search-box input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .search-box svg {
            position: absolute;
            left: 0.75rem;
            top: 50%;
            transform: translateY(-50%);
            width: 18px;
            height: 18px;
            color: var(--text-muted);
        }

        .filter-group {
            display: flex;
            gap: 0.5rem;
        }

        .select-wrapper {
            position: relative;
        }

        .select-wrapper select {
            appearance: none;
            padding: 0.625rem 2.5rem 0.625rem 1rem;
            background: var(--bg-darker);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text);
            font-size: 0.875rem;
            cursor: pointer;
        }

        .select-wrapper::after {
            content: '';
            position: absolute;
            right: 1rem;
            top: 50%;
            transform: translateY(-50%);
            border: 4px solid transparent;
            border-top-color: var(--text-muted);
        }

        /* Pagination */
        .pagination {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--border);
        }

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

        .pagination-controls {
            display: flex;
            gap: 0.25rem;
        }

        .pagination-btn {
            padding: 0.5rem 0.75rem;
            background: var(--bg-darker);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text);
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .pagination-btn:hover:not(:disabled) {
            background: var(--bg-elevated);
            border-color: var(--border-light);
        }

        .pagination-btn.active {
            background: var(--primary);
            border-color: var(--primary);
        }

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

        /* ==================== CONFIG TABS ==================== */
        .config-tabs-container {
            display: flex;
            gap: 0.25rem;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 1.5rem;
            overflow-x: auto;
            width: 100%;
            max-width: calc(100vw - var(--sidebar-width) - 4rem);
            min-width: 0;
            scrollbar-width: thin;
            scrollbar-color: var(--border-color) transparent;
            padding-bottom: 2px;
        }

        .config-tabs-container::-webkit-scrollbar {
            height: 4px;
        }

        .config-tabs-container::-webkit-scrollbar-track {
            background: transparent;
        }

        .config-tabs-container::-webkit-scrollbar-thumb {
            background: var(--border-color);
            border-radius: 2px;
        }

        .config-tab {
            display: inline-flex;
            align-items: center;
            padding: 0.625rem 1rem;
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            transition: all 0.15s ease;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .config-tab:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .config-tab.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
        }

        .config-tab-content {
            display: none;
        }

        .config-tab-content.active {
            display: block;
        }

        /* ==================== REMOTE CONTROL ==================== */
        .remote-layout {
            display: grid;
            grid-template-columns: 320px 1fr;
            gap: 1.5rem;
            height: calc(100vh - var(--header-height) - 4rem);
        }

        @media (max-width: 1024px) {
            .remote-layout {
                grid-template-columns: 1fr;
                height: auto;
            }
        }

        .devices-panel {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .connect-form {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
        }

        .connect-form h3 {
            font-size: 0.875rem;
            font-weight: 600;
            margin-bottom: 1rem;
        }

        .connect-input-group {
            display: flex;
            gap: 0.5rem;
        }

        .code-input {
            flex: 1;
            min-width: 0;
            padding: 0.875rem 1rem;
            background: var(--bg-darker);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text);
            font-size: 0.75rem;
            font-weight: 600;
            text-align: center;
            letter-spacing: 0.2em;
            font-family: monospace;
            box-sizing: border-box;
        }

        .code-input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .devices-list {
            flex: 1;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .devices-list-header {
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .devices-list-header h3 {
            font-size: 0.875rem;
            font-weight: 600;
        }

        .devices-list-body {
            flex: 1;
            overflow-y: auto;
            padding: 0.5rem;
        }

        .device-card {
            padding: 1rem;
            background: var(--bg-darker);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            margin-bottom: 0.5rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .device-card:hover {
            border-color: var(--primary);
            background: var(--bg-elevated);
        }

        .device-card.active {
            border-color: var(--success);
            background: rgba(0, 214, 114, 0.05);
        }

        .device-card.connected {
            border-color: var(--primary);
            background: rgba(0, 214, 114, 0.05);
        }

        .device-card.offline {
            opacity: 0.7;
        }

        .device-card.offline:hover {
            background: var(--bg-card);
        }

        .device-card.selected {
            border-color: var(--primary);
            background: var(--bg-elevated);
            animation: pulse-border 2s ease-in-out infinite;
        }

        @keyframes pulse-border {
            0%, 100% {
                border-color: var(--primary);
                box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
            }
            50% {
                border-color: var(--success);
                box-shadow: 0 0 8px 2px rgba(16, 185, 129, 0.2);
            }
        }

        /* Agent status dot (online/offline indicator) */
        .agent-status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 8px;
            vertical-align: middle;
        }

        .agent-status-dot.online {
            background-color: var(--success);
            box-shadow: 0 0 6px var(--success);
        }

        .agent-status-dot.offline {
            background-color: var(--danger);
        }

        .power-btn {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            flex-shrink: 0;
        }

        .power-btn.off {
            background: var(--bg-elevated);
            color: var(--text-muted);
        }

        .power-btn.off:hover {
            background: var(--primary);
            color: white;
            box-shadow: 0 0 8px rgba(0, 214, 114, 0.5);
        }

        .power-btn.on {
            background: var(--primary);
            color: white;
            box-shadow: 0 0 12px rgba(0, 214, 114, 0.6);
            animation: pulse-glow 2s ease-in-out infinite;
        }

        .power-btn.on:hover {
            background: var(--danger);
            box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
            animation: none;
        }

        @keyframes pulse-glow {
            0%, 100% { box-shadow: 0 0 8px rgba(0, 214, 114, 0.4); }
            50% { box-shadow: 0 0 16px rgba(0, 214, 114, 0.8); }
        }

        .regenerate-btn {
            width: 18px;
            height: 18px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-elevated);
            color: var(--text-muted);
            transition: all 0.2s ease;
            flex-shrink: 0;
        }

        .regenerate-btn:hover {
            background: var(--warning);
            color: white;
        }

        .regenerate-btn.loading {
            animation: spin 1s linear infinite;
            pointer-events: none;
        }

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

        .delete-device-btn {
            width: 18px;
            height: 18px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-elevated);
            color: var(--text-muted);
            transition: all 0.15s ease;
        }

        .delete-device-btn:hover {
            background: var(--danger);
            color: white;
        }

        .session-badge {
            font-size: 0.65rem;
            padding: 2px 6px;
            background: var(--primary);
            color: white;
            border-radius: 4px;
            margin-left: auto;
        }

        .device-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 0.5rem;
        }

        .device-name {
            font-weight: 600;
            font-size: 0.9375rem;
        }

        .device-code {
            font-family: monospace;
            font-size: 0.8125rem;
            padding: 0.25rem 0.5rem;
            background: rgba(0, 214, 114, 0.1);
            color: var(--primary-light);
            border-radius: var(--radius-sm);
        }

        .device-meta {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            gap: 1rem;
            font-size: 0.8125rem;
            color: var(--text-muted);
        }

        .device-meta span {
            display: flex;
            align-items: center;
            gap: 0.25rem;
        }

        /* Viewer */
        .viewer-panel {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            min-height: 0; /* Permette al panel di shrinkare nel grid */
        }

        .viewer-placeholder {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            padding: 3rem;
            text-align: center;
        }

        .viewer-placeholder svg {
            width: 80px;
            height: 80px;
            margin-bottom: 1.5rem;
            opacity: 0.3;
        }

        .viewer-placeholder h3 {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: 0.5rem;
        }

        .screen-wrapper {
            flex: 1;
            min-height: 0; /* Permette allo screen di shrinkare nel flex container */
            background: #000;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }

        #remoteScreen {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
        }

        #remoteCanvas {
            display: block;
            flex-shrink: 0; /* Prevent flexbox from shrinking canvas */
            /* Dimensions calculated by compositor.fitToContainer() */
            /* Centering handled by flexbox parent */
            /* CRITICAL: Sharp rendering for remote desktop - prevents blurry text */
            image-rendering: -webkit-optimize-contrast; /* Safari */
            image-rendering: crisp-edges; /* Firefox */
            image-rendering: pixelated; /* Chrome/Edge - best for remote desktop */
        }

        #remoteVideo {
            display: none; /* Shown when WebRTC active */
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        .stream-stats {
            position: absolute;
            top: 12px;
            right: 16px;
            background: transparent;
            color: #22c55e;
            font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
            font-size: 32px;
            font-weight: 700;
            padding: 0;
            pointer-events: none;
            z-index: 10;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
        }

        .stream-stats.buffering {
            color: #fbbf24; /* Yellow when buffering */
        }

        .stream-stats.underrun {
            color: #ef4444; /* Red when low buffer */
        }

        .viewer-toolbar {
            flex-shrink: 0; /* Non comprimere mai la toolbar */
            padding: 0.75rem 1rem;
            background: var(--bg-darker);
            border-top: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .toolbar-group {
            display: flex;
            gap: 0.5rem;
        }

        .toolbar-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text-secondary);
            font-size: 0.8125rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .toolbar-btn:hover {
            background: var(--bg-elevated);
            color: var(--text);
            border-color: var(--border-light);
        }

        .toolbar-btn.active {
            background: var(--primary);
            border-color: var(--primary);
            color: white;
        }

        .toolbar-btn svg {
            width: 16px;
            height: 16px;
        }

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

        .toolbar-btn:disabled:hover {
            background: var(--bg-card);
            color: var(--text-secondary);
            border-color: var(--border);
        }

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

        .session-info-text strong {
            color: var(--text);
        }

        /* E2E lock icon in device card */
        .e2e-lock {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            margin-left: 6px;
            vertical-align: middle;
        }

        .e2e-lock svg {
            width: 14px;
            height: 14px;
        }

        .e2e-lock.e2e-active {
            color: #22c55e;
        }

        .e2e-lock.e2e-http {
            color: #f59e0b;
        }

        .e2e-lock.e2e-offline {
            color: var(--text-muted);
            opacity: 0.5;
        }

        /* ==================== MODALS ==================== */
        .modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.75);
            backdrop-filter: blur(4px);
            align-items: center;
            justify-content: center;
            z-index: 100;
            padding: 2rem;
        }

        .modal-overlay.active {
            display: flex;
        }

        .modal {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            width: 100%;
            max-width: 500px;
            max-height: 90vh;
            overflow: hidden;
            animation: slideUp 0.3s ease;
        }

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

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

        .modal-title {
            font-size: 1.125rem;
            font-weight: 600;
        }

        .modal-close {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: all 0.2s;
        }

        .modal-close:hover {
            background: var(--bg-elevated);
            color: var(--text);
        }

        .modal-body {
            padding: 1.5rem;
            overflow-y: auto;
        }

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

        /* ==================== TOASTS ==================== */
        .toast-container {
            position: fixed;
            top: 2rem;
            right: 2rem;
            z-index: 200;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }

        .toast {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 1rem 1.25rem;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            animation: slideIn 0.3s ease;
            min-width: 300px;
        }

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

        .toast-success .toast-icon {
            color: var(--success);
        }

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

        .toast-content {
            flex: 1;
        }

        .toast-title {
            font-weight: 600;
            font-size: 0.875rem;
        }

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

        .toast-close {
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0.25rem;
        }

        /* ==================== EMPTY STATES ==================== */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 4rem 2rem;
            text-align: center;
        }

        .empty-state svg {
            width: 80px;
            height: 80px;
            color: var(--text-muted);
            opacity: 0.3;
            margin-bottom: 1.5rem;
        }

        .empty-state h3 {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: 0.5rem;
        }

        .empty-state p {
            color: var(--text-muted);
            font-size: 0.875rem;
            max-width: 300px;
        }

        /* ==================== LOADING ==================== */
        .loading-spinner {
            width: 24px;
            height: 24px;
            border: 2px solid var(--border);
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        .skeleton {
            background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card-hover) 50%, var(--bg-elevated) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
            border-radius: var(--radius-sm);
        }

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

        .flex {
            display: flex;
        }

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

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

        .gap-2 {
            gap: 0.5rem;
        }

        .gap-4 {
            gap: 1rem;
        }

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

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

        .font-mono {
            font-family: monospace;
        }

        .truncate {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* ==================== USER DROPDOWN ==================== */
        .user-dropdown {
            position: relative;
        }

        .user-dropdown-menu {
            position: absolute;
            bottom: 100%;
            left: 0;
            right: 0;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            margin-bottom: 0.5rem;
            padding: 0.5rem;
            display: none;
            animation: slideIn 0.2s ease;
        }

        .user-dropdown-menu.active {
            display: block;
        }

        .dropdown-item {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.625rem 0.75rem;
            border-radius: var(--radius-sm);
            font-size: 0.875rem;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s;
        }

        .dropdown-item:hover {
            background: var(--bg-card-hover);
            color: var(--text);
        }

        .dropdown-item.danger:hover {
            background: rgba(239, 68, 68, 0.1);
            color: var(--danger);
        }

        .dropdown-item svg {
            width: 18px;
            height: 18px;
        }

        .dropdown-divider {
            height: 1px;
            background: var(--border);
            margin: 0.5rem 0;
        }

        /* System Info Panel */
        .system-info-panel {
            position: fixed;
            right: 0;
            top: 0;
            width: 400px;
            height: 100vh;
            background: var(--bg-card);
            border-left: 1px solid var(--border);
            transform: translateX(100%);
            transition: transform 0.3s ease;
            z-index: 50;
            display: flex;
            flex-direction: column;
        }

        .system-info-panel.active {
            transform: translateX(0);
        }

        .system-info-header {
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .system-info-body {
            flex: 1;
            overflow-y: auto;
            padding: 1rem;
        }

        .system-info-section {
            background: var(--bg-darker);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            margin-bottom: 1rem;
            overflow: hidden;
        }

        .system-info-section-header {
            padding: 0.75rem 1rem;
            background: var(--bg-elevated);
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .system-info-section-body {
            padding: 0.75rem 1rem;
        }

        .system-info-row {
            display: flex;
            justify-content: space-between;
            padding: 0.35rem 0;
            border-bottom: 1px solid var(--border);
        }

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

        .system-info-label {
            color: var(--text-muted);
            font-size: 0.875rem;
        }

        .system-info-value {
            font-weight: 500;
            text-align: right;
            max-width: 60%;
            word-break: break-all;
        }

        .usage-bar {
            height: 6px;
            background: var(--bg-elevated);
            border-radius: 3px;
            overflow: hidden;
            margin-top: 0.5rem;
        }

        .usage-bar-fill {
            height: 100%;
            background: var(--primary);
            transition: width 0.3s ease;
        }

        .usage-bar-fill.warning {
            background: var(--warning);
        }

        .usage-bar-fill.danger {
            background: var(--danger);
        }

        .system-info-loading {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 3rem;
            color: var(--text-muted);
        }

        .system-info-loading .spinner {
            width: 32px;
            height: 32px;
            border: 3px solid var(--border);
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

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

        .system-info-footer {
            padding: 1rem;
            border-top: 1px solid var(--border);
        }
