:root {
    --surface: #ffffff;
    --muted-surface: #f6f8fb;
    --line: #dce3ee;
    --text: #1f2a37;
    --muted: #6b7280;
    --brand: #246bfe;
    --brand-2: #16a085;
    --danger: #dc3545;
    --warning: #f0ad4e;
    --shadow: 0 16px 42px rgba(31, 42, 55, .08);
}

[data-bs-theme="dark"] {
    --surface: #111827;
    --muted-surface: #0b1220;
    --line: #223044;
    --text: #edf2f7;
    --muted: #9aa6b2;
    --shadow: 0 16px 42px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--muted-surface);
    color: var(--text);
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 10;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 22px;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
}
.sidebar-nav { gap: 5px; }
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    color: var(--muted);
    border-radius: 8px;
    font-weight: 600;
}
.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link:hover {
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 11%, transparent);
}
.main { min-width: 0; }
.topbar {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 5;
}
.eyebrow {
    color: var(--muted);
    font-size: .75rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0;
}
.page-title { margin: 0; font-size: 1.45rem; font-weight: 800; }
.content { padding: 28px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-icon {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    color: var(--text);
    background: var(--surface);
}
.profile-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    min-height: 42px;
}
.profile-chip span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    background: var(--brand-2);
}
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.metric-card, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.metric-card { padding: 18px; display: flex; gap: 14px; align-items: center; }
.metric-icon {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--brand);
}
.metric-card p { margin: 0; color: var(--muted); font-weight: 700; font-size: .8rem; }
.metric-card strong { font-size: 1.6rem; line-height: 1; }
.panel { padding: 20px; }
.panel-title { font-size: 1rem; font-weight: 800; margin: 0 0 16px; }
.table { --bs-table-bg: transparent; }
.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    background: var(--muted);
}
.status-dot.online, .status-dot.active, .status-dot.granted { background: #16a085; }
.status-dot.offline, .status-dot.denied, .status-dot.inactive { background: #dc3545; }
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 20% 20%, rgba(36, 107, 254, .16), transparent 32%),
        radial-gradient(circle at 80% 10%, rgba(22, 160, 133, .14), transparent 32%),
        var(--muted-surface);
}
.login-card {
    width: min(100%, 440px);
    padding: 30px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.enroll-display {
    display: grid;
    place-items: center;
    min-height: 90px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--brand);
    background: var(--muted-surface);
}

@media (max-width: 1199px) {
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 991px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform .2s ease;
        width: 270px;
    }
    .sidebar.open { transform: translateX(0); }
    .content, .topbar { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 767px) {
    .metric-grid { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; }
    .profile-chip strong { display: none; }
}
