/* Hutang Pemasok Madani — navy korporat, putih bersih, rapi */
:root {
  --navy: #13294b; --navy-2: #1d3a66; --navy-soft: #e8edf5; --gold: #c9a55c;
  --bg: #f3f5f8; --card: #ffffff; --line: #e1e5eb; --line-2: #eef1f5;
  --text: #17202b; --muted: #66707c; --faint: #98a1ac;
  --red: #c0352b; --red-soft: #fbeceb; --amber: #a86a00; --amber-soft: #fff4dc; --green: #1f7a4d; --green-soft: #e7f4ec;
  --r: 12px; --shadow: 0 1px 2px rgba(16, 32, 60, .06), 0 2px 8px rgba(16, 32, 60, .05);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); touch-action: manipulation; overflow-x: clip; max-width: 100%; }
body { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px !important; }
a { color: inherit; text-decoration: none; }
.num, .rp { font-variant-numeric: tabular-nums; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.muted { color: var(--muted); } .kecil { font-size: 13px; } .merah { color: var(--red); } .hijau { color: var(--green); }
.loading { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
svg { display: block; }

/* ===== Masuk ===== */
.login-wrap { min-height: 100vh; min-height: 100dvh; background: #fff; display: flex; justify-content: center; }
.login-in { width: 100%; max-width: 420px; padding: calc(56px + var(--safe-t)) 24px calc(20px + var(--safe-b)); display: flex; flex-direction: column; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.login-brand .logo { width: 52px; height: 52px; border-radius: 14px; background: var(--navy); color: #fff; display: grid; place-items: center; flex: none; }
.login-brand .logo svg { width: 30px; height: 30px; }
.login-brand b { display: block; font-size: 20px; letter-spacing: -.01em; color: var(--navy); }
.login-brand span { font-size: 13px; color: var(--muted); }
.login-in h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.01em; }
.login-in .lead { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.login-in .inp { background: #f7f8fa; }
.login-in .inp:focus { background: #fff; }
.uji { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.uji .t { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.uji .row { display: flex; gap: 8px; flex-wrap: wrap; }
.powered { margin-top: auto; padding-top: 28px; text-align: center; font-size: 12px; color: var(--faint); }

/* ===== Isian ===== */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: #3b4652; }
.field small { color: var(--muted); font-size: 12px; }
.inp { width: 100%; min-width: 0; height: 46px; padding: 0 13px; border: 1px solid #cfd6df; border-radius: 10px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
textarea.inp { height: auto; min-height: 72px; padding: 11px 13px; resize: vertical; }
select.inp { background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1l5 5 5-5" fill="none" stroke="%2366707c" stroke-width="1.6"/></svg>') no-repeat right 13px center; padding-right: 34px; }
.inp:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(29, 58, 102, .14); }
.inp.num { text-align: right; font-variant-numeric: tabular-nums; }
.inp.janggal { border-color: var(--red); background: var(--red-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin: -4px 0 10px; }
.tgl-jelas { color: var(--muted); font-size: 12px; }

/* ===== Tombol ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 44px; padding: 0 16px; border: 1px solid #cfd6df; border-radius: 10px; background: #fff; font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: #efc9c5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.blok { width: 100%; }
.btn:disabled { opacity: .55; }
.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid #cfd6df; background: #fff; font-size: 14px; font-weight: 600; color: #3b4652; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ===== Kerangka aplikasi ===== */
.app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(76px + var(--safe-b)); }
.top { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: calc(10px + var(--safe-t)) 16px 12px; }
.top-row { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.top .logo { width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--navy); display: grid; place-items: center; flex: none; }
.top .logo svg { width: 21px; height: 21px; }
.top .judul { flex: 1; min-width: 0; }
.top .judul b { display: block; font-size: 16px; line-height: 1.2; }
.top .judul span { font-size: 12px; color: #b9c6da; }
.cab-row { max-width: 760px; margin: 10px auto 0; }
.cab-pick { display: flex; background: rgba(255, 255, 255, .1); border-radius: 9px; padding: 3px; }
.cab-pick button { border: 0; background: transparent; color: #c9d3e2; font-size: 13px; font-weight: 600; height: 30px; padding: 0 8px; border-radius: 7px; cursor: pointer; flex: 1; }
.cab-pick button.on { background: #fff; color: var(--navy); }
.cab-tag { font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, .14); padding: 5px 10px; border-radius: 7px; }
.isi { max-width: 760px; margin: 0 auto; padding: 16px; }
.powered-in { text-align: center; font-size: 12px; color: var(--faint); padding: 18px 0 6px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar-in { display: grid; grid-template-columns: repeat(5, 1fr); max-width: 760px; margin: 0 auto; height: 62px; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); border: 0; background: none; cursor: pointer; }
.tab svg { width: 23px; height: 23px; }
.tab.on { color: var(--navy); }
.tab-catat { display: flex; align-items: center; justify-content: center; border: 0; background: none; cursor: pointer; }
.tab-catat span { width: 50px; height: 50px; border-radius: 15px; background: var(--navy); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(19, 41, 75, .3); }
.tab-catat svg { width: 26px; height: 26px; }

/* ===== Kartu ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.sec-h h3 { margin: 0; font-size: 15px; font-weight: 700; }
.sec-h a, .sec-h button { font-size: 13px; color: var(--navy-2); font-weight: 600; background: none; border: 0; cursor: pointer; padding: 0; }
.hero { background: linear-gradient(0deg, var(--navy), var(--navy)); color: #fff; border-radius: 14px; padding: 18px; position: relative; overflow: hidden; }
.hero .l { font-size: 13px; color: #b9c6da; font-weight: 500; }
.hero .v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 2px; font-variant-numeric: tabular-nums; }
.hero .s { font-size: 13px; color: #c9d3e2; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border: 22px solid rgba(255, 255, 255, .05); border-radius: 50%; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat { padding: 13px 14px; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }
.stat.telat { border-color: #efc9c5; background: var(--red-soft); } .stat.telat .v { color: var(--red); }
.stat.segera .v { color: var(--amber); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.r { background: var(--red); } .dot.a { background: #e0a020; } .dot.g { background: var(--green); }
.aksi2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.aksi2 .btn { height: 50px; }

.list { overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line-2); cursor: pointer; }
.item:first-child { border-top: 0; }
.item:active { background: #f6f8fb; }
.item .av { width: 38px; height: 38px; border-radius: 10px; background: var(--navy-soft); color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tx span { font-size: 13px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .rt { text-align: right; flex: none; }
.item .rt b { display: block; font-variant-numeric: tabular-nums; font-weight: 700; }
.item .rt span { font-size: 12px; color: var(--muted); }
.item > svg { width: 18px; height: 18px; color: var(--faint); flex: none; }
.item .av svg { width: 20px; height: 20px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--line-2); color: var(--muted); vertical-align: 1px; }
.tag.r { background: var(--red-soft); color: var(--red); } .tag.a { background: var(--amber-soft); color: var(--amber); } .tag.g { background: var(--green-soft); color: var(--green); } .tag.n { background: var(--navy-soft); color: var(--navy); }
.kosong { padding: 30px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.kosong b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.cari { position: relative; margin-bottom: 12px; }
.cari svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.cari .inp { padding-left: 40px; }
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }

/* ===== Lapisan (layar yang ditumpuk) ===== */
.lapis { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; animation: masuk .22s ease-out; will-change: transform; }
.lapis.keluar { animation: keluar .18s ease-in forwards; }
@keyframes masuk { from { transform: translateX(100%); } to { transform: none; } }
@keyframes keluar { to { transform: translateX(100%); } }
.lapis-h { background: var(--navy); color: #fff; padding: calc(8px + var(--safe-t)) 8px 10px; display: flex; align-items: center; gap: 4px; flex: none; }
.lapis-h .kembali { width: 42px; height: 42px; border: 0; background: none; color: #fff; display: grid; place-items: center; cursor: pointer; border-radius: 10px; }
.lapis-h .kembali svg { width: 24px; height: 24px; }
.lapis-h .t { flex: 1; min-width: 0; }
.lapis-h .t b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lapis-h .t span { font-size: 12px; color: #b9c6da; }
.lapis-h .kanan { display: flex; gap: 2px; }
.lapis-h .kanan .btn { color: #fff; }
.lapis-b { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.lapis-b .isi { padding-bottom: 28px; }
.lapis-f { flex: none; background: #fff; border-top: 1px solid var(--line); padding: 10px 16px calc(10px + var(--safe-b)); display: flex; gap: 10px; }
.lapis-f .btn { flex: 1; height: 50px; }
.lapis-f .tot { flex: 1.2; display: flex; flex-direction: column; justify-content: center; }
.lapis-f .tot span { font-size: 12px; color: var(--muted); } .lapis-f .tot b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* Detail pemasok */
.saldo-box { background: var(--navy); color: #fff; padding: 4px 18px 18px; }
.saldo-box .l { font-size: 13px; color: #b9c6da; }
.saldo-box .v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.saldo-box .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: #c9d3e2; margin-top: 4px; }
.saldo-box .aksi2 .btn { border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); color: #fff; }
.saldo-box .aksi2 .btn.primary { background: #fff; color: var(--navy); border-color: #fff; }
.jt-box { padding: 12px 14px; }
.jt-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.jt-row:first-of-type { border-top: 0; }
.tgl-grp { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 16px 4px 6px; }
.ev { display: flex; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-2); cursor: pointer; }
.ev:first-child { border-top: 0; }
.ev:active { background: #f6f8fb; }
.ev .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.ev .ic svg { width: 18px; height: 18px; }
.ev.nota .ic { background: var(--navy-soft); color: var(--navy); }
.ev.bayar .ic { background: var(--green-soft); color: var(--green); }
.ev.batal { opacity: .5; } .ev.batal .tx b { text-decoration: line-through; }
.ev .tx { flex: 1; min-width: 0; }
.ev .tx b { display: block; font-weight: 600; font-size: 14px; }
.ev .tx span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ev .rt { text-align: right; flex: none; }
.ev .rt b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.ev .rt span { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev.bayar .rt b { color: var(--green); }

/* Formulir nota */
.brg { padding: 12px 12px 4px; margin-bottom: 10px; position: relative; }
.brg-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.brg-h b { font-size: 13px; color: var(--muted); }
.brg-h .x { width: 32px; height: 32px; border: 0; background: none; color: var(--faint); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.brg-h .x svg { width: 18px; height: 18px; }
.brg .g3 { display: grid; grid-template-columns: .8fr 1.3fr .8fr; gap: 0 8px; }
.brg .jml { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 0 2px 10px; margin-top: -4px; }
.brg .jml b { color: var(--text); font-variant-numeric: tabular-nums; }
.brg.retur { border-color: #efc9c5; } .brg.retur .jml b { color: var(--red); }
.foto-box { display: flex; align-items: center; gap: 12px; padding: 12px; }
.foto-box img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.foto-box .ph { width: 64px; height: 64px; border-radius: 8px; border: 1px dashed #c4ccd8; display: grid; place-items: center; color: var(--faint); }
.foto-box .ph svg { width: 26px; height: 26px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #e7ebf0; border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg button { border: 0; background: none; height: 40px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 14px; }
.seg button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.cepat { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 14px; }
.banner { padding: 11px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.banner.info { background: var(--navy-soft); color: var(--navy); }
.banner.warn { background: var(--amber-soft); color: #6b4500; }
.banner.red { background: var(--red-soft); color: var(--red); }
.banner .btn { margin-left: auto; }

/* Rincian nota */
.rinci { padding: 4px 14px; }
.rinci .r { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 14px; }
.rinci .r:first-child { border-top: 0; }
.rinci .r > span:first-child { color: var(--muted); }
.rinci .r > span:last-child { text-align: right; font-weight: 600; }
.brg-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.brg-tbl td { padding: 10px 14px; border-top: 1px solid var(--line-2); vertical-align: top; }
.brg-tbl tr:first-child td { border-top: 0; }
.brg-tbl td:last-child { text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.brg-tbl .k { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.brg-tbl tfoot td { font-weight: 700; background: #f7f9fb; }
.foto-besar { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }

/* Lembar pilihan (Catat) */
.tirai { position: fixed; inset: 0; z-index: 60; background: rgba(12, 22, 40, .45); display: flex; align-items: flex-end; animation: pudar .18s; }
@keyframes pudar { from { opacity: 0; } }
.lembar { width: 100%; max-width: 760px; margin: 0 auto; background: #fff; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + var(--safe-b)); animation: naik .22s ease-out; }
@keyframes naik { from { transform: translateY(100%); } }
.lembar .pegangan { width: 40px; height: 4px; border-radius: 4px; background: #d6dbe2; margin: 4px auto 12px; }
.lembar h3 { margin: 0 0 12px; font-size: 16px; }
.pilihan { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; cursor: pointer; background: #fff; width: 100%; text-align: left; }
.pilihan .ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.pilihan .ic svg { width: 22px; height: 22px; }
.pilihan b { display: block; color: var(--text); } .pilihan .tx { flex: 1; min-width: 0; } .pilihan .tx > span { display: block; font-size: 13px; color: var(--muted); }

/* Dialog */
.dlg-back { position: fixed; inset: 0; z-index: 80; background: rgba(12, 22, 40, .5); display: grid; place-items: center; padding: 20px; animation: pudar .15s; }
.dlg { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 20px; }
.dlg h3 { margin: 0 0 8px; font-size: 17px; } .dlg p { margin: 0 0 14px; color: #3b4652; font-size: 14px; }
.dlg .tb { display: flex; gap: 10px; } .dlg .tb .btn { flex: 1; }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 99; background: #17202b; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: .2s; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Tabel riwayat / akun */
.log-it { padding: 11px 14px; border-top: 1px solid var(--line-2); font-size: 13px; }
.log-it:first-child { border-top: 0; }
.log-it b { font-size: 14px; } .log-it .w { color: var(--faint); font-size: 12px; }
.log-it .d { color: var(--muted); word-break: break-word; margin-top: 2px; }

@media (min-width: 761px) {
  .lapis { left: auto; width: 560px; box-shadow: -8px 0 30px rgba(16, 32, 60, .15); }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
