:root {
    --bg: #0e0f13;
    --bg2: #141519;
    --bg3: #1c1e26;
    --border: #252830;
    --border2: #2e3240;
    --text: #e8eaf0;
    --text2: #8b90a0;
    --text3: #555a6a;
    --accent: #6c8fff;
    --accent2: #4d6ee8;
    --green: #3ecf8e;
    --red: #ff5c5c;
    --amber: #f5a623;
    --purple: #a78bfa;
    --sidebar-w: 240px;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,.4);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    font-size: 14px;
    line-height: 1.6;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    color: #fff;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    font-size: 13px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    letter-spacing: -0.5px;
}

.brand-name { display: block; font-weight: 600; font-size: 13px; }
.brand-sub { display: block; color: var(--text3); font-size: 11px; }

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

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text3);
    padding: 12px 18px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: var(--text2);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    border-radius: 0;
    transition: all 0.15s;
    position: relative;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

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

.nav-item.active {
    background: rgba(108, 143, 255, 0.12);
    color: var(--accent);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info { flex: 1; display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 30px; height: 30px;
    background: var(--accent2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
    flex-shrink: 0;
}

.user-name { display: block; font-size: 12.5px; font-weight: 500; }
.user-role { display: block; font-size: 11px; color: var(--text3); }

.logout-btn {
    color: var(--text3);
    display: flex; align-items: center;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { color: var(--red); background: rgba(255,92,92,0.1); }

/* ── MAIN ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0; z-index: 50;
}

.page-title h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    font-weight: 400;
    letter-spacing: -0.3px;
}

.page-title p { font-size: 12px; color: var(--text3); margin-top: 1px; }

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content-area { padding: 24px 28px; flex: 1; }

/* ── CARDS ── */
.card {
    background: var(--bg2);
    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;
    display: flex; align-items: center; gap: 8px;
}

.card-body { padding: 20px; }

/* ── STATS GRID ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 60px;
    border-radius: 0 var(--radius) 0 60px;
    opacity: 0.06;
}

.stat-card.blue::after { background: var(--accent); }
.stat-card.green::after { background: var(--green); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.purple::after { background: var(--purple); }

.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.stat-value { font-family: 'DM Mono', monospace; font-size: 30px; font-weight: 500; line-height: 1; }
.stat-value.blue { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-value.purple { color: var(--purple); }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }

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

thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

.td-mono { font-family: 'DM Mono', monospace; font-size: 12px; }
.td-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.badge-green { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-red { background: rgba(255,92,92,0.15); color: var(--red); }
.badge-amber { background: rgba(245,166,35,0.15); color: var(--amber); }
.badge-blue { background: rgba(108,143,255,0.15); color: var(--accent); }
.badge-purple { background: rgba(167,139,250,0.15); color: var(--purple); }
.badge-gray { background: rgba(139,144,160,0.15); color: var(--text2); }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }

.btn-danger { background: rgba(255,92,92,0.15); color: var(--red); }
.btn-danger:hover { background: rgba(255,92,92,0.25); }

.btn-ghost { background: var(--bg3); color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { color: var(--text); border-color: var(--border2); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-sm svg { width: 12px; height: 12px; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-label span { color: var(--red); }

.form-control {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 7px;
    padding: 9px 12px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
}

.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── SEARCH BAR ── */
.search-bar {
    position: relative;
    width: 260px;
}

.search-bar input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 7px;
    padding: 7px 12px 7px 34px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar svg {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    color: var(--text3);
}

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

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
    font-family: 'DM Serif Display', serif;
    font-size: 17px;
    font-weight: 400;
}

.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text3); font-size: 22px; line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── TOAST ── */
#toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    display: flex; align-items: center; gap: 10px;
    box-shadow: var(--shadow);
    animation: toastIn 0.25s ease;
    min-width: 240px;
}

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

.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 4px; align-items: center; padding-top: 16px; }

.page-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border2);
    background: var(--bg3);
    color: var(--text2);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ── PROGRESS BAR ── */
.progress-bar {
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* ── UTILS ── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.text-muted { color: var(--text3); }
.text-sm { font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.fw-mono { font-family: 'DM Mono', monospace; }

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(108,143,255,0.08) 0%, transparent 70%);
    top: -100px; right: -100px;
    pointer-events: none;
}

.login-card {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 16px;
    padding: 40px;
    width: 380px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-icon {
    width: 52px; height: 52px;
    background: var(--accent);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'DM Mono', monospace;
    font-size: 18px;
    color: #fff;
    margin: 0 auto 12px;
}

.login-logo h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    font-weight: 400;
}

.login-logo p { color: var(--text3); font-size: 13px; margin-top: 2px; }

.alert {
    padding: 10px 14px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error { background: rgba(255,92,92,0.1); border: 1px solid rgba(255,92,92,0.2); color: var(--red); }
.alert-success { background: rgba(62,207,142,0.1); border: 1px solid rgba(62,207,142,0.2); color: var(--green); }

/* ── DETAIL PANEL ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.detail-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-item:nth-last-child(-n+2) { border-bottom: none; }
.detail-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 3px; }
.detail-value { font-size: 13.5px; }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text3);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}
