:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #dde3ea;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --accent: #e8f0f8;
  --danger: #b42318;
  --warn-bg: #fff6e5;
  --warn: #8a5a00;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --card: #18202a;
    --text: #e6ebf1;
    --muted: #98a2b3;
    --line: #2a3542;
    --brand: #4f8cc9;
    --brand-ink: #08111b;
    --accent: #1d2a38;
    --danger: #f97066;
    --warn-bg: #3a2c10;
    --warn: #fdd68a;
    color-scheme: dark;
  }
  #sig-pad, #sig-preview { background: #fff; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { font-weight: 700; letter-spacing: .2px; }
.period { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0; color: inherit; }
.period input { width: auto; padding: 6px 8px; border: 0; border-radius: 8px; }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
.tab { display: none; }
.tab.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.card > h3:first-child { margin-top: 0; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label small { color: var(--muted); }
input, select {
  display: block; width: 100%;
  margin-top: 4px; padding: 10px 12px;
  font: inherit; color: var(--text);
  background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input.big { font-size: 20px; font-weight: 600; }
input.upper { text-transform: uppercase; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
label.check input { width: auto; margin: 0; }

.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 10px; }
.more { margin: 6px 0 10px; }
.more summary { cursor: pointer; color: var(--brand); font-size: 13.5px; margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--accent); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.actions.wrap { flex-wrap: wrap; justify-content: flex-start; }
button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 10px; padding: 10px 16px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0; color: var(--text);
}
.primary { background: var(--brand); color: var(--brand-ink); }
.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row-between h2 { margin: 0; }
.row-between select { width: auto; margin: 0; }

/* daftar transaksi */
.day { margin-top: 14px; }
.day-head {
  display: flex; justify-content: space-between;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.item:last-child { border-bottom: 0; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .s { font-size: 12.5px; color: var(--muted); grid-column: 1; overflow-wrap: anywhere; }
.item .a { font-weight: 700; text-align: right; white-space: nowrap; }
.item .ops { grid-column: 2; display: flex; gap: 4px; justify-content: flex-end; }
.item .ops button { padding: 3px 8px; font-size: 12.5px; font-weight: 500; border: 1px solid var(--line); background: transparent; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--brand);
  margin-right: 4px;
}
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }

/* summary */
.table-wrap { overflow-x: auto; }
table.summary { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.summary th, table.summary td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.summary th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.summary .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.summary tbody tr.zero td { color: var(--muted); }
table.summary tfoot td { font-weight: 600; }
table.summary tfoot tr.strong td { font-weight: 800; color: var(--brand); border-bottom: 0; }
.claimno { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.claimno strong { color: var(--text); }
.warnings { margin: 10px 0 0; padding: 0; list-style: none; }
.warnings li {
  background: var(--warn-bg); color: var(--warn);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; margin-bottom: 6px;
}

/* tanda tangan */
.sig-wrap { user-select: none; -webkit-user-select: none; position: relative; border: 1px dashed var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
#sig-pad { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; touch-action: none; cursor: crosshair; }
#sig-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex-direction: column; gap: 0; border-radius: 0;
  padding: 8px 4px 9px; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.tabbar .ico { font-size: 18px; line-height: 1.1; }
.tabbar button.active { color: var(--brand); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; max-width: calc(100% - 32px); z-index: 10;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
