:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --bg-primary: #0f0f14;
    --bg-secondary: #16161d;
    --bg-tertiary: #1c1c27;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Glass Card */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Auth Page */
.auth-page { overflow: hidden; }
.auth-bg {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(236, 72, 153, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
    z-index: -1;
}
.auth-card { max-width: 420px; margin: 0 auto; }
.logo-icon {
    width: 56px; height: 56px;
    background: var(--gradient);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

/* Forms */
.form-control-glass {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control-glass:focus {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-control-glass::placeholder { color: var(--text-muted); }

/* Buttons */
.btn-primary-gradient {
    background: var(--gradient);
    border: none;
    color: white;
    font-weight: 600;
    border-radius: 8px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary-gradient:hover {
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}
.btn-outline-glass {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    border-radius: 8px;
}
.btn-outline-glass:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
    border-color: var(--primary);
}

/* App Layout */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform 0.3s;
}
.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
}
.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    font-size: 1.125rem;
}
.sidebar .logo i {
    color: var(--primary);
    font-size: 1.25rem;
}
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary-light);
}
.nav-item i { font-size: 1.125rem; width: 20px; text-align: center; }
.nav-divider { height: 1px; background: var(--border-glass); margin: 0.75rem 0; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border-glass); }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}
.topbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.topbar-search input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    width: 100%;
    font-size: 0.875rem;
}
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}
.btn-icon:hover { background: var(--bg-glass); color: var(--text-primary); }
.btn-user {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}
.user-avatar {
    width: 32px; height: 32px;
    background: var(--gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
}
.notification-dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}
.glass-dropdown {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

/* Page Content */
.page-content { padding: 1.5rem; flex: 1; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-actions { display: flex; gap: 0.5rem; }

/* Stat Cards */
.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.bg-primary-subtle { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.bg-success-subtle { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.bg-warning-subtle { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.bg-danger-subtle { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.stat-label { display: block; font-size: 0.8125rem; color: var(--text-muted); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; }

/* Queue */
.queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.875rem;
}
.queue-item:last-child { border-bottom: none; }
.progress-thin { height: 6px; background: var(--bg-tertiary); border-radius: 3px; }
.progress-thin .progress-bar { border-radius: 3px; background: var(--gradient); }

/* Table */
.table-glass { color: var(--text-primary); }
.table-glass thead th {
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem;
}
.table-glass tbody td {
    border-bottom: 1px solid var(--border-glass);
    padding: 0.75rem;
    font-size: 0.875rem;
    vertical-align: middle;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-error { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.status-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-info { background: rgba(6, 182, 212, 0.15); color: var(--info); }

/* Connection Status */
.connection-status {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 9999;
}
.connection-status.visible { opacity: 1; }
.connection-status.disconnected { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* Account cards, schedule cards etc */
.account-card {
    padding: 1.25rem;
    transition: transform 0.15s, border-color 0.15s;
}
.account-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.3);
}
.account-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot-active { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot-error { background: var(--danger); }
.dot-pending { background: var(--warning); }
.dot-paused { background: var(--text-muted); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

.modal-glass .modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
}
.modal-glass .modal-header { border-bottom-color: var(--border-glass); }
.modal-glass .modal-footer { border-top-color: var(--border-glass); }
.modal-glass .btn-close { filter: invert(1); }
[data-theme="light"] .modal-glass .btn-close { filter: none; }

.upload-zone {
    border: 2px dashed var(--border-glass);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.plan-card {
    padding: 2rem;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}
.plan-card.featured {
    border-color: var(--primary);
}
.plan-card.featured::before {
    content: 'Popular';
    position: absolute;
    top: 12px; right: -28px;
    background: var(--gradient);
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.25rem 2rem;
    transform: rotate(45deg);
}
.plan-price { font-size: 2.5rem; font-weight: 700; }
.plan-price small { font-size: 0.875rem; color: var(--text-muted); font-weight: 400; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.pulse { animation: pulse-dot 2s infinite; }
