:root {
    --bg: #f4f6ff;
    --surface: #ffffff;
    --ink: #1c2340;
    --muted: #6b7393;
    --line: #e3e7f5;
    --primary: #3b5bff;
    --primary-dark: #2a44d6;
    --purple: #7c4dff;
    --pink: #ff5fa2;
    --yellow: #ffc531;
    --green: #16b97a;
    --red: #ee4d6c;
    --sidebar: #161c36;
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

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

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

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: linear-gradient(180deg, #1b2244 0%, var(--sidebar) 100%);
    color: #dfe4ff;
    padding: 20px 14px 28px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; gap: 10px; align-items: center; margin: 0 6px 22px; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 13px;
    display: grid; place-items: center; font-size: 20px; font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .3px; color: #fff; }
.brand-sub { font-size: 11px; color: #94a0cf; letter-spacing: 1.4px; text-transform: uppercase; }

.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: #7d88b8; margin: 12px 10px 6px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 10px; color: #ccd4f7;
    font-size: 13.5px; margin-bottom: 2px; transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.active { background: linear-gradient(90deg, rgba(59,91,255,.9), rgba(124,77,255,.85)); color: #fff; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; }

.main { flex: 1; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px 26px; background: rgba(255,255,255,.85);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
    backdrop-filter: blur(8px);
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar .crumb { color: var(--muted); font-size: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--yellow), var(--pink)); color: #fff; font-weight: 700;
}
.content { padding: 24px 26px 48px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::after {
    content: ""; position: absolute; right: -28px; top: -28px; width: 76px; height: 76px;
    border-radius: 50%; background: linear-gradient(135deg, rgba(59,91,255,.12), rgba(124,77,255,.12));
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-note { color: var(--muted); font-size: 12px; }

.panel {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 20px; overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15.5px; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); background: #fafbff; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #f8f9ff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    background: #eef1ff; color: var(--primary-dark);
}
.badge.green { background: #e3f8ee; color: #0b8a58; }
.badge.yellow { background: #fff5d6; color: #9a6b00; }
.badge.red { background: #ffe8ed; color: #c02345; }
.badge.grey { background: #eef0f6; color: #626a86; }
.badge.purple { background: #f0e9ff; color: #5b2fd1; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 0; border-radius: 10px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; background: #eef1ff; color: var(--primary-dark); transition: transform .1s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--purple)); color: #fff; box-shadow: 0 6px 16px rgba(59,91,255,.25); }
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: #ffe8ed; color: #c02345; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(59,91,255,.25); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
.help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #e3f8ee; color: #0b8a58; border: 1px solid #b9ecd5; }
.alert-error { background: #ffe8ed; color: #c02345; border: 1px solid #ffc6d2; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px;
}
.chip input { width: auto; }

.bar-track { height: 8px; border-radius: 999px; background: #eef0f8; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--purple)); }
.bar-fill.green { background: linear-gradient(90deg, #1ec98a, #16b97a); }
.bar-fill.yellow { background: linear-gradient(90deg, #ffd257, #ffb020); }

.pagination { display: flex; gap: 6px; padding: 14px 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty .icon { font-size: 34px; display: block; margin-bottom: 8px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
    radial-gradient(circle at 15% 15%, rgba(59,91,255,.16), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(124,77,255,.18), transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 32px 30px; box-shadow: 0 24px 60px rgba(30,40,90,.12); border: 1px solid var(--line); }
.login-card .brand-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 24px; margin-bottom: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 23px; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }

/* Chart */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--purple)); min-height: 3px; }
.chart .lbl { font-size: 9.5px; color: var(--muted); white-space: nowrap; transform: rotate(-35deg); margin-top: 4px; }

.donut-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.donut-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

@media (max-width: 900px) {
    .layout { display: block; }
    .sidebar { position: static; height: auto; width: auto; display: flex; flex-wrap: wrap; gap: 4px; padding: 12px; }
    .brand { width: 100%; margin-bottom: 8px; }
    .nav-group { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
    .nav-title { display: none; }
    .nav-link { padding: 7px 10px; }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
}
