:root {
  --bg: #f1f4f9;
  --side: #0f1b33;
  --side-2: #16264a;
  --side-text: #c9d3e6;
  --accent: #2563eb;
  --line: #e2e8f0;
}
body { background: var(--bg); font-size: .925rem; color: #1e293b; }
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { width: 248px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; flex-shrink: 0; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; visibility: visible !important; transform: none !important; background-color: var(--side) !important; }
  .sidebar .offcanvas-body { display: contents; }
}
.sidebar.offcanvas-lg { --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--side); }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; }
.brand-name { color: #fff; font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: .75rem; opacity: .7; }
.sidebar-nav { padding: .5rem .6rem; flex: 1; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: .9rem .6rem .3rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .65rem; color: var(--side-text); padding: .5rem .65rem; border-radius: 8px; font-weight: 500; }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--side-2); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--accent); color: #fff; }
.sidebar-foot { padding: .9rem; border-top: 1px solid rgba(255,255,255,.07); }
.user-box { display: flex; gap: .6rem; align-items: center; color: #fff; text-decoration: none; }
.user-box i { font-size: 1.6rem; opacity: .8; }
.user-box span { display: flex; flex-direction: column; line-height: 1.2; }
.user-box small { opacity: .65; font-size: .72rem; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .8rem; background: #fff; border-bottom: 1px solid var(--line); }
.page { padding: 1.4rem; max-width: 1400px; }
@media (max-width: 575px) { .page { padding: .8rem; } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head .sub { color: #64748b; font-size: .85rem; }

.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; border-radius: 12px 12px 0 0 !important; }

.stat { border-radius: 12px; padding: 1rem 1.1rem; background: #fff; border: 1px solid var(--line); height: 100%; }
.stat .label { color: #64748b; font-size: .8rem; display: flex; align-items: center; gap: .4rem; }
.stat .value { font-size: 1.35rem; font-weight: 750; margin-top: .2rem; }
.stat .hint { font-size: .75rem; color: #94a3b8; }
.stat.blue .value { color: #1d4ed8; } .stat.green .value { color: #15803d; }
.stat.red .value { color: #b91c1c; } .stat.dark .value { color: #0f172a; }

.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .8rem; margin-bottom: 1rem; }
.filter-bar .form-label { font-size: .75rem; color: #64748b; margin-bottom: .2rem; }

.table { margin-bottom: 0; }
.table > thead th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #475569; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-wrap .table-responsive { margin: 0; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem .8rem; border-top: 1px solid var(--line); font-size: .82rem; color: #64748b; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.chk { width: 1.1rem; height: 1.1rem; cursor: pointer; }

.bulk-bar { position: sticky; bottom: .6rem; z-index: 1010; display: none; align-items: center; flex-wrap: wrap; gap: .5rem; background: #0f1b33; color: #fff; padding: .6rem .8rem; border-radius: 12px; margin-top: .8rem; box-shadow: 0 8px 24px rgba(15,23,42,.25); }
.bulk-bar.show { display: flex; }

.btn { font-weight: 500; }
.badge { font-weight: 600; }
.empty { text-align: center; padding: 2.5rem 1rem; color: #94a3b8; }

/* Kartu tagihan untuk layar HP */
@media (max-width: 767px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border-bottom: 1px solid var(--line); padding: .6rem .8rem; position: relative; }
  .table-cards td { border: 0 !important; padding: .1rem 0 !important; text-align: left !important; }
  .table-cards td[data-label]::before { content: attr(data-label) ": "; color: #94a3b8; font-size: .78rem; }
  .table-cards td.cell-chk { position: absolute; right: .8rem; top: .7rem; width: auto; }
  .table-cards td.cell-act { padding-top: .4rem !important; }
}

/* Login */
body.blank { background: linear-gradient(135deg, #0f1b33 0%, #1e3a8a 100%); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 400px; border-radius: 16px; border: 0; box-shadow: 0 25px 60px rgba(0,0,0,.35); }

@media print {
  .sidebar, .topbar, .no-print, .filter-bar, .bulk-bar, .pagination { display: none !important; }
  .page { padding: 0; }
  body { background: #fff; }
  .table-wrap, .card { border: 0; }
}
@media (min-width: 768px) { .rk-nama { min-width: 180px; } .rk-cat { min-width: 300px; } }
@media (max-width: 575px) { .stat { padding: .75rem; } .stat .value { font-size: 1.05rem; overflow-wrap: anywhere; } }
/* HP: menu samping bisa di-scroll, tombol Keluar selalu terlihat */
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { height: 100vh; height: 100dvh; }
  .sidebar-nav { overflow-y: auto; min-height: 0; }
  .sidebar-brand, .sidebar-foot { flex-shrink: 0; }
  .sidebar-foot { padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }
}
