/* Tema gaya shadcn/ui. Komponen dasar: Tabler 1.6.1 (MIT, The Tabler Authors). Warna mengikuti variabel --tblr-*; jangan tambah warna hardcoded. */

/* ================================================================ Fondasi: font, tipografi, gerak, fokus */
:root {
    --tblr-font-sans-serif: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    /* Transisi 150-200 ms untuk hover, dropdown, modal */
    --crud-fast: .15s ease-out;
    --crud-base: .2s ease-out;
}
body { font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }

/* Skala tipografi: judul halaman, subjudul, teks tabel */
.page-title { font-size: 1.5rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.page-pretitle { font-size: .75rem; font-weight: 500; letter-spacing: .02em; text-transform: none; }
.card-title { font-size: 1rem; font-weight: 600; }
.modal-title { font-size: 1.0625rem; font-weight: 600; }
.table { font-size: .875rem; }
.table thead th {
    font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--tblr-secondary); white-space: nowrap;
}
.form-label { font-weight: 500; }

/* Fokus keyboard terlihat di semua elemen interaktif */
:focus-visible {
    outline: 2px solid var(--tblr-primary);
    outline-offset: 2px;
}
.form-control:focus-visible, .form-select:focus-visible { outline: 0; }
.btn:focus-visible, .nav-link:focus-visible, .dropdown-item:focus-visible, .page-link:focus-visible, .list-group-item:focus-visible {
    outline: 2px solid var(--tblr-primary);
    outline-offset: 2px;
    box-shadow: none;
}

/* Transisi halus */
.btn, .nav-link, .dropdown-item, .list-group-item, .page-link, .form-control, .form-select, .badge {
    transition: background-color var(--crud-fast), color var(--crud-fast), border-color var(--crud-fast), box-shadow var(--crud-fast), opacity var(--crud-fast);
}
.dropdown-menu.show { animation: crud-drop-in var(--crud-fast); }
.modal.fade .modal-dialog { transition: transform var(--crud-base), opacity var(--crud-base); }
@keyframes crud-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes crud-drop-in { from { opacity: 0; transform: translateY(-.25rem); } to { opacity: 1; transform: none; } }

/* Hormati prefers-reduced-motion: matikan animasi dan transisi */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------------------------------------------------------------- Tema shadcn: palet zinc + primary "inverted" (atribut di <html>), radius & kartu */
/* --tblr-primary-rgb tidak ikut diganti tema "inverted" shadcn; disamakan di sini supaya rgba(primary) di bawah tetap netral. */
:root {
    --tblr-primary-rgb: 24, 24, 27;
    --tblr-border-radius: .5rem;
    --tblr-border-radius-lg: .75rem;
    --app-canvas: var(--tblr-gray-50);
    --app-surface: var(--tblr-bg-surface);
    --app-muted: var(--tblr-gray-100);
    --app-hover: color-mix(in srgb, var(--tblr-body-color) 6%, transparent);
    --app-sidebar-w: 16rem;
    --app-sidebar-w-icon: 3.5rem;
}
[data-bs-theme=dark] {
    --tblr-primary-rgb: 250, 250, 250;
    --app-canvas: var(--tblr-gray-900);
    --app-surface: var(--tblr-gray-950);
    --app-muted: var(--tblr-gray-800);
    --tblr-bg-surface: var(--tblr-gray-950);
    --tblr-body-bg: var(--tblr-gray-950);
}
.card {
    --tblr-card-border-radius: var(--tblr-border-radius-lg);
    --tblr-card-inner-border-radius: calc(var(--tblr-border-radius-lg) - 1px);
    --tblr-card-border-color: var(--tblr-border-color);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / .04);
}
.card-header, .card-footer { background: transparent; }
.btn-primary:hover { background-color: color-mix(in srgb, var(--tblr-primary) 90%, var(--tblr-bg-surface)); }

/* ---------------------------------------------------------------- Shell: sidebar kiri + panel konten berbingkai (inset) */
body { background: var(--app-canvas); }
.app-shell { display: flex; min-height: 100vh; }
.app-main {
    flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
    background: var(--app-surface);
}
.app-content { flex: 1 0 auto; }
@media (min-width: 992px) {
    .app-main {
        margin: .5rem .5rem .5rem 0; min-height: calc(100vh - 1rem);
        border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
        border-radius: var(--tblr-border-radius-lg);
        box-shadow: 0 1px 2px 0 rgb(0 0 0 / .04);
    }
}

