/* SiDIVA-TS UI — identitas "Buku Kas": konsol pembukuan dealer pulsa.
   Keputusan desain (disengaja, bukan default):
   - Satu keluarga abu WARM (kertas → grafit); light "Kertas" = default,
     dark "Karbon" via toggle (preferensi tersimpan, prefer-color-scheme dihormati).
   - Satu aksen: biru tinta pulpen (aksi utama, posisi aktif, fokus).
     Status: hijau tinta (ok), vermillion (gagal), cokelat tinta (peringatan).
   - Tipografi: IBM Plex Sans self-hosted (nol network runtime, karakter
     "struk tercetak") + IBM Plex Mono utk SEMUA angka/uang (tabular).
   - Shape lock: panel 8px, kontrol 6px, chip/stempel 4px — tanpa kecuali.
   - Signature: double rule akuntansi di bawah saldo (baris total buku),
     tabel bergaris rambut, chip status seperti stempel (mono, uppercase).
   - Shadow hanya utk elevasi nyata: drawer mobile & scrim modal.
   - Motion: hover + transisi drawer 200ms — data yang dibaca tak pernah
     bergeser demi gaya. */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/plex-sans-var.woff2") format("woff2") tech("variations");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ── Token: Kertas (light, default) ─────────────────────────────────── */
:root {
  --bg: #f3f0e8;            /* meja kerja */
  --surface: #fcfbf7;       /* lembar kertas (panel) */
  --surface-2: #f0ede3;     /* kertas naik 1 tingkat (thead, drawer, modal) */
  --border: #ddd7c5;        /* garis rambut */
  --border-strong: #c6bda4; /* garis lipatan/tepi */
  --rule2: #b3a98c;         /* double rule (garis total pembukuan) */
  --text: #211e16;          /* tinta */
  --muted: #6e685a;         /* tinta encer */
  --acc: #1d47c2;           /* biru tinta pulpen */
  --acc-press: #16389c;
  --acc-soft: rgb(29 71 194 / .07);
  --acc-btn: #1d47c2;       /* isi tombol utama */
  --on-acc: #ffffff;
  --ok: #156b3b;
  --bad: #b3361d;
  --warn: #8a6410;
  --row-alt: rgb(33 30 22 / .02);
  --row-hover: rgb(33 30 22 / .045);
  --scrim: rgb(43 39 28 / .35);
  /* shape lock */
  --r-lg: 8px;   /* panel, modal */
  --r-md: 6px;   /* tombol, input */
  --r-sm: 4px;   /* chip/stempel */
  /* skala spasi */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, ui-monospace, monospace;
}

/* ── Token: Karbon (dark) ───────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg: #191712;
  --surface: #201e18;
  --surface-2: #2a2720;
  --border: #3a352b;
  --border-strong: #4c4638;
  --rule2: #5a5342;
  --text: #ece8dc;
  --muted: #a79f8c;
  --acc: #a9bcff;
  --acc-press: #c2d0ff;
  --acc-soft: rgb(169 188 255 / .09);
  --acc-btn: #7d93f5;
  --on-acc: #141833;
  --ok: #7cc29a;
  --bad: #e9846b;
  --warn: #d0a24d;
  --row-alt: rgb(255 255 255 / .02);
  --row-hover: rgb(255 255 255 / .05);
  --scrim: rgb(10 9 6 / .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
::selection { background: var(--acc-soft); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* kode produk panjang: tampil pendek, klik untuk copy full string */
.clickable { cursor: pointer; border-bottom: 1px dotted var(--muted); }
.clickable:hover { color: var(--acc); border-bottom-color: var(--acc); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--warn); }

/* ── Gerbang login ─────────────────────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.gate-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--s5);
  display: grid;
  gap: var(--s3);
  box-shadow: 0 1px 0 var(--border), 0 12px 32px -20px rgb(33 30 22 / .25);
}
.gate-card h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.gate-card p { margin: 0; }
/* penanda langkah: stempel kecil — posisi dalam alur, bukan hiasan */
.gate-step {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--s2);
}
label { display: grid; gap: var(--s1); font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-soft);
}
.check { display: flex; align-items: center; gap: var(--s2); color: var(--muted); }
.check input { width: auto; }
.msg { min-height: 18px; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }

