:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --primary: #4f46e5;
    --accent: #6366f1;
    --bg: #f1f5f9;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 22px 22px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    white-space: nowrap;
}
.sidebar-brand i { color: #818cf8; margin-right: 8px; font-size: 1.3rem; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-weight: 600; font-size: .9rem; line-height: 1.2; }
.sidebar-user-role { color: #94a3b8; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; }

.sidebar-nav { padding: 14px 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 22px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: .9rem;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav a i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active {
    background: rgba(99,102,241,.18);
    color: #fff;
    border-left-color: #818cf8;
}

.sidebar-footer { padding: 16px 22px; border-top: 1px solid rgba(255,255,255,.08); }
.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fca5a5;
    text-decoration: none;
    font-size: .9rem;
}
.logout-btn:hover { color: #fff; }

/* ---------- Main / Topbar ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-weight: 600; font-size: .9rem; color: var(--muted); }
.badge-role {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.role-super_admin { background: #eef2ff; color: #4338ca; }
.role-user { background: #ecfdf5; color: #047857; }
.role-viewer { background: #f1f5f9; color: #475569; }

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

/* ---------- Cards ---------- */
.card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15,23,42,.08);
}

.stat-card { border: none; border-radius: 16px; color: #fff; }
.stat-card .stat-body { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { opacity: .9; font-size: .82rem; }

.bg-grad-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.bg-grad-success { background: linear-gradient(135deg, #10b981, #34d399); }
.bg-grad-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.bg-grad-secondary { background: linear-gradient(135deg, #64748b, #94a3b8); }
.bg-grad-danger { background: linear-gradient(135deg, #ef4444, #f87171); }

/* Feature cards on dashboard */
.feature-card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15,23,42,.08);
    transition: transform .15s ease, box-shadow .15s ease;
    height: 100%;
    text-decoration: none;
    color: var(--text);
    display: block;
    background: #fff;
}
.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(15,23,42,.12);
    color: var(--text);
}
.feature-card .feature-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 14px;
}
.feature-card h5 { font-weight: 700; margin-bottom: 6px; }
.feature-card p { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }

/* ---------- Tables ---------- */
.card-table { padding: 0; }
.card-table .card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    border-radius: 14px 14px 0 0 !important;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-table .card-header h5 { margin: 0; font-weight: 700; }
.card-table .table-wrap { padding: 0 20px 20px; }

.table thead th {
    background: #f8fafc;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ---------- Forms ---------- */
.btn { border-radius: 8px; }
.form-control, .form-select { border-radius: 8px; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(99,102,241,.15);
}

.section-card { padding: 20px; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 18px;
    background: #fff;
    padding: 36px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
}
.login-brand i { color: var(--accent); }
.login-subtitle { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 26px; }

/* ---------- Misc ---------- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: 10px; color: #cbd5e1; }

.alert { border-radius: 10px; }

.topbar-logout { display: none; }

/* ---------- Responsive (mobile-first untuk OB) ---------- */
@media (max-width: 768px) {
    .app-wrapper { display: block; }

    /* Sidebar menjadi bottom navigation */
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: auto;
        z-index: 50;
        background: #0f172a;
    }
    .sidebar-brand, .sidebar-user, .sidebar-footer { display: none; }

    .sidebar-nav {
        flex-direction: row;
        padding: 6px 4px;
        justify-content: space-around;
    }
    .sidebar-nav a {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        padding: 6px 2px;
        font-size: .62rem;
        text-align: center;
        border-left: none;
        border-top: 3px solid transparent;
        white-space: nowrap;
    }
    .sidebar-nav a i { font-size: 1.3rem; width: auto; }
    .sidebar-nav a.active {
        border-left: none;
        border-top-color: #818cf8;
        background: rgba(99,102,241,.18);
    }

    .main { padding-bottom: 66px; }
    .topbar { padding: 12px 16px; }
    .topbar-user { display: none; }
    .topbar-logout { display: inline-flex; }

    .content { padding: 16px; }

    .stat-card .stat-body { padding: 16px; }
    .stat-card .stat-value { font-size: 1.5rem; }

    .table-wrap { padding: 0 8px 8px; }
    .table thead th { display: none; }
    .table.card-list thead { display: none; }

    .ob-task-card { padding: 0; }
}