/* Navbar atas: tombol sidebar, breadcrumb, pencarian, tema, avatar */
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .5rem;
    height: 3.75rem; padding-inline: 1rem;
    background: color-mix(in srgb, var(--app-surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
    border-start-start-radius: inherit; border-start-end-radius: inherit;
}
@media (min-width: 992px) {
    /* Menempel .5rem dari atas (selaras bingkai panel); celah di atasnya ditutup warna kanvas supaya konten yang di-scroll tidak terlihat. */
    .app-topbar { top: .5rem; border-radius: var(--tblr-border-radius-lg) var(--tblr-border-radius-lg) 0 0; }
    .app-topbar::before { content: ""; position: absolute; inset-inline: -1px; bottom: 100%; height: calc(.5rem + 1px); background: var(--app-canvas); }
}
.topbar-divider { width: 1px; height: 1.25rem; background: var(--tblr-border-color); margin-inline: .25rem; }
.topbar-crumbs { min-width: 0; }
.topbar-crumbs .breadcrumb { flex-wrap: nowrap; font-size: .875rem; }
.topbar-crumbs .breadcrumb-item { white-space: nowrap; }
.topbar-crumbs .breadcrumb-item a { color: var(--tblr-secondary); text-decoration: none; }
.topbar-crumbs .breadcrumb-item a:hover { color: var(--tblr-body-color); }
.topbar-crumbs .breadcrumb-item.active { color: var(--tblr-body-color); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.topbar-search {
    display: flex; align-items: center; gap: .5rem; width: 16rem; height: 2.25rem; margin-inline-end: .25rem; padding-inline: .75rem .375rem;
    color: var(--tblr-secondary); font-size: .875rem;
    background: var(--app-surface);
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); border-radius: var(--tblr-border-radius);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / .04);
    transition: background-color var(--crud-fast), color var(--crud-fast);
}
.topbar-search:hover { background: var(--app-hover); color: var(--tblr-body-color); }
.topbar-search kbd {
    margin-inline-start: auto; padding: .125rem .375rem; font-family: inherit; font-weight: 500; color: var(--tblr-secondary);
    background: var(--app-muted); border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); box-shadow: none;
}
.app-topbar .avatar { background: var(--app-muted); color: var(--tblr-body-color); font-weight: 600; font-size: .75rem; }
kbd { font-size: .6875rem; }

/* Judul halaman dan footer */
.page-header { margin-block: 1.75rem 0; }
.page-header .page-title { font-size: 1.75rem; letter-spacing: -.025em; }
.page-header .btn-list { justify-content: flex-start; }
@media (min-width: 768px) { .page-header .btn-list { justify-content: flex-end; } }
.page-body { margin-block: 1.5rem 2rem; }
.footer {
    margin-top: 0; padding-block: 1rem; font-size: .875rem; color: var(--tblr-secondary);
    background: transparent; border-top: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
}

