:root {
  --bg: #f6f7fb; --surface: #fff; --border: #e6e8ef; --text: #1f2937; --muted: #6b7280;
  --primary: #2563eb; --primary-50: #eff4ff; --success: #16a34a; --warn: #d97706; --danger: #dc2626;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --sidebar: 248px;
  --surface-2: #f8fafc; --chip: #f3f4f6; --border-strong: #d1d5db; --text-2: #4b5563;
  --primary-200: #c7d2fe; --info-50: #f0f9ff; --info-200: #bae6fd;
  --danger-50: #fef2f2; --danger-200: #fecaca; --warn-50: #fff7ed; --warn-200: #fed7aa; --success-50: #ecfdf5; --success-200: #bbf7d0;
  --yellow-50: #fffbeb; --yellow-200: #fde68a; --yellow-700: #92400e;
  color-scheme: light;
}
/* ===== Tema gelap: ikut sistem (Otomatis) atau dipilih manual (data-theme) ===== */
:root[data-theme="dark"] {
  --bg: #0f1117; --surface: #171a21; --surface-2: #1d2129; --chip: #252a34; --border: #2a2f3a; --border-strong: #3b4150;
  --text: #e6e8ec; --text-2: #c4c9d2; --muted: #9aa2b1;
  --primary: #5b8def; --primary-50: rgba(91,141,239,.15); --primary-200: rgba(91,141,239,.38);
  --success: #34c46a; --success-50: rgba(52,196,106,.13); --success-200: rgba(52,196,106,.35);
  --warn: #f2a33a; --warn-50: rgba(242,163,58,.13); --warn-200: rgba(242,163,58,.35);
  --danger: #f2706a; --danger-50: rgba(242,112,106,.13); --danger-200: rgba(242,112,106,.38);
  --info-50: rgba(56,189,248,.12); --info-200: rgba(56,189,248,.32);
  --yellow-50: rgba(250,204,21,.10); --yellow-200: rgba(250,204,21,.30); --yellow-700: #f5d36b;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117; --surface: #171a21; --surface-2: #1d2129; --chip: #252a34; --border: #2a2f3a; --border-strong: #3b4150;
    --text: #e6e8ec; --text-2: #c4c9d2; --muted: #9aa2b1;
    --primary: #5b8def; --primary-50: rgba(91,141,239,.15); --primary-200: rgba(91,141,239,.38);
    --success: #34c46a; --success-50: rgba(52,196,106,.13); --success-200: rgba(52,196,106,.35);
    --warn: #f2a33a; --warn-50: rgba(242,163,58,.13); --warn-200: rgba(242,163,58,.35);
    --danger: #f2706a; --danger-50: rgba(242,112,106,.13); --danger-200: rgba(242,112,106,.38);
    --info-50: rgba(56,189,248,.12); --info-200: rgba(56,189,248,.32);
    --yellow-50: rgba(250,204,21,.10); --yellow-200: rgba(250,204,21,.30); --yellow-700: #f5d36b;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--primary-50), var(--surface-2) 60%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; box-shadow: 0 10px 40px rgba(37,99,235,.08); padding: 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; }
.login-card .brand { margin-bottom: 24px; font-size: 17px; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .25s ease; }
.sidebar .brand { padding: 18px 18px 14px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); transition: background .15s, color .15s; }
.nav a:hover { background: var(--chip); }
.nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.content { padding: 24px; max-width: 1400px; margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.menu-btn { display: none; }
.menu-btn svg { width: 22px; height: 22px; }
.topbar-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; visibility: hidden; }
.backdrop { display: none; }
.avatar.has-img { background-size: cover; background-position: center; color: transparent; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-menu { position: relative; }
.dropdown { position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.08); min-width: 210px; padding: 6px; display: none; }
.dropdown.open { display: block; animation: fade .15s; }
.dropdown a, .dropdown div.item { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); cursor: pointer; }
.dropdown a:hover { background: var(--chip); }

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: var(--surface); transition: border .15s, box-shadow .15s; }
textarea { height: auto; min-height: 70px; padding: 8px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.search { max-width: 280px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--chip); color: var(--text-2); text-transform: capitalize; }
.badge.draft { background: var(--chip); color: var(--text-2); }
.badge.approved, .badge.posted, .badge.disbursed { background: var(--primary-50); color: var(--primary); }
.badge.received, .badge.partial, .badge.pending, .badge.submitted, .badge.requested, .badge.partially_ordered { background: var(--warn-50); color: var(--warn); }
.badge.paid, .badge.active, .badge.settled, .badge.ordered { background: var(--success-50); color: var(--success); }
.badge.cancelled, .badge.inactive, .badge.rejected { background: var(--danger-50); color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 650; border-top: 2px solid var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 4px 2px; flex-wrap: wrap; font-size: 13px; }
.pager select { width: auto; height: 30px; padding: 0 8px; font-size: 13px; }
.pager .pages { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.pager .pages .btn { min-width: 30px; padding: 0 8px; }
@media (max-width: 640px) { .pager { justify-content: center; } .pager .pages { margin-left: 0; width: 100%; justify-content: center; } }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi .label { font-size: 12.5px; color: var(--muted); }
.kpi .value { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid2.even { grid-template-columns: 1fr 1fr; }
.chart-box { position: relative; height: 280px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; animation: fadeBg .2s; }
@keyframes fadeBg { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.15); animation: pop .2s ease; }
.modal.lg { max-width: 960px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.x { margin-left: auto; }

.items-table input, .items-table select { height: 34px; }
.items-table td { padding: 6px 4px; }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 8px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.info-grid div span { display: block; font-size: 12px; color: var(--muted); }
.att-list { list-style: none; padding: 0; margin: 8px 0 0; }
.att-list li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.dropzone { border: 1.5px dashed var(--primary-200); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; transition: background .15s; }
.dropzone:hover, .dropzone.over { background: var(--primary-50); }
.perm-table td, .perm-table th { padding: 7px 8px; text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; user-select: none; }
.chip input { width: 14px; height: 14px; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 360px; animation: pop .2s; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- sidebar ringkas (ikon) untuk layar desktop kecil, mis. 1366×768 ----------
   Otomatis di lebar ≤1440px (bisa diubah lewat tombol ☰ dan diingat). Arahkan kursor ke sidebar untuk melihat nama menu. */
@media (min-width: 1025px) {
  .menu-btn { display: inline-flex; width: 40px; height: 40px; padding: 0; }
  body.nav-mini { --sidebar: 64px; }
  body.nav-mini .sidebar { transition: width .18s ease, box-shadow .18s ease; overflow: hidden; }
  body.nav-mini .sidebar .brand { padding: 14px 8px 10px; text-align: center; }
  body.nav-mini .sidebar .brand .muted { display: none; }
  body.nav-mini .sidebar .logo-img { max-width: 48px; object-fit: contain; object-position: left; }
  body.nav-mini .nav { padding: 6px 8px 16px; overflow-x: hidden; }
  body.nav-mini .nav-group { font-size: 0; padding: 0; height: 1px; margin: 10px 6px; background: var(--border); }
  body.nav-mini .nav a { justify-content: center; padding: 10px 0; }
  body.nav-mini .nav a span { display: none; }
  body.nav-mini .sidebar:hover { width: 248px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  body.nav-mini .sidebar:hover .brand .muted { display: block; }
  body.nav-mini .sidebar:hover .logo-img { max-width: none; }
  body.nav-mini .sidebar:hover .nav-group { font-size: 11px; height: auto; padding: 14px 10px 6px; margin: 0; background: none; }
  body.nav-mini .sidebar:hover .nav a { justify-content: flex-start; padding: 8px 10px; }
  body.nav-mini .sidebar:hover .nav a span { display: inline; white-space: nowrap; }
}
/* ---------- panel info pelanggan: kolom kanan ikut terlihat (sticky + gulir sendiri) & kartu bisa dilipat ---------- */
@media (min-width: 1025px) {
  .cust-grid { grid-template-columns: minmax(0, 1fr) 330px !important; align-items: start; }
  .cust-side { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
}
.cust-side .card { margin-bottom: 10px !important; margin-top: 0 !important; }
.cust-side .cside-h { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; }
.cust-side .cside-h::after { content: '▾'; margin-left: auto; color: var(--muted); font-size: 12px; transition: transform .15s; }
.cust-side .card.folded .cside-h::after { transform: rotate(-90deg); }
.cust-side .card.folded .cside-b { display: none; }
.cust-side .card.folded { padding-bottom: 12px; }
@media (max-width: 1440px) and (min-width: 1025px) {
  .cust-head { padding: 14px 16px !important; } .cust-head h1 { font-size: 20px; }
  .kpis .kpi { padding: 12px 14px; } .kpis .kpi .value { font-size: 20px; }
}
.cust-side .cside-sum { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }

/* layar lebar: konten boleh lebih lebar agar tabel tidak sempit */
@media (min-width: 1800px) { .content { max-width: 1680px; } }

/* tablet */
@media (max-width: 1024px) {
  .grid2, .grid2.even { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.1); }
  .sidebar.open { transform: none; }
  .backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; width: 40px; height: 40px; padding: 0; }
  .topbar-title { visibility: visible; }
  .user-menu .btn span { display: none; }
}
/* phone */
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .search { max-width: none; flex: 1; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 17px; }
  .modal-bg { padding: 0; align-items: flex-end; }
  /* layar sempit: kepala & tombol tetap, isi yang menggulir (dvh = tinggi layar yang benar-benar terlihat di HP) */
  .modal, .modal.lg { border-radius: 16px 16px 0 0; max-height: 94vh; max-height: 94dvh; display: flex; flex-direction: column; overflow: hidden; }
  .modal > .modal-head, .modal > .modal-foot { flex: 0 0 auto; }
  .modal > .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  /* responsive tables -> cards */
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 6px 0; background: var(--surface); }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 12px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; }
  table.responsive tfoot td { display: flex; }
  .card.flush-mobile { background: transparent; border: 0; box-shadow: none; padding: 0; }
  .chart-box { height: 230px; }
  .kpi .value { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kpi { padding: 14px; }
  /* compact cards: first column is the card title, secondary columns hidden */
  .hm { display: none !important; }
  table.responsive tr { padding: 4px 0; margin-bottom: 8px; }
  table.responsive td { padding: 4px 12px; font-size: 13.5px; align-items: center; width: auto !important; min-width: 0 !important; }
  table.responsive tbody td:first-child { font-size: 14.5px; padding-top: 8px; }
  table.responsive tbody td:first-child::before { content: none; }
  table.responsive tbody td:first-child { justify-content: flex-start; text-align: left; }
  table.responsive td input:not([type=checkbox]):not([type=radio]), table.responsive td select { width: 62%; max-width: 230px; min-width: 110px; height: 36px; }
  table.responsive td:empty { display: none; }
  table.responsive td > .cv { min-width: 0; overflow-wrap: anywhere; }
  table.responsive td:has(> .cv:empty) { display: none; }
  table.items-table td:first-child select { width: 100%; max-width: none; }
  /* statement tables (Neraca, Laba Rugi, Arus Kas) */
  .card > .table-wrap > table:not(.responsive) td, .card > .table-wrap > table:not(.responsive) th { padding: 8px 6px; font-size: 12.5px; }
  /* fade hint only where a wide statement table really scrolls sideways */
  .table-wrap.is-scroll:has(> table:not(.responsive)) { -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }
  table.responsive input[type=checkbox] { width: 22px; height: 22px; }
  .tabs { scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .tabs::-webkit-scrollbar { display: none; }
  /* modal: keep actions reachable */
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); z-index: 2; padding-bottom: max(14px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 16px rgba(0,0,0,.05); }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .grow { display: none; }
  .modal-head { position: sticky; top: 0; background: var(--surface); z-index: 2; }
  .modal .pager.simple { display: none; }
  .modal-body { padding: 16px; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-head h1 { font-size: 18px; }
}

.budget-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 4px; min-width: 80px; }
.budget-bar > div { height: 100%; background: var(--success); border-radius: 99px; transition: width .3s; }
.budget-bar.warn > div { background: var(--warn); } .budget-bar.over > div { background: var(--danger); }
.timeline { list-style: none; padding: 0; margin: 0 0 14px; display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.timeline li { padding: 4px 10px; border-radius: 99px; background: var(--chip); color: var(--muted); }
.timeline li.done { background: var(--success-50); color: var(--success); } .timeline li.bad { background: var(--danger-50); color: var(--danger); }

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .backdrop, .tabs, .pager, .page-head .actions, .btn, #toasts { display: none !important; }
  .main { margin: 0; } .content { padding: 0; max-width: none; animation: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .grid2, .grid2.even { grid-template-columns: 1fr; }
  table.responsive thead { display: table-header-group; } table.responsive tr { display: table-row; } table.responsive td { display: table-cell; }
}

/* ---------- mobile bottom navigation & menu sheet ---------- */
.bnav, .msheet { display: none; }
body.no-scroll { overflow: hidden; }
@media (max-width: 1024px) {
  .nav a { padding: 11px 12px; }              /* 44px tap targets in the tablet drawer */
}
@media (max-width: 640px) {
  .menu-btn { display: none !important; }
  .topbar { height: 54px; }
  .content { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); left: 16px; right: 16px; }
  .toast { max-width: none; }
  .bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 4px 4px env(safe-area-inset-bottom); }
  .bnav a, .bnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px;
    color: var(--muted); font: inherit; font-size: 11px; font-weight: 500; background: none; border: 0; border-radius: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .bnav svg { width: 23px; height: 23px; }
  .bnav .active { color: var(--primary); }
  .bnav .active svg { stroke-width: 2.2; }
  .bnav a:active, .bnav button:active { background: var(--chip); }
  .msheet:not([hidden]) { display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 60; background: var(--bg); animation: sheetUp .22s ease; }
  @keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } }
  .ms-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: max(12px, env(safe-area-inset-top)); }
  .ms-head .avatar { width: 40px; height: 40px; font-size: 16px; flex: none; }
  .ms-search { padding: 12px 16px 4px; }
  .ms-search input { height: 44px; border-radius: 12px; font-size: 15px; }
  .ms-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; -webkit-overflow-scrolling: touch; }
  .ms-body h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 2px 8px; font-weight: 600; }
  .ms-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .ms-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; min-height: 84px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; color: var(--text); font-size: 11.5px; line-height: 1.25; text-align: center; -webkit-tap-highlight-color: transparent; }
  .ms-grid a.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); font-weight: 600; }
  .ms-grid a:active { background: var(--chip); }
  .ms-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
  .ms-ic svg { width: 22px; height: 22px; }
  .ms-foot { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  .ms-foot .btn { flex: 1; height: 44px; }
}
@media (max-width: 360px) { .ms-grid { grid-template-columns: repeat(3, 1fr); } .bnav span { font-size: 10px; } }

