:root {
  --bg: #f3f4f0;
  --card: #ffffff;
  --ink: #10211b;
  --ink-2: #33473f;
  --muted: #6c7d75;
  --line: #e3e8e2;
  --line-strong: #cfd8d0;
  --green: #1b3a7a;
  --green-dark: #132a63;
  --green-soft: #e9eefb;
  --gold: #b98a1f;
  --gold-soft: #fbf3e0;
  --amber: #a9761a;
  --amber-soft: #fdf3e3;
  --red: #b3261e;
  --red-soft: #fbeae9;
  --blue-soft: #eaf0fb;
  --blue: #2b5aa7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 33, 27, .05), 0 8px 24px -12px rgba(16, 33, 27, .18);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }

.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: #0b1a3d;
  color: #c9d5ef;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%; flex: none; overflow: hidden;
  background: #132a63; display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 6px 14px -8px #000;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 14.5px; line-height: 1.25; }
.brand-text span { font-size: 11.5px; color: #8fa3cc; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13.8px; font-weight: 500; color: #a7b8db;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #eaf0ff; }
.nav-item.active { background: var(--green); color: #fff; box-shadow: 0 4px 12px -6px #000; }

.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: #8497c2; padding: 10px 8px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d9a441; }
.status-dot.on { background: #43c08a; box-shadow: 0 0 0 3px rgba(67,192,138,.15); }
.status-dot.off { background: #e0645a; }

/* ---------- Main ---------- */
.main { min-width: 0; padding: 26px 30px 48px; }

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.topbar h1 { font-size: 23px; font-weight: 700; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  transition: transform .08s, box-shadow .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { background: #fbfcfa; box-shadow: 0 4px 12px -8px rgba(0,0,0,.4); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(16,33,27,.05); }
.btn-danger { color: var(--red); border-color: #eccac7; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-link { border: none; background: none; color: var(--green); font-weight: 600; padding: 0; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 15.5px; font-weight: 700; }
.card-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.stat-value { font-size: 25px; font-weight: 750; margin-top: 8px; letter-spacing: -.02em; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.stat.accent { background: linear-gradient(155deg, #1e4188, #12295c); border-color: transparent; color: #fff; }
.stat.accent .stat-label, .stat.accent .stat-sub { color: #b9c9ea; }
.stat.warn .stat-value { color: var(--amber); }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-blok { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- Blok cards ---------- */
.blok-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  background: #fff; cursor: pointer; transition: .15s; text-align: left;
}
.blok-card:hover { border-color: #b9d3c5; box-shadow: 0 8px 20px -16px rgba(0,0,0,.5); transform: translateY(-1px); }
.blok-card .bc-top { display: flex; justify-content: space-between; align-items: baseline; }
.blok-card .bc-name { font-weight: 700; font-size: 14px; }
.blok-card .bc-pct { font-size: 12px; font-weight: 700; color: var(--green); }
.blok-card .bc-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.bar { height: 6px; border-radius: 99px; background: #edf1ec; margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #3a63b8, #132a63); border-radius: 99px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; padding: 0 10px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 11px 10px; border-bottom: 1px solid #eef2ee; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #fafbf8; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .name { font-weight: 600; }
.tbl .sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 650;
  border: 1px solid transparent; white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chip-on { background: var(--green-soft); color: var(--green-dark); border-color: #cfe6d9; }
.chip-off { background: #f2f3f0; color: #8b968f; border-color: #e7e9e4; }
.chip-warn { background: var(--amber-soft); color: var(--amber); border-color: #f2dfc0; }
.chip-blue { background: var(--blue-soft); color: var(--blue); border-color: #d5e1f5; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: #f1f3ef; color: var(--ink-2); white-space: nowrap; }

/* ---------- recent list ---------- */
.recent { display: flex; flex-direction: column; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef2ee; }
.recent-item:last-child { border-bottom: none; }
.ri-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 750;
}
.ri-body { flex: 1; min-width: 0; }
.ri-body strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-body span { font-size: 11.5px; color: var(--muted); }
.ri-amt { text-align: right; flex: none; }
.ri-amt strong { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ri-amt span { font-size: 11px; color: var(--muted); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: #e9ede7; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 6px 12px; border-radius: 8px;
  font-size: 12.8px; font-weight: 650; color: var(--muted);
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tabs-blok { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tabs-blok button {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 9px;
  padding: 7px 15px; font-weight: 700; font-size: 13px; color: var(--ink-2); flex: none;
}
.tabs-blok button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

select.input, input.input, textarea.input {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px;
  background: #fff; font-size: 13.5px; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select.input:focus, input.input:focus, textarea.input:focus {
  border-color: #7fbfa4; box-shadow: 0 0 0 3px rgba(23,121,90,.12);
}
.input-sm { padding: 6px 9px; font-size: 12.5px; border-radius: 8px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(9, 20, 16, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 50; backdrop-filter: blur(2px); animation: fade .15s;
}
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 70px -20px rgba(0,0,0,.5);
  animation: pop .18s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { max-width: 780px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn {
  border: none; background: transparent; width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: #f1f3ef; color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- Pay options ---------- */
.pay-opt {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; margin-bottom: 9px;
  cursor: pointer; transition: .15s; background: #fff;
}
.pay-opt:hover { border-color: #a9c9b8; }
.pay-opt.on { border-color: var(--green); background: #f4fbf7; box-shadow: 0 0 0 1px var(--green) inset; }
.pay-opt .po-check {
  width: 20px; height: 20px; border-radius: 6px; border: 1.6px solid #c3cdc6;
  display: grid; place-items: center; flex: none; background: #fff;
}
.pay-opt.on .po-check { background: var(--green); border-color: var(--green); }
.pay-opt.on .po-check::after {
  content: ""; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.pay-opt .po-body { flex: 1; min-width: 0; }
.pay-opt .po-title { font-weight: 650; font-size: 14px; }
.pay-opt .po-desc { font-size: 11.8px; color: var(--muted); margin-top: 2px; }
.pay-opt input.amt {
  width: 105px; text-align: right; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 9px; font-size: 13px; font-variant-numeric: tabular-nums; background: #fff;
}
.pay-total {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--green-soft); border-radius: 12px; padding: 13px 16px; margin-top: 14px;
}
.pay-total span { font-size: 12.5px; font-weight: 650; color: var(--green-dark); text-transform: uppercase; letter-spacing: .03em; }
.pay-total strong { font-size: 21px; color: var(--green-dark); font-variant-numeric: tabular-nums; }

/* ---------- Receipt preview ---------- */
.receipt-stage {
  background: #e9ece6; border-radius: 14px; padding: 16px;
  display: grid; place-items: center; overflow: auto;
}
.receipt-stage canvas { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 10px 30px -12px rgba(0,0,0,.45); background: #fff; }
.receipt-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.receipt-actions .btn { flex: 1; min-width: 120px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .em-icon {
  width: 56px; height: 56px; border-radius: 16px; background: var(--green-soft);
  display: grid; place-items: center; margin: 0 auto 14px; color: var(--green);
}
.empty .em-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.empty h3 { color: var(--ink); font-size: 15.5px; margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 420px; margin: 0 auto 14px; line-height: 1.55; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: #10211b; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: .22s; z-index: 99; max-width: min(90vw, 460px); text-align: center;
  box-shadow: 0 18px 40px -18px #000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #8c1d16; }

/* ---------- month nav ---------- */
.month-nav { align-items: center; }
.month-nav button { font-size: 16px; line-height: 1; padding: 4px 10px; color: var(--ink-2); }
input.month-input {
  border: none; background: transparent; font-weight: 700; font-size: 13px;
  width: 132px; text-align: center; color: var(--ink); outline: none; padding: 4px 0;
  font-family: inherit;
}
input.month-input::-webkit-calendar-picker-indicator { opacity: .4; cursor: pointer; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.between { justify-content: space-between; }
.center { align-items: center; }
.hidden { display: none !important; }

.notice {
  display: flex; gap: 12px; padding: 13px 15px; border-radius: 12px;
  background: var(--amber-soft); border: 1px solid #f0ddbd; font-size: 12.8px;
  color: #7c4a08; line-height: 1.5; margin-bottom: 16px;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.checklist { display: grid; gap: 10px; }
.checklist-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.checklist-item .ci-num {
  width: 26px; height: 26px; border-radius: 50%; background: #f0f2ee; color: var(--ink-2);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none;
}
.checklist-item.done .ci-num { background: var(--green); color: #fff; }
.checklist-item.done .ci-num::after { content: "✓"; font-size: 13px; }
.checklist-item.done .ci-num span { display: none; }
.checklist-item .ci-body { flex: 1; min-width: 0; }
.checklist-item .ci-title { font-weight: 650; font-size: 13.5px; }
.checklist-item .ci-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

.ttd-box {
  border: 1.6px dashed var(--line-strong); border-radius: 12px; padding: 12px;
  display: flex; align-items: center; gap: 12px; background: #fcfdfb;
}
.ttd-box img { height: 54px; max-width: 150px; object-fit: contain; }
.ttd-box .ttd-ph { height: 54px; width: 120px; display: grid; place-items: center; color: #b3bdb6; font-size: 11.5px; background: #f4f6f2; border-radius: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-blok { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto;
    z-index: 40; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    flex-direction: row; gap: 0; align-items: center; border-top: 1px solid rgba(255,255,255,.1);
    overflow: visible;
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 0; }
  .nav-item { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 10px; flex: 1; border-radius: 10px; }
  .nav-item svg { width: 20px; height: 20px; }
  .main { padding: 18px 15px 96px; }
  .topbar { margin-bottom: 16px; }
  .topbar h1 { font-size: 20px; }
  .card { padding: 16px; border-radius: 14px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .grid-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 20px; }
  .grid-blok { grid-template-columns: 1fr 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .modal { max-height: 92vh; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }

  /* tabel jadi kartu di layar kecil */
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: block; padding: 12px 0; border-bottom: 1px solid #eef2ee; }
  .tbl.cards tr:last-child { border-bottom: none; }
  .tbl.cards td { display: inline-block; border: none; padding: 2px 6px 2px 0; vertical-align: middle; }
  .tbl.cards td.name { display: block; width: 100%; font-size: 14.5px; margin-bottom: 4px; }
  .tbl.cards td.name .sub { display: inline; margin-left: 6px; }
  .tbl.cards td.num { float: right; margin-top: 9px; font-size: 14.5px; }
  .tbl.cards td:last-child { display: block; clear: both; margin-top: 8px; padding-top: 4px; }
  .tbl.cards .actions { justify-content: flex-start; }
}

/* ---------- setup ---------- */
.setup-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.setup-card { width: 100%; max-width: 430px; text-align: center; padding: 28px 24px; }
.setup-logo { width: 84px; height: 84px; margin: 0 auto 14px; display: block; }
.setup-card h2 { font-size: 18px; margin-bottom: 8px; }
.setup-card p { line-height: 1.6; }
.setup-card code { background: #f0f2ee; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.setup-card .input { text-align: left; margin-top: 14px; font-size: 12.5px; }

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .toast, .receipt-actions, .modal-head .icon-btn, .modal-foot { display: none !important; }
  body { background: #fff; }
}