/* ---------------------------------------------------------------- Sidebar */
.app-sidebar {
    --tblr-offcanvas-width: 17rem;
    --tblr-offcanvas-bg: var(--app-canvas);
    display: flex; flex-direction: column;
    color: var(--tblr-body-color);
}
@media (min-width: 992px) {
    .app-sidebar {
        position: sticky; top: 0; flex: 0 0 auto;
        width: var(--app-sidebar-w); height: 100vh;
        transition: width var(--crud-base);
    }
}
.sidebar-header { display: flex; align-items: center; gap: .5rem; padding: .75rem .5rem .5rem; }
.sidebar-brand {
    display: flex; align-items: center; gap: .625rem; min-width: 0; flex: 1 1 auto;
    padding: .375rem; border-radius: var(--tblr-border-radius);
    color: inherit; text-decoration: none;
}
.sidebar-brand:hover { background: var(--app-hover); text-decoration: none; color: inherit; }
.sidebar-brand-icon {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 2rem; height: 2rem; border-radius: var(--tblr-border-radius);
    background: var(--tblr-primary); color: var(--tblr-primary-fg); font-size: 1.125rem;
}
/* Logo RK (latar putih, juga di tema gelap) */
.sidebar-brand-logo { background: #fff; overflow: hidden; box-shadow: inset 0 0 0 1px var(--tblr-border-color); }
.sidebar-brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo { width: 160px; height: auto; border-radius: var(--tblr-border-radius-lg); background: #fff; padding: .5rem; }

.sidebar-brand-text, .sidebar-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-brand-name { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand-sub, .sidebar-user-sub { font-size: .75rem; color: var(--tblr-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-body { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: .25rem .5rem; scrollbar-width: thin; }
.sidebar-section + .sidebar-section { margin-top: .75rem; }
.sidebar-section-title {
    height: 2rem; display: flex; align-items: center; padding-inline: .5rem;
    font-size: .75rem; font-weight: 500; color: var(--tblr-secondary); white-space: nowrap; overflow: hidden;
    transition: opacity var(--crud-base);
}
.sidebar-menu, .sidebar-submenu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .125rem; }
.sidebar-link {
    display: flex; align-items: center; gap: .625rem; width: 100%; height: 2.25rem; padding-inline: .625rem;
    font-size: .875rem; color: var(--tblr-body-color); text-align: start; white-space: nowrap;
    background: transparent; border: 0; border-radius: var(--tblr-border-radius); text-decoration: none;
    transition: background-color var(--crud-fast), color var(--crud-fast);
}
.sidebar-link > .ti { flex: 0 0 auto; font-size: 1.125rem; }
/* Menu tanpa ikon: label sejajar dengan nama modul; inisial hanya tampil saat sidebar dilipat */
.sidebar-menu > li > .sidebar-link { padding-inline-start: 1.75rem; }
.sidebar-initial { display: none; }
.sidebar-section-title { gap: 0; }
.sidebar-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-link:hover, .sidebar-sublink:hover { background: var(--app-hover); color: var(--tblr-body-color); text-decoration: none; }
.sidebar-link.active, .sidebar-sublink.active { background: var(--app-muted); font-weight: 500; }
.sidebar-link.has-active { font-weight: 500; }
.sidebar-chevron { font-size: 1rem !important; color: var(--tblr-secondary); transition: transform var(--crud-base); }
.sidebar-link:not(.collapsed) .sidebar-chevron { transform: rotate(90deg); }
.sidebar-submenu {
    margin: .125rem 0 .25rem 1.875rem; padding: .125rem 0 .125rem .625rem;
    border-inline-start: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
}
.sidebar-sublink {
    display: flex; align-items: center; height: 2rem; padding-inline: .625rem;
    font-size: .875rem; color: var(--tblr-secondary); border-radius: var(--tblr-border-radius); text-decoration: none; white-space: nowrap;
}
.sidebar-sublink.active { color: var(--tblr-body-color); }

.sidebar-footer { padding: .5rem; }
.sidebar-user {
    display: flex; align-items: center; gap: .625rem; width: 100%; padding: .375rem;
    color: inherit; text-align: start; background: transparent; border: 0; border-radius: var(--tblr-border-radius);
}
.sidebar-user:hover, .sidebar-user[aria-expanded=true] { background: var(--app-hover); }
.sidebar-avatar { flex: 0 0 auto; background: var(--app-muted); color: var(--tblr-body-color); font-weight: 600; font-size: .75rem; }
.sidebar-user-text { flex: 1 1 auto; }
.sidebar-user-name { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-caret { flex: 0 0 auto; color: var(--tblr-secondary); }
.sidebar-user-menu { min-width: 14rem; }

/* Sidebar terlipat (hanya lg ke atas): lebar ikon, label disembunyikan, tooltip dari ui.js */
@media (min-width: 992px) {
    html.sidebar-collapsed .app-sidebar { width: var(--app-sidebar-w-icon); }
    html.sidebar-collapsed .sidebar-brand-text,
    html.sidebar-collapsed .sidebar-label,
    html.sidebar-collapsed .sidebar-chevron,
    html.sidebar-collapsed .sidebar-user-text,
    html.sidebar-collapsed .sidebar-user-caret { display: none; }
    html.sidebar-collapsed .sidebar-section-title { justify-content: center; padding-inline: 0; height: 1.75rem; margin-top: .25rem; }
    html.sidebar-collapsed .sidebar-section-name { display: none; }
    html.sidebar-collapsed .sidebar-section-icon { margin: 0; font-size: 1rem; opacity: 1; }
    html.sidebar-collapsed .sidebar-initial {
        display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.5rem;
        font-size: .6875rem; font-weight: 600; letter-spacing: .02em; color: var(--tblr-secondary);
        border-radius: var(--tblr-border-radius-sm); background: var(--app-hover);
    }
    html.sidebar-collapsed .sidebar-link.active .sidebar-initial { color: var(--tblr-body-color); }
    html.sidebar-collapsed .sidebar-menu > li > .sidebar-link { padding-inline-start: 0; }
    html.sidebar-collapsed .sidebar-group > .collapse { display: none; }
    html.sidebar-collapsed .sidebar-link { justify-content: center; padding-inline: 0; }
    html.sidebar-collapsed .sidebar-link.has-active { background: var(--app-muted); }
    html.sidebar-collapsed .sidebar-brand,
    html.sidebar-collapsed .sidebar-user { justify-content: center; padding-inline: 0; }
    html.sidebar-collapsed .sidebar-body { padding-inline: .5rem; }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar { transition: none; } }

/* ---------------------------------------------------------------- Tabs (segmented, seperti shadcn Tabs) */
.app-tabs {
    display: inline-flex; gap: .125rem; padding: .25rem; margin-bottom: 1.25rem; max-width: 100%; overflow-x: auto;
    background: var(--app-muted); border-radius: var(--tblr-border-radius-lg);
}
.app-tabs .nav-link {
    padding: .3125rem .75rem; font-size: .875rem; font-weight: 500; color: var(--tblr-secondary); white-space: nowrap;
    background: transparent; border: 0; border-radius: calc(var(--tblr-border-radius-lg) - .25rem);
}
.app-tabs .nav-link:hover { color: var(--tblr-body-color); }
.app-tabs .nav-link.active { color: var(--tblr-body-color); background: var(--app-surface); box-shadow: 0 1px 2px 0 rgb(0 0 0 / .08); }

/* ---------------------------------------------------------------- Dashboard */
.stat-card { display: block; height: 100%; color: inherit; text-decoration: none; transition: border-color var(--crud-fast), box-shadow var(--crud-fast); }
a.stat-card:hover { color: inherit; text-decoration: none; border-color: color-mix(in srgb, var(--tblr-body-color) 25%, var(--tblr-border-color)); }
.stat-card .card-body { padding: 1.25rem 1.5rem; }
.stat-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; font-size: .875rem; font-weight: 500; }
.stat-card-head .ti { font-size: 1.125rem; color: var(--tblr-secondary); }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.stat-note { font-size: .75rem; color: var(--tblr-secondary); }

.card-heading { padding: 1.5rem 1.5rem 0; }
.card-heading .card-title { margin: 0; font-size: 1rem; font-weight: 600; }
.card-heading .card-subtitle { margin-top: .25rem; font-size: .875rem; color: var(--tblr-secondary); }

/* Kartu angka: nada warna sesuai makna (primer = aktif, kuning = terlambat, merah = bermasalah, hijau = selesai) */
.stat-card { --stat-tone: var(--tblr-secondary); }
.stat-card-primary { --stat-tone: var(--tblr-primary); }
.stat-card-warning { --stat-tone: var(--tblr-yellow); }
.stat-card-danger { --stat-tone: var(--tblr-red); }
.stat-card-success { --stat-tone: var(--tblr-green); }
.stat-card-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 999px;
    background: color-mix(in srgb, var(--stat-tone) 12%, transparent);
}
.stat-card .stat-card-head .ti { color: var(--stat-tone); }
.stat-card-warning.has-value .stat-value, .stat-card-danger.has-value .stat-value { color: var(--stat-tone); }
.stat-card.is-drill { cursor: pointer; }
.stat-card.is-drill:hover { border-color: color-mix(in srgb, var(--stat-tone) 45%, var(--tblr-border-color)); box-shadow: 0 2px 8px 0 rgb(0 0 0 / .06); }
.stat-card.is-drill:focus-visible { outline: 2px solid var(--tblr-primary); outline-offset: 2px; }
.stat-value .placeholder { min-height: 1.75rem; border-radius: .25rem; }

/* Grafik Chart.js: tinggi tetap supaya terbaca di layar kecil */
.dash-chart { position: relative; height: 18rem; }
@media (max-width: 575.98px) { .dash-chart { height: 14rem; } }

/* Daftar dan baris drill-down yang bisa diklik */
.feed-link { cursor: pointer; margin: -.5rem -.75rem; padding: .5rem .75rem; border-radius: var(--tblr-border-radius); transition: background var(--crud-fast); }
.feed-link:hover, .feed-link:focus-visible { background: var(--app-muted); outline: none; }
.feed-link:focus-visible { box-shadow: 0 0 0 2px var(--tblr-primary); }
.feed-empty { font-size: .875rem; }
.dash-avatar-warning { background: color-mix(in srgb, var(--tblr-yellow) 15%, transparent) !important; color: var(--tblr-yellow) !important; }
/* Datatable di modal drill-down: jarak sama dengan datatable di dalam card */
.dash-drill-list > .table-responsive > .dt-container > .row { --tblr-gutter-x: 0; margin: 0; margin-top: 0 !important; padding: .75rem 1.25rem; align-items: center; }
.dash-drill-list > .table-responsive > .dt-container > .row.dt-layout-table { padding: 0; }
.dash-drill-list > .table-responsive > .dt-container > .row:last-child:not(.dt-layout-table) { border-top: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); }
.dash-row-link { cursor: pointer; }
.dash-row-link:focus-visible { outline: 2px solid var(--tblr-primary); outline-offset: -2px; }
.dash-spin { animation: dash-spin 1s linear infinite; }
@keyframes dash-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dash-spin { animation: none; } }

/* Daftar seperti "Recent Sales" */
.feed { list-style: none; margin: 0; padding: 1.25rem 1.5rem 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.feed-item { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.feed-item .avatar { flex: 0 0 auto; background: var(--app-muted); color: var(--tblr-body-color); font-weight: 500; }
.feed-text { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.feed-title { font-size: .875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-sub { font-size: .875rem; color: var(--tblr-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-value { flex: 0 0 auto; font-weight: 500; }

.shortcut-card { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; color: inherit; text-decoration: none; }
.shortcut-card:hover { color: inherit; text-decoration: none; background: var(--app-hover); }
.shortcut-card .avatar { background: var(--app-muted); color: var(--tblr-body-color); }

/* ---------------------------------------------------------------- Indikator loading */
.crud-progress { position: fixed; inset: 0 0 auto 0; z-index: 2100; height: 3px; border-radius: 0; background: transparent; }
.crud-progress[hidden] { display: none; }

/* Tabel: dimmed saat memuat ulang, bar tipis di atas card (menggantikan kotak "Memuat...") */
div.dt-container { position: relative; }
div.dt-container.is-loading table.dataTable > tbody { opacity: .5; transition: opacity var(--crud-fast); }
div.dt-container div.dt-processing {
    position: absolute; inset: 0 0 auto 0; z-index: 4; width: auto; height: 3px; margin: 0; padding: 0; border: 0; border-radius: 0;
    font-size: 0; color: transparent; overflow: hidden; background: rgba(var(--tblr-primary-rgb), .15);
}
div.dt-container div.dt-processing > div { display: none; }
div.dt-container div.dt-processing::after {
    content: ""; position: absolute; inset-block: 0; inset-inline-start: -40%; width: 40%;
    background: var(--tblr-primary); border-radius: 3px; animation: crud-bar 1.1s ease-in-out infinite;
}
@keyframes crud-bar { from { inset-inline-start: -40%; } to { inset-inline-start: 100%; } }
.crud-skeleton td { padding-block: 1rem; }
.crud-skeleton .placeholder { height: .75rem; border-radius: var(--tblr-border-radius); }

/* Toast */
.toast-container { --tblr-toast-zindex: 2200; }
.crud-toast { background: var(--tblr-bg-surface); color: var(--tblr-body-color); border-inline-start: 4px solid var(--tblr-border-color); min-width: 18rem; max-width: 24rem; }
.crud-toast-success { border-inline-start-color: var(--tblr-success); }
.crud-toast-danger { border-inline-start-color: var(--tblr-danger); }
.crud-toast-warning { border-inline-start-color: var(--tblr-warning); }
.crud-toast-info { border-inline-start-color: var(--tblr-info); }
.crud-toast .toast-body { flex: 1 1 auto; }

/* ---------------------------------------------------------------- Tabel */
/* Header sticky: area scroll ada di .table-responsive (maks. tinggi), jadi thead menempel di dalam card. */
.card > .table-responsive { max-height: calc(100vh - 15rem); min-height: 12rem; overflow: auto; }
.card > .table-responsive table.dataTable > thead > tr > th {
    position: sticky; top: 0; z-index: 3;
    background-color: var(--tblr-bg-surface-secondary);
    box-shadow: inset 0 -1px 0 var(--tblr-border-color);
}
.card > .table-responsive > .dt-container > .row:last-child:not(.dt-layout-table) {
    position: sticky; inset-block-end: 0; z-index: 3; background: var(--tblr-bg-surface);
}
/* Hover baris dengan latar lembut */
.table-hover { --tblr-table-hover-bg: rgba(var(--tblr-primary-rgb), .06); }
table.dataTable > tbody > tr > td { vertical-align: middle; }
/* Kolom aksi di kanan; menempel saat tabel di-scroll ke samping di layar sempit */
table.dataTable > tbody > tr > td.crud-col-actions,
table.dataTable > thead > tr > th.crud-col-actions {
    position: sticky; inset-inline-end: 0; z-index: 1; width: 1%;
    background-color: var(--tblr-bg-surface);
    /* kotak lunak yang sama dengan hover baris, tapi opak supaya isi kolom lain tidak tembus */
    background-image: linear-gradient(var(--crud-row-tint, transparent), var(--crud-row-tint, transparent));
}
table.dataTable > thead > tr > th.crud-col-actions { z-index: 4; background-color: var(--tblr-bg-surface-secondary); }
table.dataTable.table-hover > tbody > tr:hover > td.crud-col-actions { --crud-row-tint: rgba(var(--tblr-primary-rgb), .06); }
@media (max-width: 991.98px) {
    table.dataTable > tbody > tr > td.crud-col-actions,
    table.dataTable > thead > tr > th.crud-col-actions { box-shadow: -1px 0 0 var(--tblr-border-color); }
}
.crud-empty { padding-block: 2.5rem; }

/* ---------------------------------------------------------------- Pencarian menu (Ctrl+K) */
.command-list { max-height: 50vh; overflow-y: auto; }
.command-list [hidden], #command-empty[hidden] { display: none !important; }
.command-list .list-group-item { border: 0; border-radius: var(--tblr-border-radius); }
.command-list .list-group-item.active { background-color: rgba(var(--tblr-primary-rgb), .12); color: var(--tblr-primary); }
.command-list .list-group-item.active .text-secondary { color: var(--tblr-primary) !important; }

/* ---------------------------------------------------------------- Form */
.btn .crud-btn-spinner { vertical-align: -.125em; }

/* Utilitas CRUD dipakai crud-kit.js. */
.crud-loading {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--tblr-bg-surface) 55%, transparent);
    animation: crud-fade-in .15s ease-out;
}
.crud-loading[hidden] { display: none; }

.crud-thumb { max-height: 180px; }
.crud-pre { white-space: pre-wrap; }

/* ---------------------------------------------------------------- DataTables di dalam card */
.card > .table-responsive > .dt-container > .row {
    --tblr-gutter-x: 0;
    margin: 0; margin-top: 0 !important; padding: .75rem 1.25rem;
    align-items: center;
}
.card > .table-responsive > .dt-container > .row.dt-layout-table { padding: 0; }
.card > .table-responsive > .dt-container > .row:last-child:not(.dt-layout-table) {
    border-top: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
}
div.dt-container .dt-length,
div.dt-container .dt-search { display: flex; align-items: center; gap: .5rem; }
div.dt-container .dt-length label,
div.dt-container .dt-search label { margin: 0; }
div.dt-container .dt-length select { width: auto; }
div.dt-container .dt-search input { margin-inline-start: 0; }
div.dt-container .dt-search input,
div.dt-container .dt-length select {
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-forms);
    color: var(--tblr-body-color);
}
div.dt-container .dt-search input:focus,
div.dt-container .dt-length select:focus {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .25);
    outline: 0;
}
div.dt-container .dt-info { color: var(--tblr-secondary); }
div.dt-container .page-item.active .page-link {
    background-color: var(--tblr-primary); border-color: var(--tblr-primary); color: var(--tblr-primary-fg);
}
div.dt-container .dt-paging .pagination { margin: 0; }
table.dataTable > thead > tr > th, table.dataTable > thead > tr > td { border-bottom-color: var(--tblr-border-color); }
div.dt-container .dt-processing {
    background: var(--tblr-bg-surface); color: var(--tblr-body-color);
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); border-radius: var(--tblr-border-radius);
}

/* ---------------------------------------------------------------- Select2 (select2-bootstrap-5-theme) disamakan dengan .form-select */
.select2-container--bootstrap-5 .select2-selection {
    background-color: var(--tblr-bg-forms);
    color: var(--tblr-body-color);
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    font-size: var(--tblr-font-size-base, .875rem);
    /* tinggi sama dengan .form-control (40px) */
    min-height: calc(1.4285714286em + 1.125rem + calc(var(--tblr-border-width) * 2));
}
.select2-container--bootstrap-5 .select2-selection--single { padding: .5625rem 2.25rem .5625rem 1rem; }
/* ukuran kecil, mengikuti .form-select-sm yang dipasang di <select> asal */
.form-select-sm + .select2-container--bootstrap-5 .select2-selection {
    min-height: 2rem; /* sama dengan .form-select-sm */
    padding: .3125rem 2rem .3125rem .5rem; font-size: .75rem;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--tblr-body-color); }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered .select2-selection__placeholder,
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder { color: color-mix(in srgb, var(--tblr-body-color) 72%, var(--tblr-bg-forms)) !important; }
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .25);
}
.select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    border-color: var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    box-shadow: var(--tblr-box-shadow-dropdown, var(--tblr-shadow));
}
.select2-container--bootstrap-5 .select2-dropdown .select2-search__field {
    background-color: var(--tblr-bg-forms); color: var(--tblr-body-color);
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); border-radius: var(--tblr-border-radius);
}
.select2-container--bootstrap-5 .select2-dropdown .select2-search__field:focus {
    border-color: var(--tblr-primary); box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .25); outline: 0;
}
.select2-container--bootstrap-5 .select2-results__option { color: var(--tblr-body-color); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background-color: var(--tblr-primary); color: var(--tblr-primary-fg); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option[aria-selected=true]:not(.select2-results__option--highlighted) {
    background-color: rgba(var(--tblr-primary-rgb), .12); color: var(--tblr-primary);
}
.select2-selection.is-invalid { border-color: var(--tblr-danger) !important; }
/* Dropdown Select2 harus di atas modal Bootstrap. */
.select2-container--open { z-index: 1090; }
/* Select2 di baris tabel kecil (master-detail) mengikuti .form-select biasa. */
.table-sm .select2-container--bootstrap-5 .select2-selection { font-size: inherit; }

/* ---------------------------------------------------------------- Dropzone */
/* dropzone.min.css (CDN) memakai warna tetap; di sini diganti variabel tema supaya ikut tema gelap. */
.crud-dropzone {
    border: 2px dashed var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    min-height: 140px;
    padding: .75rem;
    background: var(--tblr-bg-surface-secondary);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem;
    transition: border-color var(--crud-fast), background-color var(--crud-fast);
}
.crud-dropzone:hover { border-color: var(--tblr-primary); }
.crud-dropzone.dz-drag-hover { border-color: var(--tblr-primary); background: rgba(var(--tblr-primary-rgb), .08); }
.crud-dropzone .dz-message { width: 100%; margin: 1rem 0; color: var(--tblr-secondary); text-align: center; }
.crud-dropzone.dz-started .dz-message { display: none; }
.crud-dropzone .dz-preview {
    margin: 0; min-height: 0; width: 10rem; vertical-align: top;
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.crud-dropzone .dz-preview .dz-image {
    width: 8rem; height: 8rem; border-radius: var(--tblr-border-radius);
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}
.crud-dropzone .dz-preview:not(.dz-processing) .dz-progress { display: none; }
.crud-dropzone .dz-preview .dz-details {
    position: static; opacity: 1; padding: .5rem 0 0; min-width: 0; max-width: 100%; text-align: center; color: var(--tblr-body-color);
}
.crud-dropzone .dz-preview .dz-details .dz-size { margin: 0; font-size: .75rem; color: var(--tblr-secondary); }
.crud-dropzone .dz-preview .dz-details .dz-filename { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .8125rem; font-weight: 500; }
.crud-dropzone .dz-preview .dz-details .dz-filename span,
.crud-dropzone .dz-preview:hover .dz-details .dz-filename span,
.crud-dropzone .dz-preview .dz-details .dz-size span { background: transparent; border: 0; }
.crud-dropzone .dz-preview.dz-image-preview { background: transparent; }
.crud-dropzone .dz-preview .dz-remove {
    margin-top: .5rem; padding: .25rem .625rem; font-size: .75rem; text-decoration: none;
    color: var(--tblr-danger); border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-danger); border-radius: var(--tblr-border-radius);
    transition: background-color var(--crud-fast), color var(--crud-fast);
}
.crud-dropzone .dz-preview .dz-remove:hover { background: var(--tblr-danger); color: var(--tblr-danger-fg); text-decoration: none; }
.crud-dropzone .dz-preview .dz-error-message {
    top: 8.5rem; left: 0; width: 100%; background: var(--tblr-danger); color: var(--tblr-danger-fg); border-radius: var(--tblr-border-radius);
}
.crud-dropzone .dz-preview .dz-progress { background: var(--tblr-bg-surface-secondary); border: 0; }
.crud-dropzone .dz-preview .dz-progress .dz-upload { background: var(--tblr-primary); }

/* ---------------------------------------------------------------- SweetAlert2 */
.swal2-popup {
    font-family: inherit; background: var(--tblr-bg-surface); color: var(--tblr-body-color);
    border-radius: var(--tblr-border-radius-lg, var(--tblr-border-radius));
}
.swal2-title, .swal2-html-container { color: var(--tblr-body-color); }
.swal2-popup .swal2-styled { border-radius: var(--tblr-border-radius); }
/* Tanpa !important: confirmButtonColor dari crud-kit.js (inline style, merah untuk hapus) tetap menang. */
.swal2-popup .swal2-styled.swal2-confirm { background-color: var(--tblr-primary); color: var(--tblr-primary-fg); box-shadow: none; }
.swal2-popup .swal2-styled.swal2-cancel { background-color: var(--tblr-secondary); color: var(--tblr-secondary-fg); box-shadow: none; }
.swal2-popup .swal2-styled:focus { box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .25); }