/* ---------- access matrix ---------- */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 230px); border-radius: var(--radius); }
table.matrix { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--border); padding: 6px 8px; background: var(--surface); }
table.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-transform: none; letter-spacing: 0; color: var(--text); vertical-align: bottom; }
table.matrix .mx-first { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 210px; max-width: 260px; border-right: 1px solid var(--border); }
table.matrix thead .mx-first { z-index: 3; }
table.matrix .mx-col { min-width: 92px; max-width: 120px; text-align: center; font-weight: 600; white-space: normal; line-height: 1.25; }
table.matrix .mx-col span { display: block; font-weight: 400; font-size: 11px; margin-top: 2px; }
table.matrix .mx-mod th, table.matrix .mx-mod td { background: var(--bg); font-weight: 600; }
table.matrix .mx-act { font-weight: 400; padding-left: 22px; color: var(--text-2); }
table.matrix .mx-act code { font-size: 11px; color: var(--muted); margin-left: 4px; }
table.matrix .mx-c { text-align: center; }
table.matrix .mx-c.on { color: var(--success); font-weight: 700; }
table.matrix .mx-c.chg { background: var(--warn-50); }
table.matrix .mx-sum { text-align: center; font-size: 11.5px; color: var(--muted); }
table.matrix .mx-sum.full { color: var(--success); }
table.matrix .mx-sum.part { color: var(--warn); }
table.matrix [data-fill], table.matrix [data-mod] { cursor: pointer; }
table.matrix tbody tr:hover td, table.matrix tbody tr:hover th { background: var(--surface-2); }
table.matrix input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
@media (max-width: 640px) {
  .matrix-wrap { max-height: calc(100vh - 300px); }
  table.matrix .mx-first { min-width: 150px; max-width: 170px; }
  table.matrix .mx-act code { display: none; }
  table.matrix .mx-col { min-width: 76px; }
}
table.matrix tbody th { text-transform: none; letter-spacing: 0; font-size: 13px; }
table.matrix .mx-mod th { text-transform: uppercase; font-size: 11.5px; letter-spacing: .04em; color: var(--text-2); }