/* ── Tombol ────────────────────────────────────────────────────────── */
.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 7px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); background: var(--surface-2); }
.btn:active { background: var(--bg); }
.btn.primary {
  background: var(--acc-btn);
  border-color: transparent;
  color: var(--on-acc);
  font-weight: 600;
}
.btn.primary:hover { background: var(--acc-press); border-color: transparent; }
.btn.ghost {
  background: none;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 4px 0;
  width: 100%;
  font-weight: 400;
}
.btn.ghost:hover { color: var(--text); background: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.sm { padding: 3px 10px; border-radius: var(--r-sm); font-size: 12px; }

/* ── Layout app: topbar + (sidebar | main) ─────────────────────────── */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }

/* Topbar: kepala buku — lokasi, saldo (stempel), tema */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s5);
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title .tt { font-weight: 700; letter-spacing: .2px; }
.top-view { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
/* stempel saldo: angka mono dalam bingkai tinta */
.saldo-chip {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg);
}
/* toggle tema: ikon sun/moon (svg sprite) */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  padding: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

/* hamburger: 3 garis CSS, hanya tampil di layar sempit */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 9px 10px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.nav-toggle .bar { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; }
.nav-toggle:hover { border-color: var(--muted); }

.app-body { display: grid; grid-template-columns: 224px 1fr; }

/* Sidebar: kelompok berlabel + divider antar kategori.
   Struktur: head / .side-scroll (menu, ini yang discroll) / .side-foot
   (dev tools + logout — DI LUAR scroll, selalu fix di dasar). */
.side {
  border-right: 1px solid var(--border);
  padding: var(--s4) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  position: sticky;
  top: 46px;
  height: calc(100vh - 46px);
  background: var(--bg);
}
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s3); }
.side-head { display: grid; gap: 2px; padding: 0 var(--s2) var(--s2); flex-shrink: 0; }
.tt { font-weight: 700; letter-spacing: .2px; }
.nav-group { display: grid; gap: 2px; }
/* divider antar kategori — garis lipatan buku */
.nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: var(--s3); }
.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  padding: 0 var(--s2);
  margin-bottom: var(--s1);
}
.side a[data-view] {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.side a[data-view]:hover { color: var(--text); background: var(--surface); }
.side a[data-view].on { color: var(--acc); background: var(--acc-soft); }
.side-foot { flex-shrink: 0; padding-top: var(--s3); display: grid; gap: 2px; border-top: 1px solid var(--border); }
.side-foot a { color: var(--muted); text-decoration: none; font-size: 12px; padding: 4px 2px; display: flex; align-items: center; gap: 8px; }
.side-foot a:hover { color: var(--text); }
.side-foot .btn.ghost { display: flex; align-items: center; gap: 8px; }

/* ikon svg (sprite symbol): mengikuti warna teks, ukuran seragam */
.ic { width: 16px; height: 16px; flex-shrink: 0; }
.side a .ic { opacity: .7; }
.side a:hover .ic, .side a[data-view].on .ic { opacity: 1; }

/* stempel merek "Rp" — satu glyph di topbar/sidebar/gerbang */
.brand { width: 22px; height: 22px; flex-shrink: 0; vertical-align: -4px; }
.gate-brand { display: flex; align-items: center; gap: 10px; }
.gate-brand h1 { margin: 0; font-size: 17px; letter-spacing: .2px; }

.main { padding: var(--s5) var(--s6) 64px; min-width: 0; }
.view { max-width: 1080px; }
.view.wide { max-width: 1380px; } /* view tabel lebar */

/* ── Komponen konten ───────────────────────────────────────────────── */
h2.view-t { font-size: 18px; font-weight: 600; margin: 0 0 var(--s1); }
.view-sub { color: var(--muted); margin: 0 0 var(--s5); }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  margin-bottom: var(--s4);
}
.panel > h3 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .9px;
  margin: 0 0 var(--s3);
  color: var(--muted);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
label.inline { display: grid; gap: var(--s1); font-size: 12px; color: var(--muted); }
.row { display: flex; gap: var(--s2); align-items: end; flex-wrap: wrap; }
.row > .grow { flex: 1; }

/* hero saldo = baris total pembukuan: label stempel, angka mono besar,
   DOUBLE RULE di bawahnya (konvensi akuntansi utk baris total). */
.hero { padding: var(--s5); }
.hero .k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
}
.hero .v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.5px;
  display: block;
  margin: var(--s2) 0 var(--s3);
  padding-bottom: var(--s3);
  border-bottom: 3px double var(--rule2);
}

/* kartu angka sekunder — bingkai tipis, angka mono */
.stat {
  display: grid;
  gap: 2px;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.stat .k {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
}
.stat .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; }