/* ---------------------------------------------------------------- Halaman login */
.auth-page {
    background:
        radial-gradient(70rem 40rem at 15% -10%, rgba(var(--tblr-primary-rgb), .16), transparent 60%),
        radial-gradient(60rem 36rem at 100% 110%, rgba(var(--tblr-primary-rgb), .1), transparent 60%),
        var(--tblr-body-bg);
    min-height: 100vh;
}
.auth-page .card { border-color: transparent; }
.auth-theme { position: fixed; inset-block-start: 1rem; inset-inline-end: 1rem; z-index: 10; }

/* ---------------------------------------------------------------- Ikon sidebar & kolom nomor */
.sidebar-section-icon { margin-inline-end: .375rem; font-size: .875rem; opacity: .75; }
table.dataTable th.crud-col-no, table.dataTable td.crud-col-no { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Animasi (dinonaktifkan oleh prefers-reduced-motion di atas) */
@keyframes crud-rise-in { from { opacity: 0; transform: translateY(.5rem); } to { opacity: 1; transform: none; } }
@keyframes crud-row-in { from { opacity: 0; transform: translateY(.25rem); } to { opacity: 1; transform: none; } }
@keyframes crud-pop-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* Halaman: judul dan kartu muncul naik halus */
.page-body > * { animation: crud-rise-in .35s cubic-bezier(.2, .7, .2, 1) backwards; }
.page-body > *:nth-child(2) { animation-delay: .05s; }
.page-body > *:nth-child(3) { animation-delay: .1s; }

/* Datatable: baris muncul bergantian setiap data selesai dimuat */
table.dataTable > tbody > tr:not(.crud-skeleton) { animation: crud-row-in .28s ease-out backwards; }
table.dataTable > tbody > tr:nth-child(2) { animation-delay: .03s; }
table.dataTable > tbody > tr:nth-child(3) { animation-delay: .06s; }
table.dataTable > tbody > tr:nth-child(4) { animation-delay: .09s; }
table.dataTable > tbody > tr:nth-child(5) { animation-delay: .12s; }
table.dataTable > tbody > tr:nth-child(n+6) { animation-delay: .15s; }

/* Sidebar: ikon bergeser tipis saat hover, tautan aktif muncul dengan transisi */
.sidebar-link > .ti, .sidebar-sublink { transition: transform var(--crud-fast), color var(--crud-fast), background-color var(--crud-fast), padding var(--crud-fast); }
.sidebar-link:hover > .ti:not(.sidebar-chevron) { transform: scale(1.12); }
.sidebar-sublink:hover { padding-inline-start: calc(.5rem + 2px); }
.collapsing { transition: height var(--crud-base) ease; }

/* Tombol: umpan balik tekan; modal & dropdown muncul dengan skala halus */
.btn:not(:disabled):active { transform: translateY(1px) scale(.98); }
.modal.show .modal-content { animation: crud-pop-in .2s ease-out; }
.toast.show { animation: crud-rise-in .25s ease-out; }

/* Matriks hak akses: baris menu muncul saat grup dibuka, tombol "Semua" membal tipis */
#privilege-table tr.priv-menu, #privilege-table tr.priv-group { animation: crud-row-in .22s ease-out backwards; }
#privilege-table .priv-chevron { transition: transform var(--crud-base); }
#privilege-table .btn-icon:active { transform: scale(.9); }

/* ---------------------------------------------------------------- Ganti password: meter kekuatan */
.pw-badge {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 2.75rem; height: 2.75rem; font-size: 1.4rem; color: var(--tblr-primary);
    background: rgba(var(--tblr-primary-rgb), .1); border-radius: var(--tblr-border-radius-lg, .75rem);
}
.pw-card { --pw-color: var(--tblr-border-color); transition: box-shadow .4s ease, border-color .4s ease; }
.pw-card[data-strength="1"] { --pw-color: var(--tblr-red); }
.pw-card[data-strength="2"] { --pw-color: var(--tblr-orange); }
.pw-card[data-strength="3"] { --pw-color: var(--tblr-green); }
.pw-card[data-strength="4"] { --pw-color: var(--tblr-teal); border-color: var(--tblr-teal); box-shadow: 0 0 0 .2rem rgba(var(--tblr-teal-rgb), .15); }
.pw-card[data-strength="1"] #new_password:focus { border-color: var(--tblr-red); box-shadow: 0 0 0 .2rem rgba(var(--tblr-red-rgb), .15); }
.pw-card[data-strength="2"] #new_password:focus { border-color: var(--tblr-orange); box-shadow: 0 0 0 .2rem rgba(var(--tblr-orange-rgb), .15); }
.pw-card[data-strength="3"] #new_password:focus, .pw-card[data-strength="4"] #new_password:focus { border-color: var(--pw-color); box-shadow: 0 0 0 .2rem rgba(var(--tblr-green-rgb), .15); }

.pw-meter { margin-top: .75rem; --pw-color: var(--tblr-border-color); }
.pw-meter[data-level="1"] { --pw-color: var(--tblr-red); }
.pw-meter[data-level="2"] { --pw-color: var(--tblr-orange); }
.pw-meter[data-level="3"] { --pw-color: var(--tblr-green); }
.pw-meter[data-level="4"] { --pw-color: var(--tblr-teal); }
.pw-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: .375rem; }
.pw-bars span { position: relative; height: .375rem; overflow: hidden; border-radius: 999px; background: var(--app-muted, var(--tblr-bg-surface-secondary)); }
.pw-bars span::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--pw-color);
    transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.2, .8, .2, 1), background-color .35s ease;
}
.pw-meter[data-level="1"] .pw-bars span:nth-child(-n+1)::after,
.pw-meter[data-level="2"] .pw-bars span:nth-child(-n+2)::after,
.pw-meter[data-level="3"] .pw-bars span:nth-child(-n+3)::after,
.pw-meter[data-level="4"] .pw-bars span:nth-child(-n+4)::after { transform: scaleX(1); }
.pw-bars span:nth-child(2)::after { transition-delay: .06s, 0s; }
.pw-bars span:nth-child(3)::after { transition-delay: .12s, 0s; }
.pw-bars span:nth-child(4)::after { transition-delay: .18s, 0s; }
.pw-meter-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; margin-top: .5rem; }
.pw-label { font-weight: 600; color: var(--pw-color); transition: color .35s ease; }
.pw-meter[data-level="0"] .pw-label { color: var(--tblr-secondary); font-weight: 500; }
.pw-bump .pw-label { animation: crud-pop-in .3s ease-out; }
.pw-meter[data-level="4"].pw-bump .pw-bars { animation: pw-glow .8s ease-out; }
@keyframes pw-glow { 0% { filter: drop-shadow(0 0 0 transparent); } 40% { filter: drop-shadow(0 0 .45rem var(--tblr-teal)); } 100% { filter: none; } }

