:root {
  --primary: #0d6eb3;
  --primary-dark: #094f80;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7a8d;
  --border: #e2e8f0;
  --green: #1a9e5c;
  --red: #d64545;
  --orange: #e08a1f;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 72px;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.topbar .icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  padding: 4px 8px;
}

/* ---------- Main content ---------- */
.screen {
  padding: 14px;
  display: none;
}
.screen.active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-card .label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-card .value {
  font-size: 22px;
  font-weight: 700;
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-card.accent .value { color: var(--primary); }
.stat-card.warn .value { color: var(--orange); }

h2.section-title {
  font-size: 15px;
  color: var(--muted);
  margin: 18px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .name { font-weight: 600; }
.list-item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.list-item .right { text-align: right; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.badge.due { background: #fdecec; color: var(--red); }
.badge.pending { background: #fff3e0; color: var(--orange); }
.badge.paid { background: #e6f6ee; color: var(--green); }
.badge.plan { background: #e8f1fb; color: var(--primary); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  text-align: center;
}
.btn.block { display: block; width: 100%; }
.btn.secondary { background: #eef2f7; color: var(--text); }
.btn.green { background: var(--green); }
.btn.whatsapp { background: #25D366; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn:disabled { opacity: 0.5; }

.fab {
  position: fixed;
  right: 18px;
  bottom: 86px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 28px;
  box-shadow: 0 4px 10px rgba(13,110,179,0.4);
  z-index: 15;
}

.empty-msg {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 14px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: none;
  padding: 9px 0 7px;
  color: var(--muted);
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.bottom-nav button .ic { font-size: 20px; }
.bottom-nav button.active { color: var(--primary); }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.field textarea { resize: vertical; min-height: 60px; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.radio-row input { width: auto; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,30,45,0.45);
  display: none;
  align-items: flex-end;
  z-index: 50;
}
.modal-overlay.active { display: flex; }
.modal-box {
  position: relative;
  background: #fff;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.modal-box h3 {
  margin: 0 0 14px;
  font-size: 17px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.modal-actions .btn { flex: 1; }
.modal-close {
  position: absolute;
  top: 10px; right: 14px;
}

/* ---------- Login screen ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 22px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  text-align: center;
}
.login-card .drop {
  font-size: 40px;
  margin-bottom: 6px;
}
.login-card h1 {
  font-size: 19px;
  margin: 0 0 20px;
}
.login-card .field { text-align: left; }
.error-msg {
  color: var(--red);
  font-size: 13.5px;
  margin: 8px 0 0;
  min-height: 18px;
}

.hidden { display: none !important; }

.slip-preview {
  background: #fbfbfb;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
}
.slip-preview .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.slip-preview .total-row {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #1c2733;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  max-width: 85vw;
  text-align: center;
}
.toast.show { opacity: 1; }
