:root {
  --bg: #F4F5F1;
  --surface: #FFFFFF;
  --ink: #16201B;
  --ink-2: #3D4842;
  --muted: #4F5A54;
  --line: #E2E5DF;
  --line-2: #D3D8D1;
  --green: #1F6F4A;
  --green-dark: #164F35;
  --green-soft: #E8F1EC;
  --amber: #8F4E12;
  --amber-dark: #5E3509;
  --amber-soft: #FBF4EC;
  --amber-line: #EED9C2;
  --red: #B42318;
  --radius: 16px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
body.is-loading { visibility: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #7FB89A; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.c-green { color: var(--green); }
.c-amber { color: var(--amber); }
.strong { font-weight: 700; }
code { background: var(--green-soft); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-center { justify-content: center; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--green); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 15px; background: none; white-space: nowrap; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line-2); font-weight: 500; }
.btn-ghost:hover { background: #F7F8F5; }
.btn-danger { background: var(--red); color: #fff; }
.btn-icon { width: 44px; padding: 0; border-color: var(--line-2); background: var(--surface); color: var(--ink-2); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }

/* ---------- Lock screen ---------- */
.lock { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lock-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 28px; box-shadow: 0 12px 40px rgba(22, 32, 27, .08); display: flex; flex-direction: column; gap: 20px; }
.lock-title { font-family: var(--display); font-size: 24px; font-weight: 600; text-align: center; margin: 0 0 18px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); transition: background .12s, border-color .12s; }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-hidden { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.lock-msg, .form-msg { min-height: 22px; margin: 12px 0 0; text-align: center; color: var(--red); font-size: 14px; font-weight: 500; }
.form-msg { text-align: left; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.keypad button { height: 64px; border-radius: 16px; border: 1px solid var(--line); background: #F7F8F5; font-family: var(--display); font-size: 24px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.keypad button:active { background: var(--green-soft); }
.keypad button:disabled { opacity: .5; }
.setup { display: flex; flex-direction: column; gap: 14px; }
.setup .lock-title { margin-bottom: 0; }

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(22, 32, 27, .12); padding: 6px; min-width: 170px; z-index: 20; }
.menu-list button { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: none; border-radius: 8px; font-size: 15px; }
.menu-list button:hover { background: #F2F4F0; }
.main { padding-top: 32px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 28px; }

.head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.h1 { margin: 0; font-family: var(--display); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.h2 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 600; }

/* ---------- Period ---------- */
.period fieldset { margin: 0; padding: 0; border: 0; }
.period legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.period-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.date-pill { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); font-size: 13px; color: var(--muted); }
.date-pill input { border: 0; background: transparent; font-size: 15px; color: var(--ink); min-height: 40px; }
.dash { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; justify-content: flex-end; }
.chip { min-height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.chip.active { background: var(--green-soft); border-color: #BFD9CA; color: var(--green-dark); }

/* ---------- Summary cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.card-label { font-size: 14px; color: var(--muted); }
.card-dark .card-label, .card-dark .card-sub { color: #C9D2CC; }
.card-value { font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.card-sub { font-size: 13px; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--green-soft); overflow: hidden; }
.bar-amber { background: var(--amber-line); }
.bar-fill { height: 100%; width: 0; background: var(--green); transition: width .25s; }

/* ---------- Panel & table ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { padding: 18px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.tools { display: flex; flex-wrap: wrap; gap: 10px; }
.tools select, .search input { min-height: 44px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); padding: 0 14px; font-size: 15px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--muted); }
.search input { width: 240px; padding-left: 40px; }
.table-box { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; min-width: 980px; }
.tbl th, .tbl td { padding: 14px 12px; text-align: left; vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 24px; }
.tbl thead th { background: #F7F8F5; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tbl tbody tr { border-top: 1px solid #ECEEE9; }
.tbl tbody tr:hover { background: #FAFBF9; }
.tbl tfoot tr { border-top: 2px solid var(--line); background: #F7F8F5; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .date { white-space: nowrap; color: var(--ink-2); }
.tbl .guna { color: var(--muted); max-width: 220px; }
.tbl .ket { min-width: 170px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 16px; width: 1%; }
.asal { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 8px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--green-soft); color: var(--green-dark); }
.badge-part { background: var(--amber-soft); color: var(--amber-dark); border: 1px solid var(--amber-line); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions button { width: 38px; height: 38px; border-radius: 8px; border: 0; background: none; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; }
.row-actions button:hover { background: #EEF0EC; }
.row-actions .del:hover { color: var(--red); background: #FDECEA; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); margin: 0; }

/* Mobile list (disembunyikan di desktop) */
.mlist { display: none; list-style: none; margin: 0; padding: 12px; flex-direction: column; gap: 10px; }
.mitem { border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.mtop { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.mleft { display: flex; gap: 12px; align-items: center; min-width: 0; }
.mleft .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }
.mtitle { font-weight: 600; overflow-wrap: anywhere; }
.msub { font-size: 13px; color: var(--muted); }
.mamount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mfoot { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.mguna { font-size: 13px; color: var(--muted); background: var(--amber-soft); border-radius: 10px; padding: 8px 10px; }
.mactions { display: flex; gap: 8px; }
.mactions button { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; font-size: 14px; }
.mactions .del { color: var(--red); }

/* ---------- FAB ---------- */
.fab { display: none; position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 18px; border: 0; background: var(--green); color: #fff; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(31, 111, 74, .35); z-index: 15; }

/* ---------- Dialog ---------- */
.dlg { border: 0; padding: 0; border-radius: 20px; width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(22, 32, 27, .25); color: var(--ink); }
.dlg-sm { width: min(420px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(22, 32, 27, .45); }
.dlg form { display: flex; flex-direction: column; max-height: inherit; }
.dlg-head { padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dlg-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.dlg-body p { margin: 0; }
.dlg-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field input, .field textarea { min-height: 46px; padding: 0 14px; border: 1px solid #C8CEC6; border-radius: 10px; font-size: 15px; font-weight: 400; background: var(--surface); width: 100%; }
.field textarea { padding: 12px 14px; resize: vertical; }
.field input[aria-invalid="true"] { border-color: var(--red); }
.money { position: relative; display: flex; align-items: center; }
.money > span { position: absolute; left: 14px; color: var(--muted); font-weight: 400; }
.money input { padding-left: 42px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sisa-box { border-radius: 14px; background: var(--amber-soft); border: 1px solid var(--amber-line); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.sisa-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sisa-label { font-size: 14px; font-weight: 500; color: var(--amber-dark); }
.sisa-label .light { font-weight: 400; }
.sisa-value { font-family: var(--display); font-size: 24px; font-weight: 600; color: var(--amber); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sisa-hint { font-size: 13px; color: var(--amber-dark); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 100; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .main { padding-top: 20px; gap: 18px; padding-bottom: 100px; }
  .h1 { font-size: 26px; }
  .hide-sm { display: none; }
  .brand-name { font-size: 20px; }
  .head-row { flex-direction: column; align-items: stretch; }
  .period-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-row .dash { display: none; }
  .period-row .btn { grid-column: 1 / -1; }
  .date-pill { flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 12px; }
  .date-pill input { min-height: 28px; padding: 0; width: 100%; font-weight: 600; }
  .chips { justify-content: flex-start; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 16px; }
  .card-dark, .card:last-child { grid-column: 1 / -1; }
  .card-value { font-size: 22px; }
  .card-dark .card-value { font-size: 30px; }
  .panel-head { padding: 16px; }
  .tools { width: 100%; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .tools label:not(.search) { flex: 1; }
  .tools select { width: 100%; }
  .table-box { display: none; }
  .mlist { display: flex; }
  .fab { display: inline-flex; }
  .grid2 { grid-template-columns: 1fr; }
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
}