.pw-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .25rem .75rem; margin: .75rem 0 0; padding: 0; list-style: none; font-size: .8125rem; }
.pw-rules li { display: flex; align-items: center; gap: .375rem; color: var(--tblr-secondary); transition: color .25s ease; }
.pw-rules li .ti { font-size: 1rem; transition: color .25s ease; }
.pw-rules li.is-met { color: var(--tblr-body-color); }
.pw-rules li.is-met .ti { color: var(--tblr-green); }
.pw-rules li.pw-pop .ti { animation: pw-check .4s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pw-check { 0% { transform: scale(.3) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

.pw-match { min-height: 1.25rem; margin-top: .375rem; font-size: .8125rem; opacity: 0; transform: translateY(-.25rem); transition: opacity .25s ease, transform .25s ease; }
.pw-match[data-state] { opacity: 1; transform: none; }
.pw-match[data-state=""] { opacity: 0; }
.pw-match[data-state="ok"] { color: var(--tblr-green); }
.pw-match[data-state="no"] { color: var(--tblr-red); animation: pw-shake .3s ease-in-out; }
@keyframes pw-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.pw-toggle { color: var(--tblr-secondary); }
.pw-tip-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .75rem; font-size: .875rem; color: var(--tblr-secondary); }
.pw-tip-list li { display: flex; gap: .5rem; }
.pw-tip-list .ti { flex: 0 0 auto; margin-top: .125rem; color: var(--tblr-green); }

/* ---------------------------------------------------------------- Pemilih ikon (Admin › Modul/Menu) */
.icon-picker-toggle {
    display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 2.25rem; padding: .375rem .75rem; text-align: start;
    color: var(--tblr-body-color); background: var(--app-surface, var(--tblr-bg-surface));
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); border-radius: var(--tblr-border-radius);
}
.icon-picker-toggle:hover { background: var(--app-hover, var(--tblr-bg-surface-secondary)); }
.icon-picker-toggle[aria-expanded="true"] { border-color: var(--tblr-primary); }
.icon-picker-preview { font-size: 1.25rem; }
.icon-picker-chevron { margin-inline-start: auto; color: var(--tblr-secondary); transition: transform var(--crud-base); }
.icon-picker-toggle[aria-expanded="true"] .icon-picker-chevron { transform: rotate(180deg); }
.icon-picker-panel {
    margin-top: .375rem; padding: .5rem; background: var(--app-surface, var(--tblr-bg-surface));
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color); border-radius: var(--tblr-border-radius);
    box-shadow: 0 4px 12px rgb(0 0 0 / .08); animation: crud-drop-in var(--crud-fast);
}
.icon-picker-panel[hidden] { display: none; }
.icon-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr)); gap: .25rem; max-height: 13rem; margin-top: .5rem; overflow-y: auto; }
.icon-picker-item {
    display: inline-flex; align-items: center; justify-content: center; height: 2.25rem; padding: 0; font-size: 1.25rem;
    color: var(--tblr-body-color); background: transparent; border: 1px solid transparent; border-radius: var(--tblr-border-radius);
    transition: background-color var(--crud-fast), transform var(--crud-fast);
}
.icon-picker-item:hover { background: var(--app-hover, var(--tblr-bg-surface-secondary)); transform: scale(1.12); }
.icon-picker-item.is-selected { color: var(--tblr-primary-fg, #fff); background: var(--tblr-primary); }
.icon-picker-note { margin-top: .5rem; font-size: .75rem; color: var(--tblr-secondary); }
