/* Admin Sayur — tampilan ala iOS (iPhone/iPad): grouped background, kartu inset, sidebar di PC, tab bar di HP */
:root {
  --bg: #f2f2f7; --card: #fff; --elev: #fff; --text: #1c1c1e; --muted: #8a8a8e; --line: rgba(60, 60, 67, .16);
  --fill: rgba(118, 118, 128, .12); --fill-2: rgba(118, 118, 128, .08);
  --tint: #248a3d; --tint-soft: rgba(36, 138, 61, .12); --on-tint: #fff;
  --danger: #d70015; --ok: #248a3d; --warn: #c93400;
  --s-paid: #1f8a4c; --s-unpaid: #5856d6;              /* grafik: lunas / belum lunas (tervalidasi CVD) */
  --radius: 14px; --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --side: 252px; --tab-h: 58px;
  --bar: rgba(249, 249, 249, .82);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --card: #1c1c1e; --elev: #2c2c2e; --text: #f5f5f7; --muted: #98989f; --line: rgba(84, 84, 88, .55);
    --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .16);
    --tint: #30d158; --tint-soft: rgba(48, 209, 88, .16); --on-tint: #002a0c;
    --danger: #ff453a; --ok: #30d158; --warn: #ff9f0a;
    --s-paid: #2fa85c; --s-unpaid: #7472f0;
    --shadow: none; --bar: rgba(22, 22, 23, .8);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }
