/* INVOICE PRODUKSI — ukuran dari tab Invoice; tema teal (pembeda dari KURONOA INVOICE yang cokelat) */
:root {
  --dark: #0B3A42;
  --gold: #C9A227;
  --cream-txt: #F7E9D0;
  --cream: #FFF7E8;
  --cell: #FFFBF1;
  --sec: #17616B;
  --ink: #12333A;
  --blue: #0070C0;
  --pink: #FBE4E6;
  --red: #B91C1C;
  --line: #CFE0DF;
  --b-brown: #0F5560; --b-green: #2E7D32; --b-blue: #1565C0; --b-orange: #E65100;
  --b-magenta: #AD1457; --b-grey: #616161; --b-red: #C62828;
  --cols: 7.63fr 14.75fr 23.63fr 7.13fr 10.63fr 13.5fr 8.25fr 15.13fr;
  --font: 'Carlito', Calibri, 'Segoe UI', Arial, sans-serif;
  --bg: #E4EEEE;
  --surface: #FFFFFF;
  --text: #0B2A30;
  --muted: #56696C;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); }
.warn { color: #8A5A00; }

/* ---------- top ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--dark); color: var(--cream-txt);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; letter-spacing: .5px; }
.brand b { color: var(--gold); }
.brand img { border-radius: 8px; }
.status-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: #14505A; color: var(--cream-txt); white-space: nowrap; }
.chip.ok { background: #1f5130; } .chip.bad { background: #7f1d1d; } .chip.warn { background: #7a5200; }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; background: var(--bg); position: sticky; top: 52px; z-index: 15; }
.tabs button {
  border: 0; background: transparent; padding: 10px 16px; min-height: 44px; border-radius: 10px 10px 0 0;
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--surface); color: var(--dark); box-shadow: inset 0 -3px 0 var(--gold); }
main { padding: 12px 16px 96px; max-width: 1180px; margin: 0 auto; }
.banner { background: var(--gold); color: var(--dark); padding: 10px 16px; text-align: center; font-weight: 700; }
.banner button { margin-left: 8px; border: 0; background: var(--dark); color: var(--gold); padding: 6px 12px; border-radius: 8px; cursor: pointer; }

.card { background: var(--surface); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(11,58,66,.08); }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.btn {
  min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 700;
}
.btn-brown { background: var(--b-brown); color: #fff; border-color: transparent; }
.btn-green { background: var(--b-green); color: #fff; border-color: transparent; }
.btn-red { background: var(--b-red); color: #fff; border-color: transparent; }
.btn-orange { background: var(--b-orange); color: #fff; border-color: transparent; }
.btn-grey { background: var(--b-grey); color: #fff; border-color: transparent; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 8vh auto; text-align: center; display: grid; gap: 10px; }
.login h1 { margin: 4px 0 0; font-size: 22px; color: var(--dark); }
.login label { text-align: left; font-weight: 700; }
.login input { min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); }
.login img { margin: 0 auto; border-radius: 16px; }

/* ---------- invoice workspace ---------- */
.formbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; min-height: 28px; }
.badge { font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: #DCE9E8; color: var(--ink); }
.badge.ok { background: #DCEFE0; color: #1f5130; }
.badge.warn { background: #FFF0CC; color: #7a5200; }
.badge.bad { background: var(--pink); color: var(--red); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 18px; align-items: start; }
.paper-wrap { overflow-x: auto; }
.actions { position: sticky; top: 110px; display: grid; gap: 10px; }
.act {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  min-height: 52px; padding: 8px 12px; border: 0; border-radius: 10px; color: #fff; cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.act i { font-style: normal; width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-weight: 700; flex: none; }
.act b { display: block; font-size: 16px; letter-spacing: .3px; }
.act small { display: block; font-size: 10px; opacity: .9; }
.act:disabled { opacity: .45; cursor: not-allowed; }
.act-brown { background: var(--b-brown); } .act-green { background: var(--b-green); } .act-blue { background: var(--b-blue); }
.act-orange { background: var(--b-orange); } .act-magenta { background: var(--b-magenta); } .act-grey { background: var(--b-grey); }
.act-red { background: var(--b-red); }
body.busy .act, body.busy .bottombar button { pointer-events: none; opacity: .6; }

/* ---------- PAPER: replika A1:H34 ---------- */
.paper {
  width: 100%; min-width: 700px; max-width: 794px; margin: 0 auto;
  background: var(--cream); color: var(--ink); font-size: 10pt; line-height: 1.2;
  box-shadow: 0 4px 18px rgba(11,58,66,.15);
}
.sec { display: grid; grid-template-columns: var(--cols); }
.g, .c { display: flex; align-items: center; padding: 0 5px; min-width: 0; overflow: hidden; }
.head { background: var(--dark); grid-template-rows: 37px 24px 24px; }
.head .brand-name { color: var(--gold); font-size: 24pt; font-weight: 700; padding-left: 6px; white-space: nowrap; }
.head .tagline { color: var(--cream-txt); font-weight: 700; padding-left: 14px; }
.head .kontak { color: var(--cream-txt); padding-left: 14px; white-space: nowrap; }
.head .big { color: var(--gold); font-size: 48pt; font-weight: 700; justify-content: center; letter-spacing: 1px; }
.sec.gap { height: 19px; }
.info { grid-template-rows: 29px 26px 26px 26px 26px 26px 26px; }
.info .hdr, .sum .hdr { background: var(--sec); color: #fff; font-weight: 700; font-size: 11pt; justify-content: center; }
.info .lbl { background: var(--cell); font-weight: 700; color: var(--dark); white-space: nowrap; padding-right: 2px; }
.mob-only { display: none !important; }
.info .val { background: var(--cell); color: var(--ink); }
.info .blank { background: var(--cream); }
.info .blue, .info .blue input { color: var(--blue); }
.info .logo { background: var(--cell); justify-content: center; padding: 2px; }
.info .logo img { max-height: 120px; max-width: 100%; object-fit: contain; }
.preview { color: var(--muted); }
.items { grid-auto-rows: 40px; }
.ihead, .irow { display: contents; }
.ihead .c { background: var(--dark); color: var(--gold); font-weight: 700; justify-content: center; }
.irow .c { background: var(--cell); font-size: 9pt; border-bottom: 1px solid #F3E7CF; }
.irow.alt .c { background: #FFF5E2; }
.c.ctr { justify-content: center; text-align: center; }
.c.num { justify-content: flex-end; text-align: right; }
.c.desk { line-height: 1.15; }
.sum { grid-template-rows: 29px 34px 29px 29px 29px 29px 28px 28px; background: var(--cell); }
.sum .note { font-size: 9pt; color: var(--ink); justify-content: center; text-align: center; }
.sum .note.rek { font-size: 12pt; font-weight: 700; }
.sum .note.terms { justify-content: flex-start; text-align: left; align-items: center; }
.sum .tl { font-weight: 700; color: var(--dark); }
.sum .tv { justify-content: flex-end; text-align: right; }
.sum .ppnpct { justify-content: flex-end; font-weight: 700; color: var(--dark); }
.sum .grand { background: var(--dark); color: var(--gold); font-weight: 700; font-size: 11pt; }
.sum .sisa { background: var(--pink); color: var(--red); font-weight: 700; font-size: 11pt; }
.foot { display: flex; justify-content: center; align-items: center; height: 29px; background: var(--dark); color: var(--cream-txt); font-style: italic; }

/* input yang menyatu dengan sel */
.paper input, .paper select, .paper textarea {
  width: 100%; min-width: 0; height: 100%; border: 0; background: transparent; padding: 2px 2px;
  font-size: inherit; color: inherit; border-radius: 4px; outline: none;
}
.paper textarea { resize: none; height: 100%; padding-top: 4px; line-height: 1.2; }
.paper select { -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 9px) 50%, calc(100% - 5px) 50%; background-size: 4px 4px; background-repeat: no-repeat; padding-right: 14px; }
.c.ctr input, .c.ctr select { text-align: center; }
.tv input { text-align: right; }
.paper input:focus, .paper select:focus, .paper textarea:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--gold); }
.paper input::placeholder { color: #B9A88F; }

/* ---------- riwayat / admin ---------- */
.filters { display: grid; grid-template-columns: 2fr auto 1fr auto auto auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.filters input, .filters select, .cfg input { min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; }
.filters label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.inv-list { list-style: none; margin: 0; padding: 0; }
.inv-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); min-height: 56px; }
.inv-list li[data-no] { cursor: pointer; }
.inv-list li[data-no]:hover, .inv-list li[data-no]:focus { background: var(--cream); outline: none; }
.inv-list li.pending { background: #FFF6DB; }
.inv-list li.bad { background: var(--pink); }
.inv-list small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.inv-list .r { text-align: right; display: grid; justify-items: end; gap: 3px; }
.inv-list .sisa { color: var(--red); }
.badge.st-paid { background: #DCEFE0; color: #1f5130; }
.badge.st-unpaid { background: var(--pink); color: var(--red); }
.badge.st-partial { background: #FFF0CC; color: #7a5200; }
.badge.st-draft { background: #DCE9E8; color: var(--ink); }
.cfg { display: grid; gap: 10px; }
.cfg label { display: grid; gap: 4px; font-weight: 700; font-size: 14px; }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(11,58,66,.45); }
#dlg-form { padding: 18px; display: grid; gap: 10px; }
#dlg-form h3 { margin: 0; font-size: 18px; color: var(--dark); }
.dlg-body p { margin: 6px 0; }
.dlg-body .links a { color: var(--b-blue); font-weight: 700; }
.dlg-input { display: grid; gap: 4px; font-weight: 700; }
.dlg-input input { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.errlist { margin: 0; padding-left: 18px; color: var(--red); }
#toasts { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(480px, calc(100vw - 32px)); }
.toast { background: var(--dark); color: var(--cream-txt); padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.25); transition: opacity .5s, transform .5s; }
.toast.ok { border-left: 5px solid #4CAF50; } .toast.warn { border-left: 5px solid var(--gold); } .toast.bad { border-left: 5px solid #EF5350; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- bottom bar (mobile) ---------- */
.bottombar { display: none; }

@media screen and (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .actions { display: none; }
  .bottombar:not([hidden]) {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--dark);
  }
  .bottombar button { min-height: 48px; border: 0; border-radius: 10px; background: #14505A; color: var(--cream-txt); font-weight: 700; font-size: 14px; cursor: pointer; }
  .bottombar button.primary { background: var(--b-green); color: #fff; }
  .bottombar button:disabled { opacity: .45; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { grid-column: 1 / -1; }
}

/* Mobile: urutan & warna sama, tabel item jadi kartu */
@media screen and (max-width: 760px) {
  main { padding: 10px 10px 100px; }
  .paper { min-width: 0; font-size: 11pt; box-shadow: none; }
  .paper .sec { display: grid; grid-template-columns: 112px minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: minmax(40px, auto); }
  .paper .g { grid-area: auto !important; min-height: 40px; }
  .head { padding: 10px 0; }
  .head .brand-name { grid-column: 1 / -1 !important; font-size: 20pt; }
  .head .tagline, .head .kontak { grid-column: 1 / -1 !important; padding-left: 8px; font-size: 10pt; min-height: 22px !important; }
  .head .kontak { white-space: normal; }
  .head .big { grid-column: 1 / -1 !important; font-size: 30pt; justify-content: flex-start; padding-left: 8px; }
  .sec.gap { height: 8px; }
  .info .hdr, .sum .hdr { grid-column: 1 / -1 !important; }
  .info .blank, .info .logo, .info .val:empty { display: none; }
  .info .val, .sum .tv { border-bottom: 1px solid #F3E7CF; }
  .info .lbl, .sum .tl { border-bottom: 1px solid #F3E7CF; font-size: 10pt; }
  .info .val textarea { min-height: 56px; }
  .paper input, .paper select { min-height: 40px; font-size: 16px; }   /* 16px: cegah auto-zoom iOS */
  .paper textarea { font-size: 16px; }
  .items { display: block !important; }
  .ihead { display: none; }
  .irow { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--cell); }
  .irow .c { background: var(--cell) !important; border-bottom: 1px solid #F3E7CF; min-height: 44px; flex-direction: column; align-items: stretch; justify-content: center; text-align: left !important; padding: 4px 10px; }
  .irow .c::before { content: attr(data-label); font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
  .irow .c:nth-child(1) { grid-column: 1 / -1; background: var(--dark) !important; color: var(--gold); min-height: 30px; flex-direction: row; align-items: center; gap: 6px; }
  .irow .c:nth-child(1)::before { color: var(--gold); content: 'Item'; font-size: 11px; }
  .irow .c:nth-child(2), .irow .c:nth-child(3) { grid-column: 1 / -1; }
  .irow .c.num { text-align: right !important; }
  .irow .c input, .irow .c select { text-align: left !important; padding: 0; }
  .irow:not(.filled):not(.next-empty) { display: none; }
  .sum .note, .sum .hdr { display: none; }
  .paper .mob-only { display: flex !important; }
  .foot { font-size: 9pt; text-align: center; padding: 6px 8px; height: auto; min-height: 29px; }
}

/* ---------- PRINT: hanya kertas invoice, A4 1 halaman ---------- */
#print-root { display: none; }
@page { size: A4; margin: 0.15in; }
@media print {
  body { background: #fff; padding: 0; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .paper.print { box-shadow: none; max-width: none; min-width: 0; width: 100%; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .paper.print .v { white-space: pre-wrap; }
}
