:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e2e5e9;
  --line-strong: #cfd4da;
  --text: #16191d;
  --text-2: #4a525c;
  --muted: #7a828c;
  --navy: #13294b;
  --navy-2: #1d3a66;
  --navy-soft: #e8edf5;
  --green: #1d6b46;
  --green-soft: #e7f2ec;
  --amber: #8a5a00;
  --amber-soft: #fbf3e2;
  --red: #a4262c;
  --red-soft: #fbecec;
  --radius: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 32px 28px 24px; }
.brand-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.brand-mark .logo { width: 34px; height: 34px; border-radius: 6px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: .5px; }
.brand-mark .t1 { font-weight: 600; font-size: 15px; }
.brand-mark .t2 { font-size: 12px; color: var(--muted); }
.login-card h1 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.powered { text-align: center; font-size: 11px; color: var(--muted); margin-top: 20px; letter-spacing: .2px; }

/* ===== Layout ===== */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #c9d3e3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; }
.side .brand .logo { width: 30px; height: 30px; border-radius: 5px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.side .brand .t1 { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2; }
.side .brand .t2 { font-size: 11px; color: #8fa0bb; }
.side nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.side .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: #7487a5; padding: 14px 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px; color: #c9d3e3; text-decoration: none; font-size: 13.5px; cursor: pointer; }
.side a.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.nav.on { background: rgba(255,255,255,.12); color: #fff; font-weight: 500; }
.side a.nav svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.side a.nav .badge { margin-left: auto; background: #c08a1e; color: #fff; font-size: 11px; padding: 0 6px; border-radius: 9px; line-height: 18px; }
.side .foot { padding: 12px 18px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #7487a5; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.topbar .desa-pick { display: flex; align-items: center; gap: 8px; }
.topbar .desa-pick label { font-size: 12px; color: var(--muted); }
.topbar .desa-pick select { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 30px 6px 10px; background: var(--surface); font-weight: 500; min-width: 220px; }
.topbar .spacer { flex: 1; }
.topbar .who { text-align: right; line-height: 1.2; }
.topbar .who .n { font-weight: 500; font-size: 13px; }
.topbar .who .r { font-size: 11.5px; color: var(--muted); }
.content { padding: 24px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); text-decoration: none; cursor: pointer; }
.crumb a:hover { color: var(--navy-2); text-decoration: underline; }

/* ===== Buttons & inputs ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: var(--radius); cursor: pointer; font-weight: 500; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: #b9c0c8; }
.btn:focus-visible, .inp:focus-visible { outline: 2px solid #7aa2d6; outline-offset: 1px; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #e5b9bb; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--navy-soft); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.inp, select.inp, textarea.inp { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 7px 10px; background: var(--surface); min-height: 34px; }
.inp:focus { border-color: #7aa2d6; outline: none; box-shadow: 0 0 0 3px rgba(29,58,102,.10); }
.inp.num { text-align: right; }
.inp[readonly] { background: var(--surface-2); color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field small { color: var(--muted); font-size: 11.5px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ===== Panels, KPI, tables ===== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-h .note { color: var(--muted); font-size: 12.5px; }
.panel-h .r { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-b { padding: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; overflow: hidden; }
.kpi { padding: 14px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.kpi .s { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.kpi.alert .v { color: var(--amber); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #eef0f2; vertical-align: top; }
.tbl tbody tr:hover td { background: #fafbfc; }
.tbl tr.click { cursor: pointer; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td.c, .tbl th.c { text-align: center; }
.tbl tr.sub td { color: var(--text-2); }
.tbl tr.batal td { color: var(--muted); text-decoration: line-through; }
.tbl tr.grp td { background: var(--surface-2); font-weight: 600; }
.tbl.compact td { padding: 6px 10px; }
.tbl .inp { min-height: 30px; padding: 5px 8px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.tag { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 4px; border: 1px solid transparent; white-space: nowrap; }
.tag.navy { background: var(--navy-soft); color: var(--navy-2); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.gray { background: #eef0f2; color: var(--text-2); }
.neg { color: var(--red); }
.pos { color: var(--green); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--navy); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--navy); color: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .inp { width: auto; min-width: 160px; }
.banner { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border: 1px solid #ecd9ad; background: var(--amber-soft); color: #5c3d00; border-radius: 8px; margin-bottom: 18px; font-size: 13px; }
.banner .r { margin-left: auto; }
.info-line { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.info-line dt { color: var(--muted); }
.info-line dd { margin: 0; }

/* ===== Modal ===== */
.modal-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 8px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.modal.wide { max-width: 980px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; background: var(--surface-2); border-radius: 0 0 8px 8px; flex-wrap: wrap; }
.modal-f .l { margin-right: auto; font-size: 13px; color: var(--text-2); }
.sumline { display: flex; justify-content: flex-end; gap: 28px; padding: 12px 4px 0; font-size: 13px; flex-wrap: wrap; }
.sumline b { font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--muted); }

/* Isian barang dengan saran */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 50; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.10); max-height: 240px; overflow-y: auto; margin-top: 2px; }
.ac-list div { padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.ac-list div span { color: var(--muted); font-size: 12px; }
.ac-list div.on, .ac-list div:hover { background: var(--navy-soft); }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1b2330; color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.powered-in { font-size: 11px; color: var(--muted); padding: 18px 24px 24px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ===== Layar kecil (HP) ===== */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .side-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .desa-pick label, .topbar .who .r { display: none; }
  .topbar .desa-pick select { min-width: 0; max-width: 52vw; }
  .content { padding: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .info-line { grid-template-columns: 1fr; gap: 2px; }
  .info-line dd { margin-bottom: 8px; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .kpi .v { font-size: 18px; }
  .tbl td, .tbl th { white-space: nowrap; }
  .topbar .who { display: none; }
  .banner { flex-wrap: wrap; }
}
@media (min-width: 901px) { .side-back { display: none; } }
