/* Express — Dark Professional Theme */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-body: #07080c;
    --bg-surface: #0e1018;
    --bg-card: #141620;
    --bg-card-hover: #191c2a;
    --bg-input: #0e1018;
    --bg-sidebar: #0b0d14;
    --border: #1e2235;
    --border-hover: #2a2f48;
    --text-primary: #e8eaf0;
    --text-secondary: #8b90a8;
    --text-muted: #555a72;
    --accent: #4f7df9;
    --accent-hover: #6b92ff;
    --accent-glow: rgba(79, 125, 249, 0.15);
    --accent-subtle: rgba(79, 125, 249, 0.08);
    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.1);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.1);
    --orange: #fbbf24;
    --orange-bg: rgba(251, 191, 36, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --sidebar-w: 240px;
    --header-h: 60px;
    --font: 'Outfit', sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

* { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s;
}

.sidebar-brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.sidebar-brand .logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-brand .badge {
    font-size: 9px;
    font-weight: 600;
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
    cursor: pointer;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}
.nav-item .icon { font-size: 18px; width: 22px; text-align: center; }
.nav-badge { background: #f87171; color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; margin-left: auto; padding: 0 5px; }
.nav-spacer { flex: 1; }

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border);
}
.user-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
}
.user-block:hover { background: var(--bg-card); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-subtle);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; color: var(--accent);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-balance { font-size: 11px; color: var(--text-muted); }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.page-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 17px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; align-items: center; }

.page-body {
    padding: 24px 28px;
}

/* ── Cards & Stat Boxes ────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Tables ────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ───────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-success { background: var(--green-bg); color: var(--green); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── Forms ─────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    transition: border-color .15s;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Badges ────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: rgba(85,90,114,0.2); color: var(--text-muted); }
.badge-paused { background: var(--orange-bg); color: var(--orange); }
.badge-error { background: var(--red-bg); color: var(--red); }

/* ── Toggle ────────────────────────────────── */

.toggle {
    position: relative;
    width: 40px; height: 22px;
    background: var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: background .2s;
}
.toggle.active { background: var(--accent); }
.toggle::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.toggle.active::after { transform: translateX(18px); }

/* ── Pagination ────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}
.pagination .pg-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}
.pagination .pg-btn:hover { border-color: var(--accent); color: var(--accent); }
.pagination .pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .pg-info { font-size: 12px; color: var(--text-muted); padding: 0 8px; }

/* ── Modal ─────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: translateY(10px);
    transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 22px; }
.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Empty state ───────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state .title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state .desc { font-size: 13px; margin-bottom: 20px; }

/* ── Loading ───────────────────────────────── */

.spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Toast ─────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn .2s ease;
    min-width: 260px;
}
.toast-success { border-color: var(--green); }
.toast-error { border-color: var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* ── Login page ────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(79,125,249,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(167,139,250,0.04) 0%, transparent 50%),
        var(--bg-body);
}
.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-logo {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}
.login-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 16px;
    display: none;
}

/* ── Responsive ────────────────────────────── */

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-body { padding: 16px; }
}
