:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #1c2b26;
  --muted: #6b7a74;
  --green: #0f7a52;
  --green2: #0b5f3f;
  --red: #c0392b;
  --red2: #a93226;
  --line: #e3e8e5;
  --amber: #b7791f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-top: env(safe-area-inset-top);
}
#app { max-width: 480px; margin: 0 auto; padding: 12px 12px 60px; }

header { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; }
h1 { font-size: 20px; }
#sub-status { font-size: 12px; color: var(--muted); margin-top: 2px; }
header button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink);
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #e6f6ee;
  color: var(--green2);
  font-size: 13px;
  margin-bottom: 12px;
}
#status-bar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
#status-bar.off { background: #fdf1ec; color: var(--red2); }
#status-bar.off .dot { background: var(--red); }
#status-text { flex: none; }
#queue-info { flex: 1; text-align: right; font-weight: 600; color: var(--amber); }
#btn-sync {
  border: none;
  background: var(--green);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.card span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.card b { font-size: 13px; word-break: break-all; }

h2 { font-size: 15px; margin: 14px 0 8px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.preview-head h2 { margin: 0; }
#btn-lebarkan {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink);
}
#riwayat.full {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  margin: 0;
  overflow: auto;
  padding: 12px 14px 40px;
  border: none;
  border-radius: 0;
}
form, section#riwayat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.field { display: block; margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, select {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #a7d8c2; border-color: var(--green); }
#f-nominal { font-size: 22px; font-weight: 600; }

.jenis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.jenis-btn {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.jenis-btn.masuk.active { background: #e6f6ee; border-color: var(--green); color: var(--green2); }
.jenis-btn.keluar.active { background: #fdecea; border-color: var(--red); color: var(--red2); }

#btn-submit {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  margin-top: 4px;
}
#btn-submit:active { background: var(--green2); }
#btn-submit:disabled { opacity: 0.6; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#tabel-transaksi { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 700px; }
#tabel-transaksi th, #tabel-transaksi td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
#tabel-transaksi th { background: var(--green); color: #fff; font-weight: 600; }
#tabel-transaksi td.num { text-align: right; }
#tabel-transaksi tr.r-masuk td:nth-child(4) { color: var(--green2); font-weight: 600; }
#tabel-transaksi tr.r-keluar td:nth-child(4) { color: var(--red2); font-weight: 600; }
#tabel-transaksi tfoot td { background: #eef4f1; font-weight: 700; }
#tabel-transaksi .btn-hapus {
  border: 1px solid #f0c9c4;
  background: #fdecea;
  color: var(--red2);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
}
#riwayat-list b { display: block; font-size: 15px; }
#riwayat-list span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
#riwayat-list small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
#riwayat-list .r-masuk b { color: var(--green2); }
#riwayat-list .r-keluar b { color: var(--red2); }
.muted { color: var(--muted); font-size: 13px; }

footer { text-align: center; font-size: 11px; color: var(--muted); margin-top: 16px; }
footer .links { margin-bottom: 4px; }
footer .links a { color: var(--green2); text-decoration: none; font-weight: 600; }
footer .sep { margin: 0 8px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-box { background: #fff; width: min(92vw, 420px); border-radius: 14px; padding: 16px; }
.modal-box h3 { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal-actions button {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
}
.modal-actions .primary { background: var(--green); color: #fff; border: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1c2b26;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  max-width: 90vw;
  text-align: center;
}