/* ---------- tutorial ---------- */
.tut-group { margin: 22px 0 10px; font-size: 15px; }
.tut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.tut-card { display: flex; gap: 14px; align-items: flex-start; color: var(--text); transition: border-color .15s, transform .15s; }
.tut-card:hover { border-color: var(--primary-200); transform: translateY(-1px); }
.tut-card p { margin: 4px 0 6px; font-size: 13px; }
.tut-meta { font-size: 12px; color: var(--muted); }
.tut-ic { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.tut-ic svg { width: 22px; height: 22px; }
.tut-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.tut-head .tut-ic { width: 52px; height: 52px; }
.tut-note { background: var(--warn-50); border-color: var(--warn-200); margin-bottom: 14px; }
.tut-steps { list-style: none; padding: 0; margin: 0; max-width: 980px; }
.tut-steps li { display: flex; gap: 14px; padding-bottom: 22px; position: relative; }
.tut-steps li:not(:last-child)::before { content: ''; position: absolute; left: 15px; top: 34px; bottom: 4px; width: 2px; background: var(--border); }
.tut-num { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.tut-body { flex: 1; min-width: 0; }
.tut-body h3 { margin: 4px 0 6px; font-size: 15.5px; }
.tut-body p { margin: 0 0 10px; line-height: 1.6; }
.tut-tip { background: var(--info-50); border: 1px solid var(--info-200); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.tut-img { display: block; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: zoom-in; max-width: 760px; width: 100%; box-shadow: var(--shadow); }
.tut-img img { display: block; width: 100%; height: auto; }
.tut-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: 980px; padding-top: 6px; border-top: 1px solid var(--border); padding-top: 16px; }
.tut-hint { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; background: var(--primary-50); border-color: var(--primary-200); }
@media (max-width: 640px) {
  .tut-grid { grid-template-columns: 1fr; }
  .tut-steps li { gap: 10px; }
  .tut-foot .btn { flex: 1 1 100%; }
  .tut-foot .grow { display: none; }
  .tut-hint { flex-wrap: wrap; }
  .tut-hint .btn.primary { flex: 1; }
}

/* ---------- layanan internet ---------- */
.net-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); margin-right: 4px; vertical-align: 1px; }
.net-dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
pre.code { background: #0f172a; color: var(--border); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; margin: 0; }

/* ---------- pelanggan (CRM) ---------- */
.cust-link { color: inherit; text-decoration: underline; text-decoration-color: var(--primary-200); text-underline-offset: 3px; }
.cust-link:hover { color: var(--primary); text-decoration-color: var(--primary); }
.cust-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.cust-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.act-list { list-style: none; margin: 8px 0 0; padding: 0; }
.act-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--surface-2); font-size: 13.5px; }
.act-k { width: 10px; height: 10px; border-radius: 50%; background: var(--slate, var(--muted)); margin-top: 5px; flex: none; }
.act-k.invoice { background: var(--primary); } .act-k.payment { background: var(--success); } .act-k.service { background: #8b5cf6; } .act-k.ticket { background: var(--warn); } .act-k.note { background: var(--muted); }
.tk-thread { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.tk-msg { padding: 12px 14px; border-radius: 12px; white-space: pre-line; max-width: 88%; }
.tk-msg.customer { background: var(--surface); border: 1px solid var(--border); }
.tk-msg.staff { background: var(--primary-50); margin-left: auto; }
@media (max-width: 640px) { .cust-actions { width: 100%; } .cust-actions .btn { flex: 1 1 auto; } .tk-msg { max-width: 100%; } }

.cust-status { width: auto; height: 28px; font-size: 12.5px; font-weight: 600; padding: 0 8px; border-radius: 99px; background: var(--chip); }
.cust-status.paid { background: var(--success-50); color: var(--success); border-color: var(--success-200); } .cust-status.cancelled { background: var(--danger-50); color: var(--danger); border-color: var(--danger-200); }

.contact-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.chip.chip-on { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
button.chip { font: inherit; background: var(--surface); }
@media (max-width: 640px) { .contact-row > div:last-child { text-align: left !important; width: 100%; padding-left: 52px; } }

.f .hint{display:block;font-size:12px;line-height:1.45;color:var(--muted);margin-top:4px;font-weight:400}
.f.row .hint{flex-basis:100%;margin-left:26px}
.f .hint code,.pg-guide code{font-size:11.5px;word-break:break-all}
.pg-guide{background:var(--bg,var(--surface-2));border:1px solid var(--border);border-radius:10px;padding:10px 14px;font-size:13px}
.pg-guide ol{margin:6px 0 0;padding-left:18px;display:grid;gap:4px}
.copy-row{display:inline-flex;gap:6px;align-items:center;flex-wrap:wrap}
.pg-warn{background:var(--yellow-50);border:1px solid var(--yellow-200);color:var(--yellow-700);border-radius:10px;padding:10px 14px;font-size:13px;margin-bottom:10px}

/* AI assistant */
.ai-btn{gap:6px;font-weight:600;color:var(--primary)}
.ai-panel{position:fixed;top:0;right:0;bottom:0;width:min(440px,100vw);background:var(--surface);border-left:1px solid var(--border);box-shadow:-12px 0 32px rgba(15,23,42,.08);z-index:60;display:flex;flex-direction:column}
.ai-panel[hidden]{display:none}
.ai-panel header{display:flex;align-items:center;gap:10px;padding:12px 14px;border-bottom:1px solid var(--border)}
.ai-av{width:32px;height:32px;border-radius:10px;background:linear-gradient(135deg,#6366f1,#2563eb);color:#fff;display:grid;place-items:center;flex:none}
.ai-av.lg{width:48px;height:48px;font-size:22px;border-radius:14px;margin:0 auto 8px}
.ai-log{flex:1;overflow-y:auto;padding:16px 14px;display:flex;flex-direction:column;gap:12px}
.ai-hello{text-align:center;margin:auto 0}.ai-hello h2{margin:4px 0}
.ai-sug{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:12px}.ai-sug .chip{cursor:pointer;text-align:left;font-size:13px}
.ai-msg{max-width:92%;font-size:14px;line-height:1.55}
.ai-msg.user{align-self:flex-end;background:var(--primary);color:#fff;border-radius:14px 14px 4px 14px;padding:9px 13px;white-space:pre-wrap}
.ai-msg.assistant{align-self:flex-start;width:92%}
.ai-msg.assistant .ai-body{background:var(--bg);border:1px solid var(--border);border-radius:14px 14px 14px 4px;padding:10px 13px;overflow-x:auto}
.ai-body p{margin:0 0 8px}.ai-body p:last-child{margin-bottom:0}.ai-body ul,.ai-body ol{margin:4px 0 8px;padding-left:20px}
.ai-body table{font-size:12.5px;margin:6px 0;background:var(--surface)}.ai-body th,.ai-body td{padding:5px 8px}
.ai-tool{font-size:12px;color:var(--muted);margin:0 0 4px 4px}
.ai-err{font-size:13px;color:var(--danger);margin-top:6px}
.ai-input{display:flex;gap:8px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--border);align-items:flex-end}
.ai-input textarea{flex:1;resize:none;min-height:42px;max-height:140px;line-height:1.4}
.ai-dots{display:inline-flex;gap:4px}.ai-dots i{width:6px;height:6px;border-radius:50%;background:var(--muted);animation:aidot 1s infinite}.ai-dots i:nth-child(2){animation-delay:.15s}.ai-dots i:nth-child(3){animation-delay:.3s}
@keyframes aidot{0%,80%,100%{opacity:.25}40%{opacity:1}}
@media (max-width:640px){.ai-panel{border-left:0}body.ai-open{overflow:hidden}}

/* baris filter di bawah judul halaman (cari + pilihan), terpisah dari tombol aksi */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: -6px 0 14px; }
.filter-bar .search { flex: 1 1 280px; max-width: none; }
.filter-bar select, .filter-bar input[type=date] { width: auto; flex: 0 1 auto; }
.filter-bar .fl { font-size: 12.5px; color: var(--muted); }
@media (max-width: 640px) {
  .filter-bar .search { flex: 1 1 100%; }
  .filter-bar select, .filter-bar input[type=date] { flex: 1 1 140px; min-width: 0; }
}
/* Jual di Kasir: dua kolom di desktop, satu kolom di tablet/HP */
.grid2.jual-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
@media (max-width: 1024px) { .grid2.jual-grid { grid-template-columns: minmax(0, 1fr); } }
.cart-tbl td { vertical-align: middle; }
@media (max-width: 640px) { .cart-tbl input[data-q] { width: 56px !important; } .cart-tbl input[data-p] { width: 96px !important; } .cart-tbl th, .cart-tbl td { padding-left: 6px; padding-right: 6px; } .cart-tbl th:nth-child(4), .cart-tbl td:nth-child(4) { display: none; } }
.pick-item { display: flex; width: 100%; justify-content: space-between; gap: 10px; margin-bottom: 6px; text-align: left; height: auto; padding: 8px 12px; white-space: normal; }
.pick-item > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.pick-item > span:last-child { flex: none; font-weight: 600; }
/* pilihan dokumen + cari: berdampingan di desktop, bertumpuk di HP */
.doc-pick { display: flex; gap: 8px; }
.doc-pick > input { flex: 1 1 40%; min-width: 0; }
.doc-pick > select { flex: 1 1 60%; min-width: 0; }
@media (max-width: 640px) { .doc-pick { flex-direction: column; } .doc-pick > input, .doc-pick > select { flex: none; width: 100%; } }
/* pilihan jenis retur */
.choice-list { display: grid; gap: 10px; }
.choice-list .btn { height: auto; padding: 12px 14px; text-align: left; justify-content: flex-start; white-space: normal; flex-direction: column; align-items: flex-start; gap: 2px; }
.choice-list .btn small { color: var(--muted); font-weight: 400; }

/* pilihan tema */
.theme-seg { display: flex; gap: 2px; padding: 3px; background: var(--chip); border-radius: 9px; }
.theme-seg button { flex: 1; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; padding: 6px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.theme-seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
/* kertas (struk, label, pratinjau cetak) selalu putih */
.paper, .paper * { color-scheme: light; }

/* logo Grahamedia.NET: latar putih bawaan gambar dibuat chip putih agar tetap rapi di tema gelap */
.logo-img { height: 34px; width: auto; max-width: 150px; object-fit: contain; flex: none; background: #fff; border-radius: 8px; padding: 3px 6px; }
.brand-logo { flex-direction: column; align-items: flex-start; gap: 4px; }
.login-card .brand-logo .logo-img { height: 48px; max-width: 220px; }
@media (max-width: 640px) { .pt-top .logo-img, .pub-top .logo-img { height: 28px; max-width: 110px; } }

/* ===== Header halaman: judul + tombol aksi di baris 1 (kanan), filter di baris 2 =====
   Semua halaman menaruh filter & tombol dalam satu .actions; di sini dipisah tanpa mengubah markup. */
.page-head { gap: 10px; }
.page-head .actions { display: contents; }
.page-head > h1, .page-head > div:first-child:not(.actions) { margin: 0 auto 0 0; min-width: 0; }
.page-head > div:first-child:not(.actions) h1 { margin: 0; }
.page-head .actions > * { order: 1; }
.page-head .actions > :is(select, input, textarea, label, .search, .chips, .seg, .filters, .fl, #qchip) { order: 3; width: auto; }
.page-head:has(.actions > :is(select, input, label, .search, .chips, .seg, .filters))::after { content: ''; order: 2; flex-basis: 100%; height: 0; }
.page-head .actions > .search, .page-head .actions > input[type=search], .page-head .actions > input:not([type]) { flex: 1 1 240px; max-width: 360px; }
.page-head .actions > select { flex: 0 1 auto; min-width: 140px; max-width: 220px; }
.page-head .actions > input[type=date], .page-head .actions > input[type=month] { flex: 0 0 auto; width: 160px; }

/* ===== Tabel: tinggi maksimal + header tetap terlihat saat scroll ===== */
@media (min-width: 641px) {
  .card .table-wrap { max-height: min(68vh, 760px); overflow: auto; overscroll-behavior: contain; }
  .modal .table-wrap { max-height: 55vh; }
  .table-wrap thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); box-shadow: inset 0 -1px 0 var(--border); }
  .table-wrap tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--surface); }
  .pager { position: relative; border-top: 1px solid var(--surface-2); }
}
@media (max-width: 640px) {
  .page-head > h1 { flex: 1 1 auto; }
  .page-head .actions > :is(.btn, button, a.btn) { flex: 0 0 auto; }
  .page-head .actions > :is(select, input, .search) { flex: 1 1 140px; max-width: none; min-width: 0; }
  .page-head .actions > .search { flex-basis: 100%; order: 3; }
}
.settings-panel { display: grid; gap: 14px; max-width: 920px; }
[data-panel][hidden] { display: none !important; }
.tbl-tools { display: flex; justify-content: flex-end; margin: -6px 0 4px; }
.tbl-tools .btn { color: var(--muted); }
.tbl-tools .btn:hover { color: var(--text); }
@media print { .tbl-tools { display: none !important; } }

/* atribut hidden selalu menang atas display komponen (form-grid, label.f, dll.) */
[hidden] { display: none !important; }

/* galeri gambar OCR rekonsiliasi */
.gal-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
.gal-card{padding:0;overflow:hidden;text-align:left;cursor:pointer;font:inherit;color:inherit;display:flex;flex-direction:column;transition:box-shadow .15s,border-color .15s}
.gal-card:hover,.gal-card:focus-visible{border-color:var(--primary);box-shadow:0 0 0 2px var(--primary-50)}
.gal-card.gal-fail{border-color:var(--danger-200,#fecaca)}
.gal-img{height:190px;background:var(--surface-2,#f3f4f6);display:flex;align-items:center;justify-content:center;overflow:hidden;border-bottom:1px solid var(--border)}
.gal-img img{width:100%;height:100%;object-fit:cover;object-position:top}
.gal-meta{padding:10px 12px}
@media (max-width:520px){.gal-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.gal-img{height:150px}}

/* dialog bukukan uang masuk (rekonsiliasi) */
.rcv-sum{display:flex;gap:16px;align-items:center;padding:12px 14px;border:1px solid var(--border);border-radius:10px;background:var(--surface-2,var(--bg))}
.rcv-amt{font-size:22px;font-weight:700;white-space:nowrap}
.pick-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px}
.pick-card{display:flex;flex-direction:column;gap:4px;text-align:left;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--card,#fff);color:inherit;font:inherit;cursor:pointer;transition:border-color .15s,box-shadow .15s}
.pick-card:hover{border-color:var(--primary)}
.pick-card:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.pick-card.on{border-color:var(--primary);box-shadow:0 0 0 2px var(--primary-50);background:color-mix(in srgb,var(--primary) 6%,var(--card,#fff))}
.pick-top{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}
.pick-dot{flex:none;width:16px;height:16px;border-radius:50%;border:2px solid var(--border);margin-top:2px}
.pick-card.on .pick-dot{border-color:var(--primary);background:radial-gradient(circle,var(--primary) 45%,transparent 50%)}
.pick-sub{font-size:12.5px}
.pick-why{display:flex;flex-wrap:wrap;gap:4px}
.pick-why .badge{font-size:11px;text-transform:none}
.rcv-search{position:absolute;left:0;right:0;z-index:5;background:var(--card,#fff);border-radius:8px;box-shadow:0 6px 20px rgba(0,0,0,.12)}
.rcv-hit{display:flex;width:100%;gap:8px;padding:9px 12px;border:0;border-bottom:1px solid var(--border);background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}
.rcv-hit:hover,.rcv-hit:focus-visible{background:var(--surface-2,var(--bg))}
.rcv-inv{border:1px solid var(--border);border-radius:10px;max-height:260px;overflow:auto}
.rcv-row{display:flex;gap:10px;align-items:flex-start;padding:9px 12px;border-bottom:1px solid var(--border);cursor:pointer}
.rcv-row:last-child{border-bottom:0}
.rcv-row input{width:auto;margin-top:3px}
@media (max-width:520px){.rcv-sum{flex-direction:column;align-items:flex-start;gap:6px}.pick-grid{grid-template-columns:1fr}}

/* ===== Pencarian global ===== */
.gs-btn{gap:8px;color:var(--muted);border:1px solid var(--border);background:var(--surface-2);min-width:0}
.gs-btn .gs-ph{font-weight:400;max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gs-btn kbd,.gs-foot kbd{font:11px/1 inherit;border:1px solid var(--border-strong);border-radius:4px;padding:2px 5px;color:var(--muted);background:var(--surface)}
.gs-bg{position:fixed;inset:0;z-index:300;background:rgba(15,17,23,.45);display:flex;justify-content:center;align-items:flex-start;padding:8vh 16px 16px}
.gs-panel{width:100%;max-width:640px;max-height:80vh;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:0 20px 50px rgba(0,0,0,.25);overflow:hidden}
.gs-in{display:flex;align-items:center;gap:10px;padding:10px 12px;border-bottom:1px solid var(--border)}
.gs-in input{border:0;outline:0;background:transparent;font-size:16px;flex:1;min-width:0;padding:6px 0;box-shadow:none}
.gs-res{overflow:auto;padding:6px;min-height:60px}
.gs-res.busy{opacity:.7}
.gs-grp{font-size:11.5px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);padding:10px 10px 4px}
.gs-item{display:flex;gap:10px;align-items:flex-start;padding:8px 10px;border-radius:8px;color:inherit;text-decoration:none}
.gs-item.on{background:var(--primary-50)}
.gs-item .gs-ic{width:22px;text-align:center;flex:none}
.gs-item .gs-tx{min-width:0;display:flex;flex-direction:column}
.gs-item b{font-weight:600;overflow-wrap:anywhere}
.gs-item small{color:var(--muted);font-size:12.5px;overflow-wrap:anywhere}
.gs-item mark{background:var(--yellow-200);color:inherit;border-radius:2px;padding:0 1px}
.gs-hint{padding:14px 10px;color:var(--muted);font-size:13.5px}
.gs-foot{display:flex;gap:16px;padding:8px 14px;border-top:1px solid var(--border);color:var(--muted);font-size:12px}
@media (max-width:640px){.gs-btn .gs-ph,.gs-btn kbd{display:none}.gs-bg{padding:0}.gs-panel{max-width:none;max-height:100vh;height:100%;border-radius:0;border:0}.gs-btn{border:0;background:transparent}}
@media (hover:none){.gs-btn kbd,.gs-foot{display:none}}

/* ===== Aksesibilitas (audit UI/UX Pro Max): kontras badge & tombol, target sentuh, gerak ===== */
/* teks badge status: warna lebih gelap di tema terang agar kontras ≥ 4.5:1 (sebelumnya hijau 3.1, oranye 3.0) */
:root { --success-text: #15803d; --warn-text: #b45309; --danger-text: #b91c1c; --primary-text: var(--primary); --btn-primary-bg: var(--primary); }
:root[data-theme="dark"] { --success-text: var(--success); --warn-text: var(--warn); --danger-text: var(--danger); --primary-text: #86a8f2; --btn-primary-bg: #3a68cc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --success-text: var(--success); --warn-text: var(--warn); --danger-text: var(--danger); --primary-text: #86a8f2; --btn-primary-bg: #3a68cc; } }
.badge.approved, .badge.posted, .badge.disbursed { color: var(--primary-text); }
.badge.received, .badge.partial, .badge.pending, .badge.submitted, .badge.requested, .badge.partially_ordered { color: var(--warn-text); }
.badge.paid, .badge.active, .badge.settled, .badge.ordered { color: var(--success-text); }
.badge.cancelled, .badge.inactive, .badge.rejected { color: var(--danger-text); }
/* tombol utama di tema gelap: teks putih di atas biru #5b8def hanya 3.2:1 → latar #3a68cc (5.2:1) */
.btn.primary { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); }
/* layar sentuh: target minimal 44px; tombol kecil tetap ringkas tapi area sentuhnya diperluas */
@media (pointer: coarse) {
  .btn { min-height: 44px; min-width: 44px; }
  input, select { min-height: 44px; }
  .btn.sm { position: relative; }
  .btn.sm::after { content: ''; position: absolute; inset: -7px -4px; }
  .nav a, .tabs a { min-height: 44px; }
}
/* hormati pengaturan "kurangi gerakan" di sistem operasi */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* ikon SVG tombol (ui-icons.js) */
.ui-ic { flex: none; width: 16px; height: 16px; vertical-align: -3px; }
.btn.sm .ui-ic { width: 14px; height: 14px; }
/* teks abu di atas latar biru muda (banner tutorial) — kontras 4.39 → ≥ 4.5 */
.tut-hint .muted { color: var(--text-2); }
/* tautan nama pelanggan di tabel: area sentuh diperluas di layar sentuh */
@media (pointer: coarse) { .cust-link { position: relative; } .cust-link::after { content: ''; position: absolute; inset: -14px -4px; } }
/* kartu pilihan pelanggan: latar ikut tema (sebelumnya putih di tema gelap, nama tak terbaca) */
.pick-card { background: var(--surface); color: var(--text); }
.pick-card.on { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
/* dialog periksa mutasi OCR: lebih lebar, kolom teks lega */
.modal.rv-modal { max-width: 1240px; }
.rv-grid { grid-template-columns: minmax(0, 0.9fr) minmax(0, 2fr); }
.rv-tbl { table-layout: fixed; width: 100%; }
.rv-tbl .rv-on { width: 56px; } .rv-tbl .rv-date { width: 150px; } .rv-tbl .rv-amt { width: 140px; }
.rv-tbl input, .rv-tbl textarea { width: 100%; min-width: 0; }
.rv-tbl .rv-txt > * { display: block; } .rv-tbl .rv-txt > * + * { margin-top: 4px; }
.rv-tbl textarea { resize: vertical; min-height: 0; height: auto; padding: 6px 10px; line-height: 1.35; font: inherit; font-size: 13.5px; }
.rv-tbl td { vertical-align: top; }
@media (max-width: 900px) { .rv-grid { grid-template-columns: 1fr; } }
.rv-tbl th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.rv-tbl .rv-on { width: 72px; }
/* pilihan mutasi bank di dialog bukti transfer: radio kecil di kiri, teks rata kiri, label status di kanan */
.stm-opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left; margin-bottom: 8px; }
.stm-opt:hover { border-color: var(--primary); }
.stm-opt:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.stm-opt:has(input:disabled) { opacity: .6; cursor: default; }
.stm-opt input[type=radio] { width: auto; min-height: 0; flex: none; margin-top: 3px; }
.stm-opt .grow { min-width: 0; overflow-wrap: anywhere; }
.stm-opt .badge { flex: none; align-self: center; }
.choice-list .stm-opt { margin-bottom: 0; align-items: center; }
/* daftar tagihan di dialog bukti transfer: muat di layar HP tanpa nominal terpotong */
.inv-pick td { padding: 9px 8px; }
.inv-pick td:last-child { white-space: nowrap; text-align: right; }
@media (max-width: 640px) { .inv-pick td { padding: 8px 4px; font-size: 13.5px; } .inv-pick td:first-child { width: 30px; } }

/* ajakan aktifkan notifikasi push */
.push-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin: 0 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface, #fff); color: var(--text); font-size: 14px; }
.push-banner > span:first-child { font-size: 20px; }
#pushbar:empty { display: none; }
#pushbar { padding: 12px 24px 0; }
@media (max-width: 720px) { #pushbar { padding: 10px 12px 0; } }
.leaflet-popup-content .btn { color: inherit; }
.leaflet-container { isolation: isolate; z-index: 0; } /* peta tidak menimpa panel AI, sidebar, modal */

/* pendaftaran portal: pilihan kategori Personal / Bisnis */
.seg-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg-opt { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; }
.seg-opt input { width: auto; margin-top: 3px; }
.seg-opt span { display: flex; flex-direction: column; gap: 2px; }
.seg-opt small { color: var(--muted); font-size: 12.5px; }
.seg-opt:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
@media (max-width: 480px) { .seg-opts { grid-template-columns: 1fr; } }
.terms h2 { font-size: 1.2em; margin: 18px 0 6px; } .terms h3 { font-size: 1.05em; margin: 16px 0 6px; } .terms h4 { margin: 12px 0 4px; }
.terms p, .terms li { line-height: 1.6; } .terms ul, .terms ol { padding-left: 22px; margin: 4px 0 10px; }

/* kotak foto di form staf (KTP, NPWP, foto lokasi) */
.photo-pick .pp-pv { width: 96px; height: 68px; border-radius: 8px; background: var(--bg-soft, rgba(0,0,0,.05)); display: flex; align-items: center; justify-content: center; font-size: 24px; overflow: hidden; flex: none; }
.photo-pick .pp-pv img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .req-star { color: var(--danger); }

/* bar atas tabel: jumlah baris + tombol Excel */
.ptable-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px 10px; font-size: 13px; }

/* responsif HP: kolom grid tidak boleh melebar mengikuti isi */
#wa > div, .grid2 > * { min-width: 0; }
#wa #cl { overflow-x: hidden; }
@media (max-width: 720px) {
  #rwf { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; }
  #rwf > label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; grid-column: 1 / -1; min-width: 0; }
  #rwf > label:has([name=sfrom]), #rwf > label:has([name=sto]), #rwf > label:has([name=from]), #rwf > label:has([name=to]) { grid-column: auto; }
  #rwf input, #rwf select { width: 100% !important; max-width: 100%; min-width: 0; }
  #rwf > .btn { grid-column: auto; justify-content: center; }
  #rwf > .btn:only-of-type { grid-column: 1 / -1; }
}

/* isi chat WA di HP: header ringkas, kotak balas selalu terlihat */
.wa-act { display: contents; }
@media (max-width: 760px) {
  .wa-chatting .page-head { display: none; }
  .wa-chatting #wa { height: calc(100dvh - 205px - var(--sbx-h, 0px)) !important; min-height: 320px !important; }
  .wa-hd { gap: 8px !important; padding: 8px 10px !important; }
  .wa-hd .wa-nm { flex: 1 1 0; min-width: 0; }
  .wa-hd .wa-nm > b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wa-hd .wa-nm > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wa-hd .avatar, .wa-hd img { width: 36px !important; height: 36px !important; }
  .wa-act { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; align-items: center; }
  .wa-act .btn { padding: 5px 10px; font-size: 12.5px; }
  .wa-act #asg { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wa-chatting #ms { padding: 10px !important; }
}
@media (max-width: 760px) {
  .wa-act details > .card { position: fixed !important; left: 12px !important; right: 12px; min-width: 0 !important; max-height: 60vh; overflow: auto; }
}

/* email asli (Rekonsiliasi → Email) */
.modal.emhtml { max-width: 1400px; }
.em-split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; height: 72vh; }
.em-ocr { overflow-y: auto; min-height: 0; max-height: 72vh; padding-right: 4px; overscroll-behavior: contain; }
.em-split > * { min-height: 0; }
#emread .em-split { height: calc(100vh - 230px); min-height: 420px; }
#emread .em-ocr { max-height: calc(100vh - 230px); }
.em-doc { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.em-pane { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; min-height: 0; }
@media (max-width: 760px) { .em-split, #emread .em-split { grid-template-columns: 1fr; height: auto; } .em-pane { height: 65vh; } .em-ocr, #emread .em-ocr { max-height: 70vh; } }

/* Mode Sandbox */
.sbx-bar { margin: 12px 24px 0; padding: 10px 14px; border-radius: 10px; background: repeating-linear-gradient(135deg, #fde68a 0 14px, #fcd34d 14px 28px); color: #422006; font-size: 13.5px; }
.sbx-bar a { color: #422006; text-decoration: underline; font-weight: 600; }
#sbxbar:empty { display: none; }
.sbx-body { white-space: pre-wrap; word-break: break-word; font-size: 13px; max-height: 160px; overflow: auto; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .sbx-bar { margin: 10px 12px 0; } .grid4 { grid-template-columns: 1fr 1fr; } }

/* detail layanan: ringkasan + tab teknis / tagihan / riwayat */
.sv-head{display:flex;gap:12px;align-items:flex-start;margin-bottom:12px}.sv-who>b{font-size:16px}
.sv-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:14px}
.sv-kpi{border:1px solid var(--border);border-radius:12px;padding:10px 12px;background:var(--surface-2);display:flex;flex-direction:column;gap:2px;min-width:0}
.sv-kpi>span{font-size:11.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.sv-kpi b{font-size:17px}.sv-kpi small{font-size:11.5px;color:var(--muted)}
.sv-tabs{display:flex;gap:4px;border-bottom:1px solid var(--border);margin-bottom:14px;overflow-x:auto}
.sv-tabs button{background:none;border:0;border-bottom:2px solid transparent;padding:9px 14px;font:inherit;font-weight:600;color:var(--muted);cursor:pointer;white-space:nowrap;margin-bottom:-1px}
.sv-tabs button.on{color:var(--primary);border-bottom-color:var(--primary)}
.sv-h{font-size:14px;margin:16px 0 8px}.sv-h:first-child{margin-top:0}.sv-h .muted{font-weight:400;font-size:12px}
@media (max-width:640px){.sv-kpis{grid-template-columns:repeat(2,1fr)}}

/* kondisi jaringan (data OLT) di panel chat & tiket */
.net-card{border:1px solid var(--border);border-radius:10px;padding:8px 10px;margin-bottom:8px;background:var(--surface);font-size:13px}
.net-grid{display:grid;grid-template-columns:auto 1fr;gap:2px 10px;margin-top:6px;font-size:12.5px}.net-grid>span:nth-child(odd){color:var(--muted)}
.net-st{font-weight:600;white-space:nowrap}.net-st.ok{color:var(--success)}.net-st.warn{color:var(--warn)}.net-st.bad{color:var(--danger)}
.net-hint{margin-top:6px;padding:5px 8px;border-radius:8px;background:var(--surface-2);font-size:12px}
.net-snap{border:1px solid var(--border);border-radius:10px;padding:8px 12px;margin:12px 0}.net-snap summary{cursor:pointer;font-weight:600}.net-snap[open] summary{margin-bottom:8px}
