:root {
  --primary: #6d28d9;
  --primary-2: #8b5cf6;
  --on-primary: #fff;
  --primary-soft: #f1e9ff;
  --bg: #f6f3fb;
  --surface: #ffffff;
  --surface-2: #faf8fd;
  --text: #1f1630;
  --muted: #776d85;
  --line: #e8e1f1;
  --nav-bg: #ffffff;
  --nav-icon: #6b6278;
  --nav-pill: #f1e9ff;
  --nav-pill-text: #5b21b6;
  --shadow: 0 6px 22px rgba(60, 30, 100, .07);
  --shadow-nav: 0 14px 40px rgba(50, 20, 90, .18);
  --green: #16a34a; --green-soft: #e7f7ed;
  --yellow: #b7791f; --yellow-soft: #fff6e0;
  --blue: #2563eb; --blue-soft: #e9f0ff;
  --red: #dc2626; --red-soft: #fdecec;
  --bar-h: 62px;
  --nav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
[data-theme="dark"] {
  --primary: #a78bfa;
  --primary-2: #8b5cf6;
  --on-primary: #1a0f2b;
  --primary-soft: #2a1d3c;
  --bg: #0f0b15;
  --surface: #18121f;
  --surface-2: #201829;
  --text: #f6f1fc;
  --muted: #aa9fb7;
  --line: #2f253a;
  --nav-bg: #1c1c1f;
  --nav-icon: #a7a3ad;
  --nav-pill: #3a3a3f;
  --nav-pill-text: #ffffff;
  --shadow: 0 8px 26px rgba(0, 0, 0, .3);
  --shadow-nav: 0 16px 44px rgba(0, 0, 0, .55);
  --green: #4ade80; --green-soft: #12331f;
  --yellow: #fbbf24; --yellow-soft: #33280d;
  --blue: #7aa5ff; --blue-soft: #15223f;
  --red: #f87171; --red-soft: #3b171a;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--primary); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App bar ---------- */
.appbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: calc(var(--bar-h) + var(--safe-t)); padding: var(--safe-t) 10px 0 14px;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand-logo { width: 38px; height: 38px; border-radius: 11px; background: #fff; padding: 3px; object-fit: contain; box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.appbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.appbar-title strong { font-size: 15.5px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-title small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; gap: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; color: var(--text); transition: background .15s, transform .15s; }
.icon-btn:active { transform: scale(.92); }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Sub-tab di bawah appbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; z-index: 25;
  top: calc(var(--bar-h) + var(--safe-t));
  display: flex; gap: 6px; padding: 8px 14px; overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar button { flex: none; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); background: var(--surface); }
.tabbar button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- View ---------- */
.view { padding: calc(var(--bar-h) + var(--safe-t) + 16px) 16px calc(var(--nav-h) + 44px + var(--safe-b)); max-width: 780px; margin: 0 auto; animation: fade .2s ease; }
body.has-tabs .view { padding-top: calc(var(--bar-h) + var(--safe-t) + 66px); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { position: relative; overflow: hidden; border-radius: 24px; padding: 22px 20px; background: linear-gradient(135deg, #4c1d95, #6d28d9 55%, #8b5cf6); color: #fff; box-shadow: 0 16px 36px rgba(91, 33, 182, .25); }
.hero::after { content: ""; position: absolute; width: 200px; height: 200px; right: -60px; top: -90px; border-radius: 50%; background: rgba(255,255,255,.09); }
.hero-top { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.hero-top img { width: 56px; height: 56px; border-radius: 16px; background: #fff; padding: 5px; object-fit: contain; }
.hero small { opacity: .82; font-size: 12px; }
.hero h1 { margin: 2px 0 0; font-size: 20px; line-height: 1.25; letter-spacing: -.3px; }
.hero-meta { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .chip { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.2); color: #fff; }

.section-title { margin: 22px 4px 10px; font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 2px; }
.page-head { margin: 2px 4px 14px; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.app-card { position: relative; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 15px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-height: 124px; transition: transform .15s, border-color .15s; }
.app-card:active { transform: scale(.97); }
.app-card:hover { border-color: var(--primary-2); }
.app-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.app-card b { font-size: 14px; line-height: 1.3; }
.app-card .desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.list .app-card { flex-direction: row; align-items: center; min-height: 0; }
.list { display: flex; flex-direction: column; gap: 10px; }

.recent { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.recent::-webkit-scrollbar { display: none; }
.recent button { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.recent .app-icon { width: 32px; height: 32px; border-radius: 10px; }
.recent svg { width: 18px; height: 18px; }

/* ---------- Komponen ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.card + .card, .card + .stack, .stack + .card { margin-top: 12px; }
.card h3 { margin: 0 0 4px; font-size: 15.5px; }
.card .hint { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; width: 70px; height: 70px; right: -26px; top: -26px; border-radius: 50%; background: var(--primary-soft); }
.stat span { position: relative; z-index: 1; font-size: 11.5px; color: var(--muted); font-weight: 700; display: block; }
.stat b { position: relative; z-index: 1; display: block; font-size: 22px; letter-spacing: -.5px; margin-top: 4px; }
.stat.green b { color: var(--green); } .stat.red b { color: var(--red); } .stat.yellow b { color: var(--yellow); } .stat.blue b { color: var(--blue); } .stat.purple b { color: var(--primary); }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats.four .stat { padding: 10px 6px; text-align: center; }
.stats.four .stat::after { display: none; }
.stats.four .stat b { font-size: 19px; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.form .full, .form > .btn-row { grid-column: 1 / -1; }
.field { margin-bottom: 12px; min-width: 0; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 14px; outline: none; min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: flex-end; }
.toolbar > .field { flex: 1 1 140px; margin-bottom: 0; }
.toolbar > .input { flex: 1 1 160px; width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 16px; min-height: 44px; border-radius: 13px; font-weight: 800; font-size: 13.5px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; transition: transform .12s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 28%, transparent); }
.btn.danger { color: var(--red); background: var(--red-soft); border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 12.5px; border-radius: 11px; }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btn-row .btn { flex: 1 1 auto; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--primary); color: var(--on-primary); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; padding: 4px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.yellow { background: var(--yellow-soft); color: var(--yellow); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.status-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pick button { padding: 7px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 800; border: 1.5px solid var(--line); color: var(--muted); background: var(--surface); }
.status-pick button.on.green { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.status-pick button.on.yellow { background: var(--yellow-soft); color: var(--yellow); border-color: var(--yellow); }
.status-pick button.on.blue { background: var(--blue-soft); color: var(--blue); border-color: var(--blue); }
.status-pick button.on.red { background: var(--red-soft); color: var(--red); border-color: var(--red); }

/* Daftar data (pengganti tabel di HP) */
.items { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.item .right { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.item .acts { display: flex; gap: 2px; flex: none; }
.item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.item.block { flex-direction: column; align-items: stretch; gap: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); font-size: 13.5px; }
.empty svg { width: 34px; height: 34px; color: var(--primary); margin-bottom: 6px; }
.bulkbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 10px; border-radius: 14px; background: var(--red-soft); color: var(--red); font-weight: 700; font-size: 13px; }
.bulkbar .btn { margin-left: auto; }

/* Bar sederhana */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; font-size: 10.5px; color: var(--muted); }
.bars .stack-bar { width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; border-radius: 8px 8px 3px 3px; overflow: hidden; min-height: 3px; background: var(--line); }
.bars .stack-bar i { display: block; }
.hbar { margin-bottom: 12px; }
.hbar .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; gap: 10px; }
.hbar .track { height: 9px; border-radius: 99px; background: var(--primary-soft); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.photo-pick { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface-2); color: var(--primary); font-weight: 700; font-size: 13.5px; cursor: pointer; width: 100%; }
.photo-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; margin-top: 8px; }
.gps { display: flex; align-items: center; gap: 9px; font-size: 12.5px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); margin-bottom: 12px; }
.gps i { width: 9px; height: 9px; border-radius: 50%; background: #b8b2bd; flex: none; }
.gps i.ok { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.gps i.bad { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.notice { padding: 12px 14px; border-radius: 14px; font-size: 13px; margin-top: 12px; }
.notice.ok { background: var(--green-soft); color: var(--green); }
.notice.err { background: var(--red-soft); color: var(--red); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv b { text-align: right; }
.total-box { margin-top: 10px; padding: 14px; border-radius: 14px; background: var(--primary-soft); display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.total-box b { font-size: 19px; color: var(--primary); }

/* Dokumen cetak (kwitansi, slip, rapor) — selalu putih */
.paper { background: #fff; color: #1b1424; border-radius: 16px; padding: 20px; border: 1px solid var(--line); font-size: 13px; }
.paper .kop { display: flex; gap: 12px; align-items: center; padding-bottom: 10px; border-bottom: 2px solid #4c1d95; margin-bottom: 12px; }
.paper .kop img { width: 46px; height: 46px; object-fit: contain; }
.paper .kop b { display: block; font-size: 15px; color: #4c1d95; }
.paper .kop small { color: #666; }
.paper h4 { text-align: center; letter-spacing: 3px; margin: 8px 0 12px; color: #4c1d95; }
.paper .kv { border-color: #e5e0ea; }
.paper .kv span:first-child { color: #555; }
.paper .ttd { margin-top: 26px; text-align: right; font-size: 12px; }
.paper .ttd b { display: inline-block; min-width: 160px; margin-top: 46px; padding-top: 4px; border-top: 1px solid #333; text-align: center; }
.paper .total-box { background: #f1e9ff; } .paper .total-box b { color: #4c1d95; }

/* ---------- Bottom sheet ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 70; background: rgba(15, 8, 24, .5); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; }
.sheet { width: min(100%, 560px); max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); animation: up .22s ease; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } }
@media (min-width: 620px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; } .sheet::before { display: none; } }

/* ---------- Bottom navigation (floating pill) ---------- */
.bottom-nav { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); width: min(calc(100% - 24px), 460px); height: var(--nav-h); padding: 0 8px; border-radius: 999px; background: var(--nav-bg); box-shadow: var(--shadow-nav); border: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.nav-item { flex-shrink: 0; position: relative; height: 50px; min-width: 50px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 13px; border-radius: 999px; color: var(--nav-icon); transition: background .25s ease, color .2s, padding .25s; }
.nav-item .label { max-width: 0; overflow: hidden; white-space: nowrap; font-weight: 800; font-size: 13px; opacity: 0; transition: max-width .3s ease, opacity .2s; }
.nav-item.active { background: var(--nav-pill); color: var(--nav-pill-text); padding: 0 14px 0 13px; gap: 6px; }
.nav-item.active .label { max-width: 110px; opacity: 1; }
.nav-item:active { transform: scale(.94); }
.nav-item.center { width: 54px; height: 54px; min-width: 54px; padding: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 45%, transparent); }
.nav-item.center.active { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 3px; }
.nav-item.center .label { display: none; }

/* ---------- Toast & overlay ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 30px + var(--safe-b)); transform: translate(-50%, 12px); opacity: 0; pointer-events: none; z-index: 90; background: #241530; color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 13px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 12px 30px rgba(0,0,0,.25); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }
.overlay { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(3px); font-weight: 700; font-size: 13.5px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 0; color: var(--muted); font-size: 13.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 380px) { .form { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Cetak: hanya elemen .paper yang tampil */
@media print {
  body * { visibility: hidden !important; }
  .print-target, .print-target * { visibility: visible !important; }
  .print-target { position: absolute; left: 0; top: 0; width: 100%; border: 0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
