:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #1d4ed8;
    --bg-light: #f1f5f9;
    --card-border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-light);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .92rem;
    color: #1e293b;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
}

.logo-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #fff;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.logo-text { line-height: 1.1; }
.logo-text strong { display: block; font-size: .95rem; letter-spacing: .3px; }
.logo-text small { font-size: .68rem; color: var(--sidebar-text); letter-spacing: 1px; text-transform: uppercase; }

.sidebar-body { flex: 1; overflow-y: auto; padding: 12px 0 30px; }
.sidebar-body::-webkit-scrollbar { width: 5px; }
.sidebar-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-menu { list-style: none; padding: 0; margin: 0; }

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    border-left: 3px solid transparent;
    transition: all .15s;
}

.sidebar-menu .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-menu .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar-menu .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    border-left-color: #38bdf8;
}

.sidebar-menu .nav-link .bi-chevron-down { margin-left: auto; font-size: .75rem; }

.sidebar-menu .submenu { list-style: none; padding: 0 0 6px; }
.sidebar-menu .submenu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 50px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .85rem;
}
.sidebar-menu .submenu a i { font-size: .8rem; width: 16px; }
.sidebar-menu .submenu a:hover { color: #fff; }

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

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-title { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumb + .crumb::before { content: '/'; margin-right: 6px; color: #94a3b8; font-weight: 400; }

.btn-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

.user-dropdown {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 6px 10px;
    background: #fff;
}

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #fff;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem;
}

.content { flex: 1; padding: 22px; max-width: 1600px; width: 100%; margin: 0 auto; }

.footer {
    padding: 14px 22px;
    color: #64748b;
    font-size: .82rem;
    border-top: 1px solid var(--card-border);
    background: #fff;
    text-align: center;
}

.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 1035;
    display: none;
}

/* ---------- 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);
    padding: 14px 18px;
    font-weight: 600;
    border-radius: 14px 14px 0 0 !important;
}

.stat-card {
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: #fff;
    padding: 18px;
    display: flex;
    gap: 14px;
    align-items: center;
    height: 100%;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.bg-primary-soft { background: #e7f0fe; color: #0d6efd; }
.stat-icon.bg-success-soft { background: #e6f9ef; color: #198754; }
.stat-icon.bg-warning-soft { background: #fff5e0; color: #d97706; }
.stat-icon.bg-danger-soft { background: #fee8e8; color: #dc3545; }
.stat-icon.bg-info-soft { background: #e0f6fd; color: #0dcaf0; }
.stat-icon.bg-purple-soft { background: #efe8fd; color: #7c3aed; }
.stat-icon.bg-teal-soft { background: #e0f5f5; color: #14b8a6; }
.stat-icon.bg-indigo-soft { background: #e8edfd; color: #4f46e5; }

.stat-value { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .78rem; color: #64748b; }

/* ---------- Table ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: #eef0f4;
    font-size: .875rem;
    margin-bottom: 0;
}

.table thead th {
    background: #f8fafc;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #64748b;
    white-space: nowrap;
    padding: .75rem .85rem;
    border-bottom: 2px solid #e2e8f0;
}

.table tbody td {
    vertical-align: middle;
    padding: .65rem .85rem;
    border-top: 1px solid #f1f5f9;
}

.table tbody tr:hover > * {
    background-color: #f8fafc;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-striped-bg: #fafbfc;
}

/* ---------- DataTables wrapper ---------- */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 14px 16px 6px;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    font-size: .82rem;
    color: #64748b;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: .82rem;
    height: 32px;
}

.dataTables_wrapper .dataTables_filter input {
    min-width: 220px;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .1);
    outline: none;
}

.dataTables_wrapper .dataTables_info {
    padding: 12px 16px;
    font-size: .78rem;
    color: #64748b;
}

.dataTables_wrapper .dataTables_paginate {
    padding: 10px 16px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px;
    margin: 0 2px;
    padding: 4px 11px;
    border: 1px solid #e2e8f0 !important;
    background: #fff !important;
    color: #475569 !important;
    font-size: .82rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: #cbd5e1 !important;
    background: #f8fafc !important;
    border-color: #f1f5f9 !important;
}

.dataTables_wrapper .dataTables_empty {
    padding: 40px 0 !important;
    color: #94a3b8;
    font-size: .9rem;
}

.table-actions { white-space: nowrap; }
.table-actions .btn { padding: 4px 8px; font-size: .78rem; }

/* ---------- Calendar ---------- */
.iu-calendar table { width: 100%; border-collapse: collapse; }
.iu-calendar th, .iu-calendar td { border: 1px solid var(--card-border); text-align: center; padding: 4px; }
.iu-calendar .day-cell { min-height: 64px; padding: 6px; border-radius: 8px; position: relative; }
.iu-calendar .day-cell.wajib { background: #eef4ff; cursor: pointer; }
.iu-calendar .day-cell.libur { background: #fdecec; color: #b91c1c; }
.iu-calendar .day-cell.blank { background: #f8fafc; }
.iu-calendar .day-num { font-weight: 700; }
.iu-calendar .day-stat { font-size: .68rem; color: #475569; margin-top: 2px; }
.iu-calendar .day-stat .lunas { color: #198754; font-weight: 600; }

/* ---------- Pagu ---------- */
.page-title { font-weight: 700; font-size: 1.25rem; }
.text-muted { color: #64748b !important; }
.required::after { content: ' *'; color: #dc3545; }

.form-label { font-weight: 500; font-size: .85rem; }
.form-control, .form-select {
    border-radius: 8px;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(13,110,253,.1); }

.btn { border-radius: 8px; font-size: .88rem; }

.modal-content { border-radius: 14px; border: none; }
.modal-header { border-bottom: 1px solid var(--card-border); }

.tunggakan-badge { font-size: .8rem; }

/* ---------- Sidebar mobile ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .sidebar-overlay.show { display: block; }
    .content { padding: 16px; }
}
