/* Rekap Belanja — hijau daun pisang, kertas, dan lembar belanja bergaya buku tulis */
:root {
  --daun: #1e6b47;
  --daun-tua: #154f34;
  --pucuk: #e3f0e5;
  --kertas: #f4f6f1;
  --putih: #fff;
  --arang: #1d2621;
  --abu: #5d6a62;
  --garis: #dce3db;
  --kunyit: #c98a0c;
  --kunyit-muda: #fcf1d6;
  --cabai: #b8392a;
  --cabai-muda: #fbe6e2;
  --biru-garis: #c9d9ec;
  --merah-margin: #e6a3a3;
  --r-sm: 8px;
  --r: 14px;
  --tab-h: 64px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--kertas); color: var(--arang);
  font: 400 1rem/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 750; }
h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: .75rem; }
p { margin: .4rem 0; }
a { color: var(--daun); text-underline-offset: 2px; }
code { background: var(--pucuk); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--abu); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.is-hidden { display: none !important; }
:focus-visible { outline: 3px solid #7fb894; outline-offset: 2px; }
.ico { width: 22px; height: 22px; flex: none; }

/* ---------- Kerangka: rel samping (desktop) + tab bawah (HP) ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: var(--arang); text-decoration: none; font-weight: 750; letter-spacing: -0.01em; }
.brand img { border-radius: 9px; }
.rail { display: none; }
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: rgba(244, 246, 241, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--garis);
}
.main { padding: 18px 16px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); }
.content { max-width: 980px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--putih); border-top: 1px solid var(--garis);
}
.tabbar > a, .tabbar summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--abu); text-decoration: none; font-size: .72rem; font-weight: 600; cursor: pointer; list-style: none;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar > a.is-active, .tabbar .more.is-active summary { color: var(--daun); }
.tabbar > a.is-active .ico { background: var(--pucuk); border-radius: 999px; padding: 3px 14px; width: 52px; height: 28px; box-sizing: border-box; }
.more { position: relative; display: flex; }
.more summary { width: 100%; }
.more-sheet {
  position: absolute; right: 8px; bottom: calc(100% + 8px); min-width: 210px; padding: 6px;
  background: var(--putih); border: 1px solid var(--garis); border-radius: var(--r); box-shadow: 0 12px 32px rgba(29, 38, 33, .16);
}
.more-sheet a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-sm); color: var(--arang); text-decoration: none; font-weight: 550; }
.more-sheet a:hover { background: var(--kertas); }

@media (min-width: 900px) {
  .appbar, .tabbar { display: none; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 232px; display: flex; flex-direction: column; gap: 22px;
    padding: 22px 14px; background: var(--putih); border-right: 1px solid var(--garis);
  }
  .rail .brand { padding: 0 8px; }
  .rail-nav { display: flex; flex-direction: column; gap: 2px; }
  .rail-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--abu); text-decoration: none; font-weight: 600; }
  .rail-nav a:hover { background: var(--kertas); color: var(--arang); }
  .rail-nav a.is-active { background: var(--pucuk); color: var(--daun-tua); }
  .rail-user { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--garis); }
  .rail-user b, .rail-user span { display: block; }
  .main { margin-left: 232px; padding: 32px 36px 60px; }
}

/* ---------- Komponen ---------- */
.page-head { margin-bottom: 18px; }
.page-head p { max-width: 62ch; }
.panel { background: var(--putih); border: 1px solid var(--garis); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.panel-tight { padding: 14px 18px; }
.panel > h2:first-child { margin-top: 0; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
input[type=text], input[type=date], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #c9d1c8; border-radius: 10px;
  font: inherit; color: var(--arang); background: var(--putih);
}
input:focus, select:focus, textarea:focus { border-color: var(--daun); outline: 3px solid rgba(30, 107, 71, .18); outline-offset: 0; }
textarea { min-height: 150px; line-height: 1.45; resize: vertical; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; }
.form-grid .form-actions { grid-column: 1 / -1; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; cursor: pointer; }
.check-inline input { width: 18px; height: 18px; accent-color: var(--daun); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--daun); border-radius: 999px; background: var(--daun); color: #fff;
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--daun-tua); }
.btn:disabled { opacity: .65; cursor: progress; }
.btn.ghost { background: transparent; color: var(--daun-tua); border-color: #bfd2c4; }
.btn.ghost:hover { background: var(--pucuk); }
.btn.danger { background: var(--putih); color: var(--cabai); border-color: #e9b9b2; }
.btn.danger:hover { background: var(--cabai-muda); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sticky-actions {
  position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px); z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; padding: 10px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--garis); border-radius: 999px; box-shadow: 0 6px 24px rgba(29, 38, 33, .1);
  width: fit-content; max-width: 100%;
}
@media (min-width: 900px) { .sticky-actions { bottom: 18px; } }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; border: 1px solid; line-height: 1.45; }
.alert.ok { background: var(--pucuk); border-color: #b6d4bf; color: var(--daun-tua); }
.alert.warn { background: var(--kunyit-muda); border-color: #ecd29a; color: #6b4a05; }
.alert.err { background: var(--cabai-muda); border-color: #efbcb4; color: #7d2116; }
.alert a { color: inherit; font-weight: 650; }

.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--kertas); color: var(--abu); border: 1px solid var(--garis); vertical-align: 2px; }
.chip-leaf { background: var(--pucuk); color: var(--daun-tua); border-color: #c4dccb; }
.chip-warn { background: var(--kunyit-muda); color: #7a5306; border-color: #f0dba9; }

/* Daftar baris (barang, customer, PO, pengguna) */
.list { background: var(--putih); border: 1px solid var(--garis); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--garis); }
.list-row:first-child { border-top: 0; }
.list-row.is-off { opacity: .55; }
.list-main { flex: 1; min-width: 0; }
.list-main b { margin-right: 6px; }
.list-group { padding: 8px 16px; background: var(--kertas); font-weight: 700; font-size: .85rem; color: var(--abu); border-top: 1px solid var(--garis); }
.list-row a.row-link { color: inherit; text-decoration: none; }
.list-empty { padding: 28px 16px; text-align: center; color: var(--abu); }
.row-menu { position: relative; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; display: flex; flex-direction: column; gap: 8px;
  min-width: 250px; padding: 12px; background: var(--putih); border: 1px solid var(--garis); border-radius: 12px; box-shadow: 0 10px 28px rgba(29, 38, 33, .14);
}
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-height: 34px; }

.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { max-width: 340px; }

/* Ringkasan beranda */
.today {
  display: grid; gap: 14px; grid-template-columns: 1.4fr 1fr; margin-bottom: 16px;
}
@media (max-width: 680px) { .today { grid-template-columns: 1fr; } }
.today-main { background: var(--daun); color: #eaf4ec; border-radius: var(--r); padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.today-main h2 { color: #fff; font-size: 1.25rem; margin: 0; }
.today-main .big { font-size: 3rem; font-weight: 800; line-height: 1; color: #fff; letter-spacing: -0.03em; }
.today-main .btn { background: #fff; color: var(--daun-tua); border-color: #fff; align-self: flex-start; }
.today-main .btn.ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }
.today-side { display: grid; gap: 10px; }
.mini { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--putih); border: 1px solid var(--garis); border-radius: 12px; color: inherit; text-decoration: none; }
.mini b { font-size: 1.35rem; }

/* ---------- Input PO ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 130px; padding: 18px;
  border: 2px dashed #b7cdbd; border-radius: var(--r); background: #f8fbf7; text-align: center; cursor: pointer; font-weight: 400;
}
.dropzone.is-over { border-color: var(--daun); background: var(--pucuk); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-text { font-size: 1.05rem; }
.dropzone-text b { color: var(--daun); }
.file-list { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.file-list li { padding: 4px 10px; background: var(--pucuk); border-radius: 999px; font-size: .85rem; color: var(--daun-tua); }
.teks-block + .teks-block { margin-top: 14px; }
#tambah-teks { margin-top: 12px; }

/* Cek hasil: satu kartu per sumber */
.source { background: var(--putih); border: 1px solid var(--garis); border-radius: var(--r); margin-bottom: 16px; overflow: hidden; }
.source.has-error { border-color: #efbcb4; }
.source > .alert { margin: 14px 16px; }
.source-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; background: #fafbf8; border-bottom: 1px solid var(--garis); }
.source-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.source-title b { word-break: break-all; }
.src-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--pucuk); flex: none; position: relative; }
.src-icon::after { content: "PO"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .66rem; font-weight: 800; color: var(--daun-tua); }
.src-excel::after { content: "XLS"; } .src-word::after { content: "DOC"; } .src-pdf::after { content: "PDF"; }
.src-foto::after { content: "IMG"; } .src-teks::after { content: "WA"; }
.source-cust { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 16px; }
.source > .alert.small { margin-top: 0; }
@media (max-width: 560px) { .source-cust { grid-template-columns: 1fr; } }

.items { padding: 0 16px 6px; }
.items-head, .item { display: grid; grid-template-columns: minmax(180px, 2.2fr) 84px 92px minmax(120px, 1.4fr) 64px; gap: 8px; align-items: start; }
.items-head { padding: 6px 0; font-size: .78rem; font-weight: 700; color: var(--abu); border-bottom: 1px solid var(--garis); }
.item { padding: 10px 0; border-bottom: 1px solid var(--garis); }
.item:last-child { border-bottom: 0; }
.item input[type=text], .item select { min-height: 40px; padding: 7px 10px; }
.item-name { display: flex; flex-direction: column; gap: 6px; }
.item-qty { text-align: right; font-weight: 700; }
.item.is-new { background: linear-gradient(90deg, var(--kunyit-muda), transparent 70%); margin: 0 -16px; padding-left: 16px; padding-right: 16px; box-shadow: inset 3px 0 0 var(--kunyit); }
.item.is-blank select { color: var(--abu); }
.item.is-deleted > *:not(.item-del) { opacity: .35; text-decoration: line-through; }
.item-del { display: flex; align-items: center; gap: 6px; font-weight: 500; font-size: .8rem; color: var(--cabai); margin: 10px 0 0; cursor: pointer; }
.item-del input { width: 16px; height: 16px; accent-color: var(--cabai); }
.quote { font-size: .8rem; color: var(--abu); padding-left: 8px; border-left: 2px solid var(--garis); }
.raw { margin: 4px 16px 14px; }
.raw summary { cursor: pointer; color: var(--daun); font-weight: 600; font-size: .9rem; }
.raw pre { white-space: pre-wrap; background: var(--kertas); padding: 12px; border-radius: 10px; font-size: .85rem; }
@media (max-width: 720px) {
  .items-head { display: none; }
  .item { grid-template-columns: 1fr 1fr; }
  .item-name { grid-column: 1 / -1; }
  .item-note { grid-column: 1 / -1; }
  .item-qty { text-align: left; }
}

/* ---------- Lembar belanja (buku tulis bergaris) ---------- */
.sheet-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.sheet-tools input[type=date] { max-width: 190px; }
.seg { display: inline-flex; padding: 3px; background: var(--putih); border: 1px solid var(--garis); border-radius: 999px; }
.seg a { padding: 7px 14px; border-radius: 999px; color: var(--abu); text-decoration: none; font-weight: 600; font-size: .9rem; }
.seg a.is-active { background: var(--daun); color: #fff; }
.date-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.date-chips a { padding: 4px 10px; border-radius: 999px; background: var(--putih); border: 1px solid var(--garis); color: var(--arang); text-decoration: none; font-size: .82rem; }
.date-chips a.is-active { border-color: var(--daun); color: var(--daun-tua); background: var(--pucuk); }

.sheet {
  --line: 46px;
  position: relative; background-color: #fffefb; border-radius: 6px 6px 14px 14px;
  box-shadow: 0 1px 0 var(--garis), 0 14px 34px -18px rgba(29, 38, 33, .35);
  padding: 22px 18px 26px 64px;
  background-image: linear-gradient(90deg, transparent 47px, var(--merah-margin) 47px, var(--merah-margin) 49px, transparent 49px);
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 14px; border-bottom: 2px solid var(--biru-garis); }
.sheet-title { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; }
.sheet-sub { color: var(--abu); font-size: .9rem; }
.sheet-progress { text-align: right; font-size: .85rem; color: var(--abu); white-space: nowrap; }
.sheet-progress b { display: block; font-size: 1.3rem; color: var(--daun); }
.sheet-group { break-after: avoid; page-break-after: avoid; padding: 16px 0 6px; font-weight: 750; color: var(--daun); font-size: .95rem; border-bottom: 1px solid var(--biru-garis); }
.sheet-row {
  min-height: var(--line); display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 14px;
  border-bottom: 1px solid var(--biru-garis);
  cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent;
}
.sheet-row::before {
  content: ""; position: absolute; left: -44px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border: 2px solid #9fb2a5; border-radius: 6px; background: #fff;
}
.sheet-row.is-done::before { background: var(--daun); border-color: var(--daun); }
.sheet-row.is-done::after {
  content: ""; position: absolute; left: -37px; top: 50%; width: 6px; height: 11px; margin-top: -8px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.sheet-name { font-size: 1.08rem; font-weight: 650; padding: 8px 0 2px; }
.sheet-qty { font-size: 1.35rem; font-weight: 800; text-align: right; white-space: nowrap; letter-spacing: -0.01em; }
.sheet-qty small { font-size: .85rem; font-weight: 600; color: var(--abu); margin-left: 4px; letter-spacing: 0; }
.sheet-detail { grid-column: 1; font-size: .82rem; color: var(--abu); padding-bottom: 8px; line-height: 1.35; }
.sheet-detail .note { color: #7a5306; margin-top: 2px; }
/* Pesanan per customer di bawah nama barang: nama customer kiri, jumlah kanan */
.sheet-split { list-style: none; margin: 2px 0 0; padding: 0; max-width: 300px; }
.sheet-split li { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.sheet-split li + li { border-top: 1px dotted #d3dbd5; }
.sheet-split span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-split b { font-weight: 650; color: var(--arang); white-space: nowrap; }
.sheet-row.is-new .sheet-name { box-shadow: inset 0 -3px 0 var(--kunyit-muda); }
.sheet-row.is-done .sheet-name, .sheet-row.is-done .sheet-qty { text-decoration: line-through; text-decoration-thickness: 2px; color: #8b968f; }
.sheet-row.is-done .sheet-detail { opacity: .55; }
.sheet-empty { padding: 30px 0; color: var(--abu); }
@media (min-width: 760px) {
  .sheet-body { columns: 2; column-gap: 48px; }
  .sheet-keep, .sheet-row { break-inside: avoid; }
}

.pack { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pack-card { background: var(--putih); border: 1px solid var(--garis); border-radius: var(--r); padding: 14px 16px; break-inside: avoid; }
.pack-card h2 { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pack-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--garis); }
.pack-line b { white-space: nowrap; }

/* ---------- Halaman masuk ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--daun); }
.auth-box { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; color: #eaf4ec; }
.auth-brand img { border-radius: 14px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.auth-brand h1 { color: #fff; }
.auth-brand p { margin: 2px 0 0; color: #cfe5d6; }
.auth-form { background: var(--putih); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 4px; }
.auth-form h2 { margin: 0; }
.auth-form label { margin-top: 10px; }
.auth-form .btn { margin-top: 18px; }

/* ---------- Cetak: satu lembar belanja ---------- */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  .rail, .appbar, .tabbar, .no-print, .alert, .sheet-tools, .sticky-actions { display: none !important; }
  .main { margin: 0; padding: 0; }
  .content { max-width: none; }
  .print-only { display: block; }
  .sheet { --line: 27px; box-shadow: none; padding: 0 0 0 26px; background: none; }
  .sheet-head { height: auto; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1.5pt solid #000; }
  .sheet-title { font-size: 15pt; }
  .sheet-progress { display: none; }
  .sheet-body { columns: 2; column-gap: 10mm; }
  .sheet-group { height: auto; padding: 6px 0 2px; color: #000; font-size: 10pt; border-bottom: .75pt solid #000; }
  .sheet-row { min-height: 0; border-bottom: .5pt solid #bbb; break-inside: avoid; }
  .sheet-keep { break-inside: avoid; }
  .sheet-row::before { left: -22px; width: 12px; height: 12px; margin-top: -6px; border: 1pt solid #000; border-radius: 2px; background: #fff !important; }
  .sheet-row::after { display: none; }
  .sheet-row.is-done .sheet-name, .sheet-row.is-done .sheet-qty { text-decoration: none; color: #000; }
  .sheet-row.is-done .sheet-detail { opacity: 1; }
  .sheet-name { font-size: 10.5pt; padding: 3px 0 0; }
  .sheet-qty { font-size: 11pt; }
  .sheet-detail { font-size: 8pt; color: #333; padding-bottom: 3px; }
  .sheet-split { max-width: none; }
  .sheet-split li + li { border-top: .5pt dotted #999; }
  .sheet-split b { color: #000; }
  .pack { display: block; columns: 2; column-gap: 8mm; }
  .pack-card { border: .75pt solid #000; border-radius: 0; margin-bottom: 4mm; padding: 3mm; }
  a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