a { color: var(--tint); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* ---------- kerangka: sidebar (PC) & tab bar (HP) ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--side); display: flex; flex-direction: column; padding: 18px 12px 14px; background: var(--bar); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-right: .5px solid var(--line); }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); }
.sidebar .brand img { width: 38px; height: 38px; }
.sidebar .brand b { display: block; font-size: 17px; letter-spacing: -.02em; }
.sidebar .brand small { display: block; font-size: 12px; color: var(--muted); }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: 15px; }
.sidebar nav a svg { width: 21px; height: 21px; color: var(--tint); }
.sidebar nav a:hover { background: var(--fill-2); }
.sidebar nav a.on { background: var(--tint); color: var(--on-tint); }
.sidebar nav a.on svg { color: var(--on-tint); }
.sidebar .foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: .5px solid var(--line); }
.sidebar .foot .av { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--tint-soft); color: var(--tint); font-weight: 800; text-transform: uppercase; }
.sidebar .foot .who { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.main { margin-left: var(--side); padding: 28px 32px 48px; min-height: 100dvh; }
.main > .wrap { max-width: 1120px; margin: 0 auto; }
.tabbar { display: none; }
.mhead { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 0 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
  .mhead { display: flex; position: sticky; top: 0; z-index: 25; align-items: center; justify-content: space-between; margin: 0 -16px 4px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--bar); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-bottom: .5px solid var(--line); }
  .mhead .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
  .mhead .brand img { width: 26px; height: 26px; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 6px 4px env(safe-area-inset-bottom); background: var(--bar); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-top: .5px solid var(--line); }
  .tabbar a { display: grid; justify-items: center; align-content: start; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
  .tabbar a.on { color: var(--tint); }
  .tabbar svg { width: 26px; height: 26px; }
}

/* ---------- judul halaman (large title iOS) ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.page-head h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 16px; color: var(--tint); }
.back svg { width: 18px; height: 18px; }
@media (max-width: 900px) { .page-head { margin-top: 10px; } .page-head h1 { font-size: 30px; } }

/* ---------- komponen ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 16px 18px; }
.card h2 { margin: 0 0 2px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.section-title { margin: 22px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--tint-soft); color: var(--tint); font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; transition: transform .1s, opacity .15s, background .15s; }
.btn:active { transform: scale(.97); opacity: .8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--tint); color: var(--on-tint); }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.icon { width: 36px; padding: 0; }
.btn svg { width: 18px; height: 18px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-weight: 400; }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 0; border-radius: 10px; background: var(--fill); color: var(--text); font-size: 15px; font-weight: 400; outline: none; transition: box-shadow .15s, background .15s; }
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { background: var(--card); box-shadow: 0 0 0 2px var(--tint); }
.input.num { text-align: right; }
.input[readonly] { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--fill); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--s-unpaid) 15%, transparent); color: var(--s-unpaid); }
.badge.brand { background: var(--tint-soft); color: var(--tint); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 36px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 2px; border-radius: 10px; background: var(--fill); }
.seg button { min-height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--elev); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
@media (max-width: 560px) { .seg { display: grid; width: 100%; } .seg button { padding: 0 6px; } }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: 14px 16px; }
.stat p { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat b { display: block; margin-top: 4px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.stat .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; }
@media (max-width: 1100px) { .stats:not(.three) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .stats { gap: 10px; } .stats.three { grid-template-columns: 1fr 1fr; } .stats.three .stat:last-child { grid-column: span 2; } .stat { padding: 12px 14px; } .stat p { font-size: 12px; } .stat b { font-size: clamp(15px, 4.6vw, 20px); } }

/* tabel daftar (PC) / kartu (HP) */
.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 18px; border-bottom: .5px solid var(--line); }
.list td { padding: 12px 18px; border-bottom: .5px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tr.click { cursor: pointer; }
.list tr.click:hover td { background: var(--fill-2); }
.units { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 9px; background: var(--fill); font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; font-weight: 700; }
.chip.na b { color: var(--muted); font-weight: 500; }
button.chip { border: 1px solid transparent; cursor: pointer; }
button.chip:hover { border-color: var(--tint); background: var(--tint-soft); }
.cards { display: none; }
@media (max-width: 760px) {
  .list.responsive { display: none; }
  .cards { display: grid; }
  .cards .item { display: flex; gap: 12px; align-items: center; min-height: 60px; padding: 11px 16px; border-bottom: .5px solid var(--line); }
  .cards .item:last-child { border-bottom: 0; }
  .cards .item:active { background: var(--fill-2); }
  .cards .item .grow { min-width: 0; flex: 1; }
  .cards .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- editor invoice ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.sum { position: sticky; top: 24px; }
.sum .big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
@media (max-width: 1100px) { .editor { grid-template-columns: minmax(0, 1fr); } .sum { position: static; } }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.picker { position: relative; }
.results { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 6px); max-height: 360px; overflow: auto; background: var(--elev); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .18), 0 0 0 .5px var(--line); }
.results .r { padding: 10px 14px; border-bottom: .5px solid var(--line); }
.results .r:last-child { border-bottom: 0; }
.results .r .n { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 8px 6px; border-bottom: .5px solid var(--line); }
.items td { padding: 6px; border-bottom: .5px solid var(--line); vertical-align: middle; }
.items .input { min-height: 38px; padding: 7px 10px; }
.items td.total { text-align: right; font-weight: 700; white-space: nowrap; }
@media (max-width: 760px) {
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: 100%; }
  .items tr { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, .7fr) minmax(0, 1.4fr) auto; gap: 6px; padding: 10px 0; border-bottom: .5px solid var(--line); }
  .items td { border: 0; padding: 0; }
  .items td.c-name { grid-column: 1 / -1; }
  .items td.total { grid-column: 1 / 4; text-align: left; align-self: center; }
  .items td.c-no { display: none; }
}
.markup-row { display: grid; grid-template-columns: 1.1fr 1fr 1.1fr 1fr auto; gap: 8px; align-items: end; padding: 10px 0; border-bottom: .5px solid var(--line); }
.markup-row:last-child { border-bottom: 0; }
@media (max-width: 640px) { .markup-row { grid-template-columns: 1fr 1fr; } .markup-row .del { justify-self: end; } }

