/* ===== MeroSampati — design tokens ===== */
:root {
  --ink:        #14201d;   /* near-black green, text */
  --forest:     #1a3a34;   /* deep green, brand + topbar */
  --forest-2:   #245049;   /* lighter forest for accents */
  --paper:      #f6f4ee;   /* warm off-white background */
  --card:       #ffffff;
  --line:       #e4e0d6;   /* hairline */
  --muted:      #6b7671;   /* secondary text */
  --owe:        #b23b3b;   /* tenant owes (red) */
  --clear:      #2e7d5b;   /* paid up (green) */
  --gold:       #c99a3b;   /* small accent */
  --radius:     14px;
  --shadow:     0 1px 2px rgba(20,32,29,.06), 0 6px 20px rgba(20,32,29,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 16px; }

.view { display: none; }
.view.active { display: block; }

/* ===== Login ===== */
.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, #21463f 0%, var(--forest) 55%, #12292400 100%),
    var(--forest);
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 32px 26px;
  box-shadow: var(--shadow);
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 58px; height: 58px;
  background: var(--forest); color: #fff;
  border-radius: 16px;
  font-size: 24px; font-weight: 700;
  margin-bottom: 12px;
}
.brand h1 { font-size: 26px; letter-spacing: -.4px; }
.tagline { color: var(--muted); font-size: 14px; margin-top: 2px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(36,80,73,.12); }

.btn { border: none; border-radius: 10px; padding: 13px 16px; font-size: 15px; font-weight: 600; }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:active { background: var(--forest-2); }
.btn-ghost { background: transparent; color: var(--forest); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--owe); border: 1px solid #e6c9c9; }
.btn-block { width: 100%; }

.error-msg { color: var(--owe); font-size: 13px; text-align: center; }
.link-btn { background: none; border: none; color: var(--forest); font-size: 14px; font-weight: 600; }

/* ===== App shell ===== */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px calc(14px);
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--forest); color: #fff;
}
.topbar h2 { font-size: 18px; font-weight: 600; flex: 1; letter-spacing: -.2px; }
.topbar .link-btn { color: #cfe0db; }
.back-btn { background: none; border: none; color: #fff; font-size: 22px; line-height: 1; padding: 0 4px 0 0; }

.main { padding: 16px 16px 90px; max-width: 620px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; background: none; border: none; padding: 14px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.tab.active { color: var(--forest); }

/* ===== Cards & lists ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-align: left; width: 100%;
}
.row:active { border-color: var(--forest-2); }
.row-main { min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; }
.row-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-end { text-align: right; white-space: nowrap; font-size: 13px; color: var(--muted); }
.chev { color: var(--line); font-size: 18px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 10px;
}
.section-head:first-child { margin-top: 4px; }
.section-head h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.pill-occupied { background: #e7f1eb; color: var(--clear); }
.pill-vacant { background: #f0eee7; color: var(--muted); }

/* ===== Dashboard ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow); }
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.hero-balance {
  border-radius: 18px; padding: 20px; color: #fff; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--forest) 0%, var(--forest-2) 100%);
  box-shadow: var(--shadow);
}
.hero-balance .lbl { font-size: 13px; opacity: .85; }
.hero-balance .amt { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-top: 4px; }
.hero-balance .note { font-size: 12px; opacity: .8; margin-top: 6px; }

/* ===== Balance card (tenant view) ===== */
.balance-card { border-radius: 18px; padding: 20px; color: #fff; box-shadow: var(--shadow); }
.balance-card.owe { background: linear-gradient(135deg, #9e3232 0%, var(--owe) 100%); }
.balance-card.clear { background: linear-gradient(135deg, #256b4c 0%, var(--clear) 100%); }
.balance-card .amt { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.balance-card .lbl { font-size: 13px; opacity: .9; }
.balance-breakdown { display: flex; gap: 18px; margin-top: 14px; font-size: 13px; }
.balance-breakdown div span { display: block; opacity: .8; font-size: 11px; }

.detail-meta { color: var(--muted); font-size: 14px; }
.detail-meta b { color: var(--ink); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 36px 20px; }
.empty p { margin-bottom: 12px; font-size: 14px; }

.fab-row { display: flex; gap: 10px; margin-top: 14px; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(20,32,29,.5); display: grid; place-items: end center; z-index: 20; }
.modal-card {
  width: 100%; max-width: 620px; background: var(--card);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 30; box-shadow: var(--shadow);
}

.money { font-variant-numeric: tabular-nums; }
.spin { text-align: center; color: var(--muted); padding: 40px; }

@media (min-width: 560px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .modal-card { animation: none; }
}
/* ensure hidden really hides, even over other styles */
[hidden] { display: none !important; }