/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:     #4f46e5;
    --primary-dark:#3730a3;
    --primary-light:#ede9fe;
    --success:     #16a34a;
    --danger:      #dc2626;
    --warning:     #d97706;
    --bg:          #f3f4f6;
    --card:        #ffffff;
    --text:        #111827;
    --muted:       #6b7280;
    --border:      #e5e7eb;
    --sidebar-w:   240px;
    --radius:      10px;
    --shadow:      0 1px 4px rgba(0,0,0,.08);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: #1e1b4b;
    color: #c7d2fe;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 22px 20px 18px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span { font-size: 22px; }

.sidebar nav { flex: 1; padding: 12px 0; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #c7d2fe;
    font-size: 14px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: #818cf8;
    text-decoration: none;
}

.sidebar nav a .icon { font-size: 17px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: 13px;
    color: #a5b4fc;
}

.sidebar-footer a { color: #f87171; font-size: 13px; }

/* ── Main content ──────────────────────────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.topbar h1 { font-size: 18px; font-weight: 600; }

.topbar .user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.user-badge .avatar {
    width: 32px; height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}

.content { padding: 28px; flex: 1; }

/* ── Stats Cards ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.purple { background: var(--primary-light); }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.orange { background: #ffedd5; }

.stat-info .value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-info .label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── Card ──────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 22px; }

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

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: var(--primary-light); color: var(--primary); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
    text-decoration: none;
}
.btn:hover { opacity: .88; transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-sm       { padding: 5px 12px; font-size: 13px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color .15s;
    background: #fff;
    color: var(--text);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fef08a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Login Page ────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

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

.login-card .brand .logo { font-size: 40px; }
.login-card .brand h1 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-card .brand p  { color: var(--muted); font-size: 14px; }

/* ── Confirm dialog ────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    text-align: center;
}
.modal-box h3 { font-size: 18px; margin-bottom: 10px; }
.modal-box p  { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ── Toggle switch ─────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0;
    background: #d1d5db;
    border-radius: 24px;
    cursor: pointer;
    transition: .2s;
}
.slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(18px); }

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