:root {
  --bg: #f1f8f4;
  --card: #ffffff;
  --ink: #0f2a1e;
  --muted: #5b7366;
  --line: #d9e9e0;
  --g: #16a36a;
  --g-d: #0c6a45;
  --g-dd: #084a31;
  --g-l: #e0f4ea;
  --red: #d6453a;
  --red-l: #fdeceb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(10, 60, 40, .06), 0 6px 18px rgba(10, 60, 40, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------- login ---------- */
.login {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 400px at 50% -120px, #b9ebd1 0, transparent 70%),
    var(--bg);
}
.login .box { max-width: 400px; width: 100%; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 26px; letter-spacing: -.5px; color: var(--g-dd); }
.logo .mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--g), var(--g-d)); color: #fff; font-size: 20px;
}
.logo b { color: var(--g); font-weight: 800; }
.login p.sub { color: var(--muted); margin: 8px 0 24px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, select.input {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 12px 14px; outline: none; min-height: 46px;
}
.input:focus { border-color: var(--g); box-shadow: 0 0 0 3px rgba(22, 163, 106, .18); }
.input.code { text-align: center; letter-spacing: 2px; font-weight: 700; font-size: 17px; text-transform: uppercase; }
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; min-height: 46px;
  background: linear-gradient(135deg, var(--g), var(--g-d)); color: #fff;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--g-l); color: var(--g-d); }
.btn.danger { background: var(--red-l); color: var(--red); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.err { color: var(--red); background: var(--red-l); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.foot-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- app shell ---------- */
.topbar { background: linear-gradient(135deg, var(--g-d), var(--g-dd)); color: #fff; padding: 14px 0 70px; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .logo { color: #fff; font-size: 20px; }
.topbar .logo .mark { width: 32px; height: 32px; font-size: 17px; background: rgba(255, 255, 255, .18); }
.topbar .logo b { color: #8df0c0; }
.who { font-size: 12px; opacity: .85; text-align: right; }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; font-size: 12px; }
main { margin-top: -56px; padding-bottom: 96px; }
#app:not([data-tab="home"]) .topbar { padding-bottom: 16px; }
#app:not([data-tab="home"]) main { margin-top: 0; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 10px; }
.title-row h2 { font-size: 17px; }

.hero {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 18px;
}
.hero .lbl { color: var(--muted); font-size: 13px; font-weight: 600; }
.hero .big { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 14px; }
.big.neg { color: var(--red); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { border-radius: 12px; padding: 10px 12px; }
.mini.in { background: var(--g-l); }
.mini.out { background: var(--red-l); }
.mini .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.mini .val { font-weight: 800; font-size: 16px; }
.mini.in .val { color: var(--g-d); }
.mini.out .val { color: var(--red); }

.list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.day-head {
  display: flex; justify-content: space-between; padding: 8px 16px; background: #f6fbf8;
  font-size: 12px; font-weight: 700; color: var(--muted); border-top: 1px solid var(--line);
}
.day-head:first-child { border-top: 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 16px; border: 0; border-top: 1px solid var(--line); background: #fff;
}
.row:first-child { border-top: 0; }
.row .dot { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; flex: none; }
.row .dot.in { background: var(--g-l); color: var(--g-d); }
.row .dot.out { background: var(--red-l); color: var(--red); }
.row .mid { flex: 1; min-width: 0; }
.row .cat { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .note { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 800; white-space: nowrap; }
.row .amt.in { color: var(--g-d); }
.row .amt.out { color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip.on { background: var(--g-d); border-color: var(--g-d); color: #fff; }
.chip.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--g-l); border-color: transparent; color: var(--g-dd); }
.chip.tag.out { background: var(--red-l); color: #8f2b23; }
.chip.tag button { border: 0; background: none; padding: 0; font-size: 16px; line-height: 1; opacity: .6; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input { width: auto; flex: 1 1 140px; }

/* ---------- laporan ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 1px; height: 100%; min-width: 0; }
.bars .b { flex: 1; max-width: 10px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .b.in { background: var(--g); }
.bars .b.out { background: #ef8279; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .lg-in { background: var(--g); }
.legend .lg-out { background: #ef8279; }
.brk { margin-bottom: 12px; }
.brk .top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; gap: 10px; }
.brk .top span:first-child { font-weight: 600; }
.track { height: 8px; background: #eef5f1; border-radius: 99px; overflow: hidden; }
.track > div { height: 100%; border-radius: 99px; }
.track .in { background: var(--g); }
.track .out { background: #ef8279; }
.stack > * + * { margin-top: 14px; }

/* ---------- nav & fab ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav .wrap { display: grid; grid-template-columns: repeat(4, 1fr); padding: 0; }
.nav button {
  border: 0; background: none; padding: 9px 4px 8px; display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.nav button.on { color: var(--g-d); }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 21;
  border: 0; border-radius: 999px; padding: 0 20px; height: 52px; font-weight: 800;
  background: linear-gradient(135deg, var(--g), var(--g-d)); color: #fff; box-shadow: 0 8px 20px rgba(12, 106, 69, .4);
}

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 30, 20, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow: auto;
}
.sheet h3 { font-size: 18px; margin-bottom: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #eef5f1; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 10px; font-weight: 700; color: var(--muted); }
.seg button.on.in { background: var(--g); color: #fff; }
.seg button.on.out { background: var(--red); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 10px; margin-top: 6px; }
.actions .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--g-dd); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: 90vw;
}
.toast.bad { background: var(--red); }

/* ---------- admin ---------- */
.codebox { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 17px; font-weight: 700; letter-spacing: 1px; word-break: break-all; }
.admin-card + .admin-card { margin-top: 12px; }
.admin-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.badge.on { background: var(--g-l); color: var(--g-d); }
.badge.off { background: var(--red-l); color: var(--red); }
.meta { color: var(--muted); font-size: 13px; margin: 6px 0; }
.dev { font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.newbox { background: var(--g-l); border-radius: 12px; padding: 12px; margin-top: 12px; }
.newbox .codebox { margin: 4px 0; }

@media (min-width: 700px) {
  .sheet { border-radius: 22px; margin-bottom: 8vh; }
  .overlay { align-items: center; }
  .hero .big { font-size: 34px; }
}
