:root {
    --brand: #9c0d1f;
    --brand-dark: #7a0a18;
    --brand-soft: #fbeaec;
    --ink: #1e2430;
    --muted: #6b7280;
    --line: #e8eaee;
    --bg: #f5f6f8;
    --radius: .8rem;
    --ease: cubic-bezier(.2, .7, .2, 1);
}
* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg); color: var(--ink); font-size: .92rem;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
.text-brand { color: var(--brand) !important; }

/* ---------- Tombol ---------- */
.btn { border-radius: .55rem; font-weight: 500; transition: background-color .15s, border-color .15s, box-shadow .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus-visible { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-brand:focus-visible, .form-control:focus, .form-select:focus { box-shadow: 0 0 0 .22rem rgba(156, 13, 31, .15); }
.btn-outline-brand { color: var(--brand); border-color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.form-control:focus, .form-select:focus { border-color: #d68a93; }
.form-control, .form-select { border-radius: .55rem; border-color: #dfe2e8; }

/* ---------- Navbar ---------- */
.app-navbar {
    background: #fff; border-bottom: 1px solid var(--line); padding: 0;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04); z-index: 1030;
}
.app-navbar .container-xxl { min-height: 62px; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-text { font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.app-navbar .navbar-nav .nav-link {
    color: #4b5563; font-weight: 500; padding: .5rem .85rem; border-radius: .55rem;
    display: flex; align-items: center; gap: .45rem; transition: background-color .12s, color .12s;
}
.app-navbar .navbar-nav .nav-link:hover, .app-navbar .navbar-nav .show > .nav-link { background: #f3f4f6; color: var(--ink); }
.app-navbar .navbar-nav .nav-link.active { background: var(--brand-soft); color: var(--brand); }
.app-navbar .dropdown-toggle::after { margin-left: .15rem; border-width: .28em .28em 0; opacity: .6; }

/* Dropdown: tanpa delay, muncul langsung saat hover (desktop) */
.dropdown-menu {
    border: 1px solid var(--line); border-radius: .8rem; padding: .4rem; margin-top: .35rem;
    box-shadow: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06); min-width: 13rem;
}
.dropdown-menu.show { animation: dd-in .12s var(--ease); }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-item { border-radius: .5rem; padding: .5rem .7rem; display: flex; align-items: center; gap: .6rem; color: #374151; transition: background-color .1s; }
.dropdown-item i { width: 1.1rem; text-align: center; color: #9ca3af; font-size: 1rem; }
.dropdown-item:hover, .dropdown-item:focus { background: #f3f4f6; color: var(--ink); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.dropdown-item.active i { color: var(--brand); }
.dropdown-item.text-danger:hover { background: #fef2f2; }

@media (min-width: 992px) {
    .app-navbar .navbar-nav .dropdown { position: relative; }
    /* jembatan tak terlihat agar pointer tidak "jatuh" di celah antara menu dan dropdown */
    .app-navbar .navbar-nav .dropdown:hover::before { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: .5rem; }
    .app-navbar .navbar-nav .dropdown:hover > .dropdown-menu { display: block; animation: dd-in .12s var(--ease); margin-top: .25rem; }
    .app-navbar .navbar-nav .dropdown:hover > .nav-link { background: #f3f4f6; }
}
@media (max-width: 991.98px) {
    .app-navbar .navbar-nav .nav-link { padding: .7rem .85rem; }
    .app-navbar .dropdown-menu { box-shadow: none; border: 0; background: #f9fafb; margin: 0 0 .25rem .75rem; animation: none; }
    .offcanvas { max-width: 82vw; }
}
.user-toggle { padding: .25rem .5rem; border-radius: .7rem; color: var(--ink); transition: background-color .12s; }
.user-toggle:hover { background: #f3f4f6; color: var(--ink); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; }

/* ---------- Header halaman ---------- */
.page-head { background: #fff; border-bottom: 1px solid var(--line); padding: 1rem 0 .85rem; }
.page-heading { font-size: 1.3rem; font-weight: 700; margin: 0 0 .15rem; letter-spacing: -.01em; }
.breadcrumb { font-size: .78rem; --bs-breadcrumb-divider-color: #c4c8d0; }
.breadcrumb a { text-decoration: none; color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }
.main-content { padding-top: 1.25rem; padding-bottom: 2rem; min-height: calc(100vh - 220px); animation: page-in .22s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.main-footer { padding: 1rem 0; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); background: #fff; }

/* ---------- Kartu & tabel ---------- */
.card { border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); border-radius: var(--radius); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0 !important; padding: .9rem 1.15rem; }
.card-header h5, .card-header h4 { margin: 0; font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.15rem; }
.table { --bs-table-hover-bg: #fbf3f4; }
.table thead th { background: #f8f9fb; color: #4b5563; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; border-bottom: 2px solid var(--line); vertical-align: middle; }
.table-bordered > :not(caption) > * > * { border-color: var(--line); }
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.page-title { font-weight: 700; margin-bottom: 1rem; }
.stat-card { display: flex; gap: .9rem; align-items: center; padding: 1.1rem; transition: transform .15s var(--ease), box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16, 24, 40, .08); }
.stat-card .icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; }
.stat-card .num { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.badge-soft { font-weight: 600; }
.form-label { font-weight: 600; font-size: .8rem; margin-bottom: .3rem; color: #374151; }
.required::after { content: ' *'; color: #dc3545; }
.modal-content { border: 0; border-radius: 1rem; box-shadow: 0 24px 60px rgba(16, 24, 40, .25); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal.fade .modal-dialog { transition: transform .2s var(--ease); }
.alert { border: 0; border-radius: .7rem; }
.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .75rem + 2px); border-radius: .55rem; }

/* DataTables */
div.dataTables_wrapper div.dataTables_filter input { margin-left: .5rem; }
.page-link { color: var(--brand); border-radius: .4rem; margin: 0 .1rem; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.dt-actions .btn { padding: .15rem .5rem; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, #5a0f1a 0%, transparent 60%), linear-gradient(135deg, #1b1f27 0%, #3a0a12 100%); padding: 1rem; }
.login-card { width: 100%; max-width: 400px; border-radius: 1.1rem; border: 0; animation: page-in .3s var(--ease); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Loading bar global ---------- */
#top-loader { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--brand), #e5566a); z-index: 2000; opacity: 0; transition: opacity .2s; pointer-events: none; }
#top-loader.active { opacity: 1; width: 85%; transition: width 8s cubic-bezier(.1, .6, .2, 1), opacity .1s; }

/* ---------- Template tabel (DataTables) ---------- */
.dataTables_wrapper { position: relative; }
.dt-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .85rem; }
.dt-toolbar .dataTables_length label, .dt-toolbar .dataTables_filter label { margin: 0; display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; }
.dt-toolbar .dataTables_length select { width: auto; border-radius: .55rem; padding-right: 2rem; }
.dt-toolbar .dataTables_filter { position: relative; }
.dt-toolbar .dataTables_filter input { margin: 0 !important; width: 260px; max-width: 100%; border-radius: 2rem; padding: .45rem 1rem .45rem 2.3rem; background: #f6f7f9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat .85rem center; border-color: transparent; }
.dt-toolbar .dataTables_filter input:focus { background-color: #fff; border-color: #d68a93; }
.dt-body { border: 1px solid var(--line); border-radius: .8rem; overflow-x: auto; background: #fff; }
.dt-body table.dataTable { margin: 0 !important; border-collapse: separate; border-spacing: 0; width: 100%; }
.dt-body table.dataTable thead th { position: sticky; top: 0; border-top: 0; border-bottom: 1px solid var(--line); background: #f8f9fb; }
.dt-body table.dataTable.table-bordered > :not(caption) > * > * { border-width: 0 0 1px 0; }
.dt-body table.dataTable tbody tr:last-child td { border-bottom: 0; }
.dt-body table.dataTable tbody tr { transition: background-color .1s; }
table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc { cursor: pointer; }
table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sorting_desc { color: var(--brand); }
.dt-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .85rem; font-size: .82rem; color: var(--muted); }
.dt-footer .pagination { margin: 0; }
.dt-footer .page-link { border: 0; min-width: 2.1rem; text-align: center; }
.dt-footer .page-item.disabled .page-link { background: transparent; color: #c4c8d0; }

/* Loading: tabel diredupkan + spinner di tengah */
div.dataTables_wrapper div.dataTables_processing { position: absolute; top: 50%; left: 50%; width: auto; margin: 0; padding: .6rem 1.1rem; transform: translate(-50%, -50%); background: #fff; border: 1px solid var(--line); border-radius: 2rem; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); z-index: 5; }
.dt-spinner { display: inline-flex; align-items: center; gap: .6rem; color: #4b5563; font-size: .85rem; font-weight: 500; }
.dataTables_wrapper.is-loading .dt-body table tbody { opacity: .4; transition: opacity .15s; pointer-events: none; }
tr.dt-loading td { text-align: center; padding: 3rem 0 !important; }
.dt-empty { text-align: center; padding: 2.2rem 0; color: #9ca3af; }
.dt-empty i { font-size: 2rem; display: block; margin-bottom: .3rem; }
.dt-actions .btn { border-radius: .5rem; }
@media (max-width: 575.98px) { .dt-toolbar .dataTables_filter input { width: 100%; } .dt-toolbar, .dt-toolbar .dt-search { width: 100%; } }

/* Ringkasan total */
.sum-box { background: #f8f9fb; border: 1px solid var(--line); border-radius: .8rem; padding: .8rem 1rem; display: flex; flex-direction: column; }
.sum-box .sum-label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.sum-box strong { font-size: 1.3rem; letter-spacing: -.01em; }
.sum-box.sum-warn { background: #fff8e6; border-color: #f6dca0; } .sum-box.sum-warn strong { color: #b45309; }
