/* style.css — mobile-first, sidebar di layar lebar, bottom-nav di HP. */
:root {
  --bg: #f3f4f6; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --pri: #1f2937; --pri-ink: #fff; --acc: #2563eb; --ok: #16a34a; --err: #dc2626; --warn: #d97706;
  --sale: #dbeafe; --sale-ink: #1d4ed8; --buy: #dcfce7; --buy-ink: #15803d; --move: #fef3c7; --move-ink: #b45309;
  --ret: #fee2e2; --ret-ink: #b91c1c; --adj: #ede9fe; --adj-ink: #6d28d9;
  --side: 220px; --top: 52px; --bottom: 58px; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--acc); text-decoration: none; }
h1.page-title { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
h3 { font-size: 15px; margin: 12px 0 6px; }
p { margin: 6px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; padding: 14px; }
.neg { color: var(--err); } .pos { color: var(--ok); } .nowrap { white-space: nowrap; }
.link { font-weight: normal; font-size: 13px; margin-left: 8px; }
.hidden { display: none !important; }

/* layout */
#app { min-height: 100vh; }
.top { position: fixed; top: 0; left: 0; right: 0; height: var(--top); background: var(--pri); color: var(--pri-ink); display: flex; align-items: center; gap: 12px; padding: 0 14px; z-index: 20; }
.top .brand { font-weight: 800; letter-spacing: .5px; cursor: pointer; white-space: nowrap; }
.top .brand .muted { color: #9ca3af; font-weight: 400; }
.top .biz { background: #374151; color: #fff; border: 0; border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.top .btn-add { background: #374151; color: #fff; border: 0; border-radius: 6px; width: 30px; height: 30px; font-size: 18px; line-height: 1; cursor: pointer; }
.top .btn-add:hover { background: var(--acc); }
.row .btn.small { margin-top: 3px; min-height: 38px; }
.top .who { margin-left: auto; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .who .muted { color: #9ca3af; }
.side { display: none; }
main { padding: calc(var(--top) + 12px) 12px calc(var(--bottom) + 16px); max-width: 1100px; }
.bottom { position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); gap: 2px; }
.bottom a span { font-size: 20px; line-height: 1; }
.bottom a.on { color: var(--acc); font-weight: 600; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; position: fixed; top: var(--top); left: 0; bottom: 0; width: var(--side); background: var(--card); border-right: 1px solid var(--line); padding: 10px 0; overflow-y: auto; }
  .side a { padding: 9px 16px; color: var(--ink); font-size: 14px; }
  .side a:hover { background: var(--bg); } .side a.on { background: #eef2ff; color: var(--acc); font-weight: 600; }
  main { margin-left: var(--side); padding: calc(var(--top) + 18px) 24px 30px; }
  .bottom { display: none; }
}

/* cards, tiles, lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card.err { border-color: var(--err); color: var(--err); } .card.warn { border-color: var(--warn); background: #fffbeb; } .card.ok { border-color: var(--ok); background: #f0fdf4; }
.card.warn ul { margin: 6px 0 0 18px; }
.scroll { overflow-x: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tiles.small { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.tile .k { font-size: 12px; color: var(--muted); } .tile .v { font-size: 20px; font-weight: 700; margin-top: 2px; } .tile .s { font-size: 12px; color: var(--muted); }
.tiles.small .tile .v { font-size: 17px; }
.list .li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .li:last-child { border-bottom: 0; } .list .li:hover { background: #f9fafb; }
.li-main { flex: 1; min-width: 0; } .li-main > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-right { text-align: right; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.tag-sale { background: var(--sale); color: var(--sale-ink); } .tag-buy { background: var(--buy); color: var(--buy-ink); }
.tag-move { background: var(--move); color: var(--move-ink); } .tag-ret { background: var(--ret); color: var(--ret-ink); }
.tag-adj { background: var(--adj); color: var(--adj-ink); } .tag-void { background: #e5e7eb; color: #374151; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.quick .q { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px; border-radius: var(--radius); font-size: 22px; color: var(--ink); }
.quick .q b { font-size: 12px; }
.q.sale { background: var(--sale); } .q.buy { background: var(--buy); } .q.move { background: var(--move); } .q.ret { background: var(--ret); }
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.menu-grid a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; background: var(--bg); border-radius: var(--radius); color: var(--ink); font-size: 13px; text-align: center; }
.menu-grid a span { font-size: 24px; }

/* forms */
.form label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.form label.chk, label.chk { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; }
input, select, textarea, button { font: inherit; }
input:not([type=checkbox]), select, textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); margin-top: 3px; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--acc); }
textarea { font-family: ui-monospace, monospace; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 10px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 6px; align-items: center; } .row > input, .row > select { flex: 1; }
.row-btn { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn { border: 1px solid #d1d5db; background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 38px; }
.btn:hover { background: #f9fafb; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; } .btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.small { padding: 4px 9px; min-height: 30px; font-size: 13px; } .btn.big { padding: 12px 22px; font-size: 16px; font-weight: 700; }
.btn.wide { width: 100%; }
.btn-x { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }
.err-text { color: var(--err); font-size: 13px; margin-top: 8px; min-height: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { border: 1px solid #d1d5db; background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.range-custom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.range-custom input { width: auto; }
.range-label { margin-bottom: 8px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl .r { text-align: right; } .tbl tfoot th { color: var(--ink); font-size: 14px; }
.tbl tr[data-p], .tbl tr[data-trx] { cursor: pointer; } .tbl tr[data-p]:hover { background: #f9fafb; }
.tbl.sticky th:first-child, .tbl.sticky td:first-child { position: sticky; left: 0; background: var(--card); }
.tbl.lines input.n { width: 74px; text-align: right; padding: 5px 6px; min-height: 32px; margin: 0; }
.tbl.lines input.money { width: 100px; }
/* baris transaksi di HP / layar sempit: tabel → kartu bertumpuk */
@media (max-width: 860px) {
  .tbl.lines thead { display: none; }
  .tbl.lines, .tbl.lines tbody { display: block; }
  .tbl.lines tr { display: grid; grid-template-columns: 1fr 1fr auto; grid-template-areas: "barang barang del" "stok qty sub" "list harga diskon" "selisih selisih selisih"; gap: 6px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
  .tbl.lines td.c-list { grid-area: list; } .tbl.lines td.c-selisih { grid-area: selisih; }
  .tbl.lines td.c-selisih::before { display: inline; margin-right: 6px; }
  .tbl.lines td { display: block; border: 0; padding: 0; text-align: left; }
  .tbl.lines td.c-barang { grid-area: barang; } .tbl.lines td.c-del { grid-area: del; }
  .tbl.lines td.c-stok { grid-area: stok; } .tbl.lines td.c-qty { grid-area: qty; } .tbl.lines td.c-sub { grid-area: sub; text-align: right; }
  .tbl.lines td.c-harga { grid-area: harga; } .tbl.lines td.c-diskon { grid-area: diskon; }
  .tbl.lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); }
  .tbl.lines input.n, .tbl.lines input.money { width: 100%; }
  .qty input { width: 56px !important; }
  .top .who { display: none; } .top .biz { max-width: 140px; }
}
.qty { display: inline-flex; align-items: center; gap: 2px; }
.qty button { width: 30px; height: 32px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; cursor: pointer; font-size: 16px; }
.qty input { width: 54px !important; }

/* kasir */
.picker { position: relative; }
.picker-in { font-size: 16px; padding: 11px 12px; }
.picker-dd { position: absolute; left: 0; right: 0; top: 100%; z-index: 15; background: #fff; border: 1px solid #d1d5db; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.pk { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pk:last-child { border-bottom: 0; } .pk.on, .pk:hover { background: #eef2ff; }
.total-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.big { font-size: 22px; font-weight: 800; }
.total-box { text-align: right; margin: 8px 0; } .total-box > div { padding: 2px 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 12px; margin-bottom: 10px; font-size: 14px; }
.kv > div > span { color: var(--muted); font-size: 12px; display: block; }

/* modal & toast */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 16px; overflow-y: auto; }
@media (min-width: 700px) {
  .modal-wrap { align-items: center; }
  .modal { width: 520px; border-radius: 14px; } .modal.wide { width: 820px; max-width: 95vw; }
}
#toasts { position: fixed; top: calc(var(--top) + 8px); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--pri); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 14px; opacity: 0; transform: translateY(-6px); transition: .25s; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: none; } .toast.err { background: var(--err); } .toast.ok { background: var(--ok); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 24px; }
.login h1 { margin: 0; letter-spacing: 1px; }

/* chart */
.chart { width: 100%; height: 150px; display: block; }
.chart rect { fill: var(--acc); } .chart text { font-size: 10px; fill: var(--muted); }

/* gambar produk */
.thumb { border-radius: 8px; object-fit: cover; flex: none; background: #e5e7eb; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.thumb-empty { color: #6b7280; font-weight: 700; letter-spacing: .5px; }
.pk { display: flex; align-items: center; gap: 10px; } .pk-main { min-width: 0; flex: 1; }
.img-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.img-row .thumb { border-radius: 12px; }
/* header: bahasa */
.top .btn-lang { background: transparent; color: #d1d5db; border: 1px solid #4b5563; border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.top .btn-lang:hover { color: #fff; border-color: #9ca3af; }
/* pengeluaran & kas */
.q.exp { background: #fce7f3; } .tag-exp { background: #fce7f3; color: #9d174d; }
.tile.on { outline: 2px solid var(--acc); }
.quick { grid-template-columns: repeat(5, 1fr); }

/* pemilih tanggal sendiri */
input.dt { cursor: pointer; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M3 1h1v1h8V1h1v1h1.5A1.5 1.5 0 0 1 16 3.5v10A1.5 1.5 0 0 1 14.5 15h-13A1.5 1.5 0 0 1 0 13.5v-10A1.5 1.5 0 0 1 1.5 2H3zM1 5v8.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5V5z'/%3E%3C/svg%3E") no-repeat right 10px center; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.dp-dow { font-size: 11px; color: var(--muted); padding: 4px 0; }
.dp-day { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 8px 0; cursor: pointer; font-size: 15px; }
.dp-day:hover { background: var(--bg); } .dp-day.today { border-color: var(--acc); } .dp-day.on { background: var(--acc); color: #fff; font-weight: 700; }
.dp-time { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; } .dp-time span { color: var(--muted); font-size: 13px; margin-right: 4px; }
.dp-time select { width: auto; margin: 0; }

/* riwayat pembelian pembeli (retur / ongkir), tombol OK-Hapus qty, biaya bulanan */
.grid-span { grid-column: 1 / -1; margin-bottom: 8px; }
.list.hist { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; margin-top: 4px; }
.list.hist .li.on { background: #eef2ff; outline: 2px solid var(--acc); border-radius: 8px; }
.qty { flex-wrap: nowrap; } .tbl.lines td.c-qty { white-space: nowrap; }
.qty .btn.small { min-height: 32px; padding: 4px 8px; margin-left: 4px; white-space: nowrap; }

/* kelompok menu */
.menu-group { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 14px 16px 4px; }
.menu-grid .menu-group { grid-column: 1 / -1; padding: 8px 4px 0; }

.tbl.lines td.c-note input { min-width: 160px; margin: 0; }
@media (max-width: 860px) { .tbl.lines tr { grid-template-areas: "barang barang del" "stok qty sub" "list harga diskon" "selisih selisih selisih" "note note note"; } .tbl.lines td.c-note { grid-area: note; } }
