/* Money Book — mobile-first styles */
:root {
  --green: #1b7a43;
  --green-dark: #135c32;
  --green-light: #e7f4ec;
  --gold: #e8a90c;
  --gold-light: #fdf3d7;
  --red: #c0392b;
  --red-light: #fdecea;
  --ink: #1d2521;
  --muted: #6b7671;
  --line: #e3e8e5;
  --bg: #f6f8f7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(29, 37, 33, 0.08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: 0.2px;
}
.status { display: flex; align-items: center; gap: 0.6rem; }
.net-dot {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block;
  background: #9adbb6;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}
.net-dot.offline { background: var(--gold); }
.pending-badge {
  background: var(--gold);
  color: #4a3703;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.lock-btn {
  background: rgba(255,255,255,0.16);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- layout ---------- */
.container { max-width: 640px; margin: 0 auto; padding: 1rem; }
.inline-form { display: inline; }
.center { text-align: center; }

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.2rem 0 0.6rem;
  color: var(--ink);
}
.sub-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.35rem; }
.help-text { color: var(--muted); font-size: 0.88rem; margin: 0.25rem 0 0.75rem; }

/* ---------- alerts / notes ---------- */
.alert {
  padding: 0.75rem 1rem;
  margin: 0.6rem 0;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 500;
}
.alert-success { background: var(--green-light); color: var(--green-dark); }
.alert-danger { background: var(--red-light); color: var(--red); }
.alert-warning { background: var(--gold-light); color: #6b5309; }
.offline-note {
  background: var(--gold-light);
  color: #6b5309;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin: 0.6rem 0;
}
.records-note { border-left: 4px solid var(--gold); }
.empty-note {
  color: var(--muted);
  text-align: center;
  padding: 1.4rem 1rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- balance ---------- */
.balance-card {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  border-radius: 18px;
  padding: 1.4rem 1.2rem;
  margin-top: 0.4rem;
  box-shadow: 0 4px 14px rgba(19, 92, 50, 0.28);
}
.balance-label {
  font-size: 0.85rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.balance-amount {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0.25rem 0 0.4rem;
  word-break: break-all;
}
.balance-sub { font-size: 0.88rem; opacity: 0.95; display: flex; gap: 0.8rem; }
.balance-sub .pos { color: #c9f2da; }
.balance-sub .neg { color: #ffd9a1; }

.totals-row { display: flex; gap: 0.75rem; margin-top: 0.75rem; }
.total-card {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--line);
}
.total-card.in { border-left-color: var(--green); }
.total-card.out { border-left-color: var(--red); }
.total-label { font-size: 0.78rem; color: var(--muted); }
.total-value { font-size: 1.15rem; font-weight: 700; margin-top: 0.15rem; }
.total-card.in .total-value { color: var(--green-dark); }
.total-card.out .total-value { color: var(--red); }

/* ---------- add form ---------- */
.add-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.5rem;
}
.add-section .section-title { margin-top: 0; }

.type-toggle {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.type-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.type-toggle label {
  flex: 1;
  text-align: center;
  padding: 0.85rem 0.5rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  border: 2px solid var(--line);
  color: var(--muted);
  background: #fff;
  user-select: none;
}
.type-toggle input#type-in:checked + label {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
}
.type-toggle input#type-out:checked + label {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0.7rem 0 0.3rem;
}
.input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  font-size: 1rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27, 122, 67, 0.15);
}
.amount-input {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.5rem; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.selected {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 600;
}

.two-cols { display: flex; gap: 0.75rem; }
.two-cols > div { flex: 1; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 12px;
  padding: 0.9rem 1.2rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  color: #fff;
  background: var(--green);
}
.btn:active { transform: scale(0.985); }
.btn-save { width: 100%; margin-top: 1rem; }
.btn-ghost {
  background: #fff;
  color: var(--green-dark);
  border: 1.5px solid var(--green);
  width: 100%;
  margin-top: 0.6rem;
}
.btn-danger { background: var(--red); width: 100%; margin-top: 0.6rem; }
.btn-small {
  width: auto;
  padding: 0.55rem 0.95rem;
  font-size: 0.88rem;
  margin-top: 0;
}
.btn[disabled] { opacity: 0.6; }

.filter-row, .export-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.filter-row .input { flex: 1; }
.export-row { flex-wrap: wrap; }

/* ---------- transaction list ---------- */
.tx-list { display: flex; flex-direction: column; gap: 0.5rem; }
.tx-row {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
}
.tx-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800;
  flex-shrink: 0;
}
.tx-icon.in { background: var(--green-light); color: var(--green-dark); }
.tx-icon.out { background: var(--red-light); color: var(--red); }
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 600; font-size: 0.95rem; }
.tx-date {
  color: var(--muted); font-size: 0.78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tx-amounts { text-align: right; flex-shrink: 0; }
.tx-amount { font-weight: 700; font-size: 0.98rem; }
.tx-amount.pos { color: var(--green-dark); }
.tx-amount.neg { color: var(--red); }
.tx-balance { color: var(--muted); font-size: 0.72rem; }
.tx-actions { display: flex; flex-direction: column; gap: 0.35rem; margin-left: 0.2rem; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn.danger { color: var(--red); }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom));
  z-index: 20;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 1rem;
  border-radius: 10px;
  min-width: 72px;
}
.bottom-nav a.active { color: var(--green-dark); background: var(--green-light); }
.nav-icon { font-size: 1.25rem; line-height: 1.2; }

/* ---------- unlock screen ---------- */
.unlock-body {
  background: var(--green);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.unlock-card {
  background: #fff;
  border-radius: 20px;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.unlock-logo {
  width: 64px; height: 64px;
  margin: 0 auto 0.7rem;
  background: var(--green);
  color: #fff;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800;
}
.unlock-title { margin: 0 0 0.3rem; font-size: 1.3rem; }
.pin-input {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.6rem;
  margin-top: 0.5rem;
}

/* ---------- pending (offline) entries ---------- */
.tx-row.pending {
  border: 1.5px dashed var(--gold);
  background: #fffdf5;
}
.tx-row.pending .tx-balance { color: #a07908; }
.pending-chip {
  background: var(--gold-light);
  color: #6b5309;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.balance-pending {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  color: #ffe9b3;
}

/* ---------- guide ---------- */
.guide-step { margin-bottom: 0.6rem; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 800;
  margin-right: 0.4rem;
}
.text-in { color: var(--green-dark); }
.text-out { color: var(--red); }

/* ---------- auth + admin ---------- */
.text-link { color: var(--green-dark); font-weight: 700; }
.field-label.left { text-align: left; }
.help-text.spaced { margin-top: 1rem; }
.badge-admin {
  background: var(--gold-light);
  color: #6b5309;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
}
.reset-details {
  margin: -0.3rem 0 0.5rem;
  padding: 0 0.4rem;
}
.reset-details summary {
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0;
}
.reset-form { display: flex; gap: 0.5rem; padding: 0.4rem 0 0.6rem; }
.reset-form .input { flex: 1; }
.remove-user-form { padding-bottom: 0.6rem; }
.btn-danger-outline {
  background: #fff;
  color: var(--red);
  border: 1.5px solid var(--red);
}

/* ---------- larger screens ---------- */
@media (min-width: 700px) {
  .balance-amount { font-size: 2.6rem; }
}