/* ---------- grafik pemasukan ---------- */
.chart-card .head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.on { fill: var(--fill-2); }
.tip { position: absolute; z-index: 5; min-width: 168px; padding: 9px 11px; border-radius: 12px; background: var(--elev); box-shadow: 0 10px 30px rgba(0, 0, 0, .18), 0 0 0 .5px var(--line); font-size: 13px; pointer-events: none; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.tip div span:last-child { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; }
.hbars { display: grid; gap: 12px; }
.hbar .t { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.hbar .t span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .t span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar .track { height: 8px; margin-top: 5px; border-radius: 4px; background: var(--fill-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--tint); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
details.tbl summary { cursor: pointer; color: var(--tint); font-weight: 600; font-size: 14px; padding: 4px 0; }
details.tbl table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 13px; }
details.tbl th, details.tbl td { padding: 6px 4px; border-bottom: .5px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
details.tbl th:first-child, details.tbl td:first-child { text-align: left; }

/* ---------- dialog (sheet di HP) & toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .35); animation: fade .15s; }
.dialog { width: 100%; max-width: 640px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--card); border-radius: 18px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); animation: pop .18s; }
.dialog.sm { max-width: 400px; }
.dialog header { padding: 18px 20px 4px; }
.dialog header h3 { margin: 0; font-size: 18px; font-weight: 700; }
.dialog .body { padding: 12px 20px; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(18px + env(safe-area-inset-bottom)); }
@media (max-width: 560px) { .overlay { place-items: end center; padding: 0; } .dialog { border-radius: 22px 22px 0 0; max-height: 92dvh; animation: sheet .22s ease-out; } .dialog footer .btn { flex: 1; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet { from { transform: translateY(100%); } }
#toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
#toast div { padding: 11px 18px; border-radius: 14px; background: rgba(30, 30, 30, .92); color: #fff; font-weight: 600; font-size: 14px; text-align: center; backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: pop .2s; }
#toast div.err { background: var(--danger); }
@media (max-width: 900px) { #toast { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); } }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; padding: 32px 26px; text-align: center; }
.login img { width: 76px; }
.login h1 { margin: 10px 0 2px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login form { display: grid; gap: 12px; margin-top: 22px; text-align: left; }
.login .btn { min-height: 48px; font-size: 16px; }
.err-text { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; }

/* ---------- tampilan invoice ---------- */
.doc-wrap { overflow: hidden; border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, .15); background: #fff; margin: 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
@media print {
  body { background: #fff; }
  .sidebar, .mhead, .tabbar, .toolbar, .page-head, #toast, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; max-width: none; }
  .main > .wrap { max-width: none; }
  .doc-wrap { box-shadow: none; border-radius: 0; width: auto !important; height: auto !important; overflow: visible; }
  .doc-wrap > .doc { transform: none !important; }
}

/* ---------- date picker ---------- */
.datebtn { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; color: var(--text); }
.datebtn svg { width: 17px; height: 17px; flex: none; color: var(--tint); }
.datebtn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.datebtn.empty span { color: var(--muted); }
.dp-back { position: fixed; inset: 0; z-index: 55; background: transparent; }
.dp { position: fixed; z-index: 56; width: 320px; padding: 14px; background: var(--elev); border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .22), 0 0 0 .5px var(--line); animation: pop .16s; }
.dp-now { padding: 2px 4px 10px; border-bottom: .5px solid var(--line); margin-bottom: 10px; }
.dp-now small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.dp-now b { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.dp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.dp-head select { flex: 1; min-width: 0; height: 36px; padding: 0 8px; border: 0; border-radius: 10px; background: var(--fill); font-weight: 600; }
.dp-head button { width: 36px; height: 36px; flex: none; border: 0; border-radius: 10px; background: var(--fill); color: var(--tint); font-size: 20px; line-height: 1; cursor: pointer; }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-week span { padding: 4px 0; font-size: 11px; font-weight: 600; color: var(--muted); }
.dp-week span:last-child, .dp-grid button.sun { color: var(--danger); }
.dp-grid button { aspect-ratio: 1; min-height: 38px; border: 0; border-radius: 50%; background: transparent; font-weight: 500; font-size: 15px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dp-grid button:hover { background: var(--fill-2); }
.dp-grid button.out { color: var(--muted); opacity: .45; }
.dp-grid button.today { color: var(--tint); font-weight: 700; }
.dp-grid button.sel { background: var(--tint); color: var(--on-tint); font-weight: 700; }
.dp-foot { display: flex; gap: 8px; margin-top: 10px; }
.dp-foot .btn { flex: 1; }
@media (max-width: 560px) {
  .dp-back { background: rgba(0, 0, 0, .35); animation: fade .15s; }
  .dp { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; animation: sheet .22s ease-out; }
  .dp::before { content: ""; display: block; width: 40px; height: 5px; margin: -6px auto 10px; border-radius: 3px; background: var(--line); }
  .dp-grid button { min-height: 44px; font-size: 17px; }
  .dp-foot .btn { min-height: 46px; }
}
