:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1f2a40;
    --bg-input: #0d1321;
    --border-color: #2a3550;
    --text-primary: #f0f4f8;
    --text-secondary: #8899b4;
    --text-muted: #5a6b85;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --sidebar-width: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ================================ */
/* LOGIN SCREEN */
/* ================================ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0e17 0%, #1a1040 50%, #0a0e17 100%);
    position: relative;
}
.login-screen::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: 20%; left: 30%;
    pointer-events: none;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s ease;
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo i {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 12px;
    display: block;
}
.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ================================ */
/* INPUTS & BUTTONS */
/* ================================ */
.input-group {
    position: relative;
    margin-bottom: 16px;
}
.input-group i {
    position: absolute;
    left: 16px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}
.input-group input, .form-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    outline: none;
}
.form-input {
    padding-left: 16px;
}
.input-group input:focus, .form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
}
.form-select:focus { border-color: var(--accent); }
.form-select option { background: var(--bg-secondary); }

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #000; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px 10px; font-size: 13px; border-radius: 8px; }

.error-text { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; }

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

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}
.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-header i {
    font-size: 28px;
    color: var(--accent);
}
.sidebar-header span {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}
.nav-item i { width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border-color); }

/* CONTENT */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.content-header {
    padding: 20px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 5;
}
.content-header h2 { font-size: 20px; font-weight: 600; }
.admin-badge {
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 13px;
    color: var(--accent);
    border: 1px solid var(--border-color);
}
.page-content { padding: 24px 32px; }

/* ================================ */
/* STAT CARDS */
/* ================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    opacity: 0;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat-card:hover::after { opacity: 1; }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}
.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ================================ */
/* TABLE */
/* ================================ */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.table-header h3 { font-size: 16px; font-weight: 600; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.search-input {
    padding: 8px 14px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    width: 240px;
    outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-wrapper {
    position: relative;
}
.search-wrapper i {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 14px 20px;
    text-align: left;
    font-size: 13px;
}
th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}
td { border-bottom: 1px solid var(--border-color); }
tr:hover td { background: var(--bg-card-hover); }
tr:last-child td { border-bottom: none; }

/* STATUS BADGES */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}
.badge-active { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-expired { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-suspended { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-xtream { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-m3u { background: rgba(59,130,246,0.15); color: var(--info); }

.mac-address {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--accent);
}

/* ================================ */
/* MODAL */
/* ================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%; max-width: 580px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }

/* ================================ */
/* PAGINATION */
/* ================================ */
.pagination {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ================================ */
/* EMPTY STATE */
/* ================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 14px; }

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

/* ================================ */
/* TOAST NOTIFICATION */
/* ================================ */
.toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--info); color: #fff; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
