/* Sylvania PO: satu kolom sempit, tab bawah, kartu hitungan dan kartu item. */
:root {
  --bg: #EDF0F3;
  --surface: #FAFBFC;
  --ink: #161C22;
  --muted: #5A6672;
  --line: #D5DBE1;
  --accent: #274C8F;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE6F6;
  --good: #1F7A48;
  --good-soft: #DAEFE3;
  --bad: #AE3B28;
  --bad-soft: #F6DFD9;
  --wa: #1E7A4A;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161B;
    --surface: #1A2028;
    --ink: #E6EAEE;
    --muted: #8C98A4;
    --line: #2B343E;
    --accent: #8DB0EA;
    --accent-ink: #0E1622;
    --accent-soft: #20314D;
    --good: #5BBE85;
    --good-soft: #17301F;
    --bad: #EE8A76;
    --bad-soft: #3A1E19;
    --wa: #5BBE85;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.top h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.gear { color: var(--muted); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; }
.gear:hover { color: var(--ink); }

main {
  max-width: 680px; margin: 0 auto;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(130px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden] { display: none !important; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; border-radius: 8px; }
.tabs a.on { color: var(--accent); }
.tabs a:focus-visible, .gear:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.grid { display: grid; gap: 10px; min-width: 0; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .lin label { font-size: 12px; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--ink); }
.field input, .field textarea, .lin input {
  width: 100%; min-width: 0;
  font: 500 16px/1.2 var(--mono); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px;
  font-variant-numeric: tabular-nums;
}
.field .txt, .field input.txt, .field textarea.txt { font-family: var(--sans); font-weight: 500; }
.field textarea { resize: vertical; line-height: 1.35; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.readout { font: 600 16px/1.2 var(--mono); padding: 9px 10px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: 600 14px/1 var(--sans); border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 11px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.wa { color: #0E1622; } }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.foot { margin: 0; font-size: 12px; color: var(--muted); }
.empty { margin: 0; text-align: center; color: var(--muted); font-size: 14px; padding: 14px 0; }

/* Kalkulator */
.result { background: var(--accent-soft); border-radius: 10px; padding: 16px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.eyebrow { font-size: 12px; color: var(--accent); font-weight: 600; margin: 0; }
.big { font: 600 40px/1.05 var(--mono); letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; margin: 2px 0 0; overflow-wrap: anywhere; }
.note { margin: 6px 0 0; font: 400 13px/1.4 var(--mono); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.stat { min-width: 0; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font: 600 15px/1.25 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .s { font: 400 11px/1.3 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.warn { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 14px; font-weight: 500; }
.scen { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.card.first { border-color: var(--accent); }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card .qty { font: 600 18px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.tag { font: 600 10px/1 var(--sans); letter-spacing: .05em; text-transform: uppercase; padding: 4px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); }
.ln { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font: 400 12.5px/1.4 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ln span { min-width: 0; }
.ln b { font-weight: 500; color: var(--ink); text-align: right; white-space: nowrap; }
.ln.tot { border-top: 1px dashed var(--line); padding-top: 5px; margin-top: 2px; }
.ln.tot b { font-weight: 600; }
.ln.laba { margin-top: 4px; padding: 7px 8px; border-radius: 6px; background: var(--good-soft); color: var(--good); font-weight: 600; }
.ln.laba b { color: var(--good); font-weight: 600; font-size: 14px; }
.ln.laba.neg { background: var(--bad-soft); color: var(--bad); }
.ln.laba.neg b { color: var(--bad); }

/* PO */
.combo { position: relative; }
.cres { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 25; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 22px rgba(0, 0, 0, .18); max-height: 280px; overflow-y: auto; }
.cr { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 11px 12px; color: var(--ink); font: inherit; cursor: pointer; }
.cr:last-child { border-bottom: 0; }
.cr:hover, .cr:focus-visible { background: var(--accent-soft); outline: none; }
.cr .cn { font-weight: 600; overflow-wrap: anywhere; }
.cr .ct { font: 400 12px/1.3 var(--mono); color: var(--muted); white-space: nowrap; }
.cr.new { color: var(--accent); font-weight: 600; justify-content: flex-start; }
.sres { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; max-height: 52vh; overflow-y: auto; background: var(--bg); }
.sr { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 8px 10px; cursor: pointer; color: var(--ink); font: inherit; }
.sr:last-child { border-bottom: 0; }
.sr:hover, .sr:focus-visible { background: var(--accent-soft); outline: none; }
.sr .th { width: 44px; height: 44px; border-radius: 6px; background: var(--line); flex: none; object-fit: cover; }
.sr .mid { min-width: 0; flex: 1; }
.sr .nm { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.sr .sk { font: 400 11.5px/1.3 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.sr .pr { font: 600 13px/1.2 var(--mono); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.sr .st { display: block; font: 400 11px/1.2 var(--mono); color: var(--muted); }
.sr-none { padding: 12px; color: var(--muted); font-size: 14px; }
.manual { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: 64px minmax(0, 1fr) 30px; gap: 8px 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--bg); }
.lin, .lsub { grid-column: 1 / -1; }
.ph { position: relative; width: 64px; height: 64px; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface); padding: 0; cursor: pointer; overflow: hidden; color: var(--muted); font: 500 11px/1.2 var(--sans); }
.ph span { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 4px; }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface); }
.ph:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lm { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ln1 { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.25; }
.ln2 { font: 400 11.5px/1.3 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.lin { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.lin label { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lin input { padding: 7px 8px; font-size: 15px; }
.lsub { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lsub .hint { font: 400 11px/1.2 var(--mono); color: var(--bad); }
.lsub b { font: 600 14px/1.2 var(--mono); font-variant-numeric: tabular-nums; margin-left: auto; }
.rm { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; align-self: start; }
.rm:hover { color: var(--bad); border-color: var(--bad); }

.savebar {
  position: sticky; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.sb-total { display: flex; flex-direction: column; }
.sb-total span { font-size: 11px; color: var(--muted); }
.sb-total b { font: 600 20px/1.1 var(--mono); font-variant-numeric: tabular-nums; }

/* Riwayat */
.hist { display: flex; flex-direction: column; gap: 8px; }
.hrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; cursor: pointer; color: var(--ink); font: inherit; }
.hrow:hover, .hrow:focus-visible { border-color: var(--accent); outline: none; }
.hrow .a { font-weight: 600; overflow-wrap: anywhere; }
.hrow .b { font: 400 12px/1.3 var(--mono); color: var(--muted); }
.hrow .t { font: 600 14px/1.2 var(--mono); text-align: right; font-variant-numeric: tabular-nums; grid-row: 1 / span 2; grid-column: 2; align-self: center; }

/* Invoice */
.invbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.invbar span { font-weight: 600; }
#invFrame { width: 100%; height: calc(100dvh - 250px); min-height: 380px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* Dokumen PO */
.docbar { display: flex; flex-wrap: wrap; gap: 8px; }
.paper { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; padding: 18px 16px; font: 13px/1.4 var(--sans); overflow-x: auto; }
.paper .dh { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.paper .co { font-size: 18px; font-weight: 700; }
.paper .co-s { color: #444; font-size: 12px; }
.paper .ttl { font-size: 20px; font-weight: 700; letter-spacing: .08em; text-align: right; }
.paper .meta { font: 500 12px/1.4 var(--mono); text-align: right; color: #333; }
.paper .cu { margin-bottom: 12px; font-size: 13px; }
.paper .cu b { font-size: 14px; }
.paper table { width: 100%; border-collapse: collapse; }
.paper th.r { font-family: var(--sans); }
.paper .cq, .paper .ch { display: none; }
.paper .qh { font: 500 12px/1.3 var(--mono); margin-top: 3px; color: #222; }
@media (min-width: 560px) { .paper .cq, .paper .ch { display: table-cell; } .paper .qh { display: none; } }
.paper th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid #111; padding: 6px 4px; }
.paper td { padding: 6px 4px; border-bottom: 1px solid #ddd; vertical-align: middle; }
.paper tr { break-inside: avoid; }
.paper .r { text-align: right; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.paper .c { text-align: center; width: 28px; color: #555; }
.paper .pf { width: 62px; }
.paper .pf img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; display: block; }
.paper .s { font: 400 11px/1.3 var(--mono); color: #555; }
.paper .tt { margin: 12px 0 0 auto; width: min(100%, 280px); }
.paper .tt div { display: flex; justify-content: space-between; padding: 3px 0; font-family: var(--mono); font-size: 12.5px; }
.paper .tt .g { border-top: 2px solid #111; margin-top: 4px; padding-top: 6px; font-size: 15px; font-weight: 700; }
.paper .cat { margin-top: 12px; font-size: 12px; color: #333; }
.paper .ft { margin-top: 16px; font-size: 11px; color: #666; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: min(92vw, 420px); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); color: #fff; }

@media (max-width: 420px) {
  .big { font-size: 34px; }
  .stat .v { font-size: 13px; }
  .line { grid-template-columns: 56px minmax(0, 1fr) 28px; }
  .ph { width: 56px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .top, .tabs, .docbar, #toast, #payPanel { display: none !important; }
  main { padding: 0; max-width: none; }
  .view:not(#v-doc) { display: none !important; }
  .paper { border: 0; padding: 0; overflow: visible; }
  .paper .cq, .paper .ch { display: table-cell; }
  .paper .qh { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* DP, status, pembayaran */
.dprow { display: flex; gap: 8px; align-items: center; }
.dprow input { flex: 1; min-width: 0; }
.btn.sm { padding: 9px 11px; font-size: 13px; }
.tag { color: var(--muted); font-weight: 400; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 600 13px/1 var(--sans); border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 9px 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bd { display: inline-block; font: 600 11px/1 var(--sans); padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.bd.st-menunggu, .bd.st-kurang { background: var(--bad-soft); color: var(--bad); }
.bd.st-lunas { background: var(--good-soft); color: var(--good); }
.hrow .s { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font: 400 12px/1.3 var(--mono); color: var(--muted); }
.payinfo { display: flex; flex-direction: column; gap: 4px; }
.payinfo .bd { align-self: flex-start; margin-bottom: 2px; }
.paylist { display: flex; flex-direction: column; gap: 6px; }
.payrow { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font: 400 12.5px/1.4 var(--mono); border-top: 1px dashed var(--line); padding-top: 6px; }
.payrow .k { min-width: 0; overflow-wrap: anywhere; }
.payrow a { color: var(--accent); font-family: var(--sans); font-weight: 600; margin-left: 6px; }
.payrow button { border: 0; background: none; color: var(--bad); font: 600 12px/1 var(--sans); cursor: pointer; margin-left: 8px; padding: 4px; }
.payform { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.payform input[type="file"] { font: 400 13px var(--sans); }
.paper .stamp { display: inline-block; margin-top: 4px; font: 700 10px/1 var(--sans); letter-spacing: .04em; border: 1.5px solid #111; border-radius: 3px; padding: 4px 6px; color: #111; }
.paper .stamp.st-lunas { border-color: #1F7A48; color: #1F7A48; }
.paper .stamp.st-menunggu, .paper .stamp.st-kurang { border-color: #AE3B28; color: #AE3B28; }
.paper .pay { margin-top: 12px; font-size: 12.5px; }
.paper .pay .pl { border: 1.5px solid #111; border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; }
.paper .pay .pt { font-weight: 700; margin-bottom: 3px; }
.paper .pay .pr { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); padding: 2px 0; }
.paper .pay .pr.sum { border-top: 1px solid #999; margin-top: 3px; padding-top: 4px; font-weight: 700; }
.paper td .s.pcs { font-family: var(--mono); }