/* tabel = baris pembukuan: garis rambut, kepala mono kecil,
   angka rata kanan tabular */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: var(--s2) 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 60vh; }

/* sortir kolom via klik header: 1x naik, 2x turun, 3x urutan awal */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sa::after { content: " ↑"; color: var(--acc); }
th.sd::after { content: " ↓"; color: var(--acc); }
.sort-bar { display: none; }
.schip {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 3px 10px;
  font: 500 12px var(--font-ui);
  min-height: 30px;
  cursor: pointer;
}
.schip:hover { color: var(--text); border-color: var(--muted); }
.schip.on { color: var(--acc); border-color: var(--acc); background: var(--acc-soft); font-weight: 600; }

/* pemilih operator (segmen): kontrol 6px, tombol dalam 4px — shape lock.
   Aktif = aksen lembut, bukan tombol penuh: ini pilihan, bukan aksi utama. */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin: 4px 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
}
.seg-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 6px 14px;
  font: 500 13px var(--font-ui);
  color: var(--muted);
  cursor: pointer;
  min-height: 34px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on {
  background: var(--acc-soft);
  border-color: var(--acc);
  color: var(--acc);
  font-weight: 600;
}

/* hasil JSON / transcript */
pre.json {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s3);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
}

/* "Respons lengkap" jadi details — hemat ruang, tetap jujur */
details.panel > summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
}
details.panel > summary:hover { color: var(--text); }

/* chip status = stempel: mono uppercase dalam bingkai tinta */
.chip {
  display: inline-block;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 1px 8px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.bad { color: var(--bad); border-color: var(--bad); }

/* modal */
.modal-back { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: var(--s4); z-index: 40; }
.modal {
  width: min(680px, 100%);
  max-height: 84vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: 0 24px 48px -24px rgb(0 0 0 / .4);
}
.modal h3 { margin: 0 0 var(--s3); font-size: 15px; }

/* toast — feedback aksi */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--acc);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  z-index: 50;
  max-width: 340px;
  box-shadow: 0 12px 32px -16px rgb(0 0 0 / .35);
}
.toast.bad { border-left-color: var(--bad); }

/* keranjang mini grosir */
.count {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  background: var(--acc-btn);
  color: var(--on-acc);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 0 4px;
}

/* ── Mobile (< 900px): drawer off-canvas ───────────────────────────── */
.side-backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 29; }
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .app-body { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(280px, 84vw);
    height: 100vh;
    z-index: 30;
    background: var(--surface-2);
    transform: translateX(-100%);
    transition: transform .2s ease; /* mengungkap nav — tujuan UX, sekali jalan */
    padding: var(--s4);
    gap: var(--s3);
  }
  .side.open { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / .45); }
  .side-head { display: none; } /* identitas sudah di topbar */
  .main { padding: var(--s4) var(--s4) 64px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  /* target sentuh: nav & tombol minimal 44px */
  .side a[data-view] { padding: 12px 10px; font-size: 15px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 32px; }
  .seg { display: flex; width: 100%; }
  .seg-btn { flex: 1; min-height: 44px; }
  input, select, textarea { font-size: 16px; } /* cegah auto-zoom iOS */
  .toast { left: var(--s4); right: var(--s4); max-width: none; }
  .topbar { padding: 10px var(--s4); }
  .topbar-title .tt { display: none; }
  .hero .v { font-size: 28px; }
}

/* ── Mobile (< 720px): tabel padat jadi kartu berlabel ─────────────── */
@media (max-width: 720px) {
  .sort-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s1);
    margin-bottom: var(--s3);
  }
  .tbl-wrap.dense { max-height: none; overflow: visible; }
  .tbl-wrap.dense table, .tbl-wrap.dense tbody,
  .tbl-wrap.dense tr, .tbl-wrap.dense td { display: block; width: 100%; }
  .tbl-wrap.dense thead { display: none; }
  .tbl-wrap.dense tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s3) var(--s4);
    margin-bottom: var(--s3);
  }
  .tbl-wrap.dense tr:nth-child(even) { background: var(--surface); }
  .tbl-wrap.dense tr:hover { background: var(--surface); }
  .tbl-wrap.dense td {
    display: flex;
    gap: var(--s3);
    align-items: baseline;
    border: none;
    padding: 3px 0;
    white-space: normal;
    overflow: visible;
  }
  .tbl-wrap.dense td::before {
    content: attr(data-label);
    flex: 0 0 118px;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
  }
  .tbl-wrap.dense td:first-child { font-family: var(--font-mono); }
}
