:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --sidebar-bg: #0f172a;
    --sidebar-bg2: #111c34;
    --sidebar-fg: #94a3b8;
    --sidebar-fg-active: #ffffff;
    --content-bg: #f1f5f9;
    --card-border: #e6e9f0;
    --ink: #1e293b;
    --muted: #64748b;
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--content-bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
}

/* ── Shell ─────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
    color: var(--sidebar-fg);
    display: flex; flex-direction: column;
    z-index: 1050;
    transition: transform .22s ease;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex; flex-direction: column; align-items: center; gap: .55rem;
    padding: 1.15rem 1rem .95rem;
    color: #fff; text-align: center;
}
.sidebar-brand-img {
    width: 100%; max-width: 158px; height: auto; display: block;
    background: #fff; border-radius: 12px;
    padding: .7rem .85rem;
    box-shadow: 0 6px 16px rgba(2, 6, 23, .35);
}
.sidebar-brand-text { font-weight: 700; line-height: 1.05; font-size: .92rem; letter-spacing: .3px; color: #e2e8f0; }

.nav-list { display: flex; flex-direction: column; gap: 2px; padding: .5rem .75rem; flex: 1; }
.nav-list .nav-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .62rem .8rem;
    color: var(--sidebar-fg);
    border-radius: 9px;
    font-weight: 500; font-size: .92rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-list .nav-link i { font-size: 1.12rem; width: 1.3rem; text-align: center; }
.nav-list .nav-link:hover { background: rgba(148, 163, 184, .12); color: #e2e8f0; }
.nav-list .nav-link.active {
    background: var(--brand); color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .4);
}

.sidebar-foot { padding: .85rem 1rem 1.1rem; border-top: 1px solid rgba(148, 163, 184, .14); }
.sidebar-user { display: flex; align-items: center; gap: .65rem; }
.avatar {
    width: 38px; height: 38px; flex: none;
    display: grid; place-items: center;
    background: var(--brand); color: #fff;
    border-radius: 50%; font-weight: 700; font-size: .82rem;
}
.su-meta { display: flex; flex-direction: column; min-width: 0; }
.su-name { color: #e2e8f0; font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { color: var(--sidebar-fg); font-size: .76rem; }

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    z-index: 1045; opacity: 0; visibility: hidden; transition: opacity .2s;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: .8rem;
    padding: .7rem 1.4rem;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--card-border);
}
.topbar-title { font-size: 1.18rem; font-weight: 700; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.btn-icon { display: inline-grid; place-items: center; }

.content { padding: 1.5rem 1.4rem 3rem; flex: 1; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
}

/* ── Page header ───────────────────────────────────────────────── */
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .ph-text { min-width: 0; }
.page-head h2 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-head .ph-sub { color: var(--muted); font-size: .9rem; margin: .15rem 0 0; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card { border: 1px solid var(--card-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--card-border); font-weight: 600; border-radius: 14px 14px 0 0 !important; }

/* ── KPI ───────────────────────────────────────────────────────── */
.kpi { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; height: 100%; }
.kpi-icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 13px; font-size: 1.5rem; }
.kpi-icon.indigo { background: #eef2ff; color: #4f46e5; }
.kpi-icon.amber  { background: #fef3c7; color: #d97706; }
.kpi-icon.red    { background: #fee2e2; color: #dc2626; }
.kpi-icon.green  { background: #dcfce7; color: #16a34a; }
.kpi-icon.sky    { background: #e0f2fe; color: #0284c7; }
.kpi-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.kpi-label { color: var(--muted); font-size: .85rem; margin-top: .25rem; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 240px; }

/* ── Tables ────────────────────────────────────────────────────── */
.table { vertical-align: middle; margin: 0; }
.table > thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); font-weight: 700; border-bottom-width: 1px;
}
.table > tbody td { border-color: #f1f5f9; }
.table-hover > tbody > tr:hover > * { background: var(--brand-soft); }
.table-card .table { border-radius: 0 0 14px 14px; overflow: hidden; }

.badge { font-weight: 600; padding: .38em .6em; border-radius: 7px; }
.btn { border-radius: 9px; font-weight: 500; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.form-label { font-weight: 600; font-size: .85rem; color: #334155; margin-bottom: .3rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: .6rem; opacity: .5; }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

/* ── Login / error ─────────────────────────────────────────────── */
.login-body {
    min-height: 100vh; margin: 0;
    display: grid; place-items: center; padding: 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #312e81 55%, #4f46e5 100%);
}
.login-wrap { width: 100%; max-width: 410px; }
.login-card { background: #fff; border-radius: 18px; padding: 2.2rem 2rem; box-shadow: 0 24px 60px rgba(2, 6, 23, .4); }
.login-head { text-align: center; margin-bottom: 1.4rem; }
.login-logo-img {
    width: 116px; height: auto; display: block;
    margin: 0 auto .9rem;
}
.login-title { font-size: 1.45rem; font-weight: 800; margin: 0; }
.login-sub { color: var(--muted); font-size: .9rem; margin: .25rem 0 0; }
.login-footer { text-align: center; color: rgba(255, 255, 255, .65); font-size: .8rem; margin-top: 1.2rem; }
.error-code { font-size: 4.5rem; font-weight: 800; color: var(--brand); line-height: 1; margin-bottom: .5rem; }
