:root {
  --bg: #f3f4f6;
  --card: #fff;
  --ink: #17261d;
  --muted: #5b6573;
  --line: #e3e6eb;
  --stroke: #d9dee6;
  --accent: #123c26;
  --accent-dark: #0c2b1a;
  --accent-soft: #e4efe8;
  --on-accent: #fff;
  --gold: #8a6a2a;
  --ok: #0e6b0e;
  --ok-bg: #dff6dd;
  --due: #8a5300;
  --due-bg: #fff4ce;
  --late: #9b1c1c;
  --late-bg: #fde8e8;
  --bal: #7a3e00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(21,35,59,.06);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0 14px;
  background: var(--accent-dark); color: #fff;
}
.topbar b { font-size: 1rem; letter-spacing: .01em; }
.topbar .sub { font-size: .72rem; opacity: .8; font-weight: 500; }
.topbar .grow { flex: 1; }
.topbar a, .topbar button.link { color: #fff; background: none; border: 0; padding: 8px 8px; cursor: pointer; white-space: nowrap; font-size: .92rem; }
main { padding: 16px 14px 48px; max-width: 720px; margin: 0 auto; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.02rem; margin: 18px 0 8px; }
.card { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.unit {
  display: block; color: inherit;
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 8px; box-shadow: var(--shadow);
}
.unit:hover { background: #f8f9fb; }
.unit .who { font-weight: 650; font-size: 1.05rem; }
.unit .meta { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.badge.paid { color: var(--ok); background: var(--ok-bg); }
.badge.due { color: var(--due); background: var(--due-bg); }
.badge.late { color: var(--late); background: var(--late-bg); }
.badge.balance_owed { color: var(--bal); background: #fdeccc; }
.badge.vacant { color: var(--muted); background: #eee; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--stroke); background: #fff; color: var(--ink);
  cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.danger { color: var(--late); border-color: #f1c0c0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btnbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btnbar .btn { flex: 1; min-width: 140px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: .93rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
label { display: block; margin: 0 0 10px; font-size: .86rem; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; min-height: 40px;
  border: 1px solid var(--stroke); border-radius: 8px; background: #fff; color: var(--ink);
}
.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 4px; }
.list td { border-bottom: 1px solid var(--line); padding: 8px 4px; vertical-align: top; }
.list .num { text-align: right; white-space: nowrap; }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(15,23,40,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal > .card { width: 100%; max-width: 440px; margin: 0; border-radius: 14px 14px 0 0; max-height: 92vh; overflow: auto; }
.login { max-width: 360px; margin: 48px auto; }
.login h1 { color: var(--accent); }
.addr { color: var(--muted); font-size: .92rem; margin: 0 0 14px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--accent-dark); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; font-size: .9rem; }
.payhead { background: var(--accent-dark); color: #fff; padding: 22px 16px 18px; }
.payhead b { display: block; font-size: 1.1rem; }
.paidstamp { display: inline-block; border: 3px solid var(--ok); color: var(--ok); font-weight: 800; padding: 2px 12px; transform: rotate(-6deg); margin: 8px 0; }
@media (min-width: 800px) {
  main { padding: 22px 20px 60px; }
  .modal { align-items: center; }
  .modal > .card { border-radius: var(--radius); }
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1611; --card: #16231b; --ink: #eef4f0; --muted: #9db0a4; --line: #29402f; --stroke: #29402f; --accent: #7fc29b; --on-accent: #0c2b1a; --ok-bg: rgba(14,107,14,.22); --due-bg: rgba(138,83,0,.22); --late-bg: rgba(155,28,28,.22); }
  input, select, textarea, .btn { background: #132019; color: var(--ink); border-color: #29402f; }
  .unit:hover { background: #1b2c21; }
}

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.chk { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 550; }
label.chk input { width: auto; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; resize: vertical; background: #fff; }
section.prop { margin: 14px 0 22px; }
section.prop h2 { font-size: 1.05rem; margin: 0; }
form.add-unit { margin-top: 8px; }
form.add-unit input { flex: 1; min-width: 0; max-width: 140px; }
.badge.vacant, .badge.new { background: #e8edf3; color: #334155; }
.badge.scheduled { background: #fde68a; color: #92400e; }
.badge.done { background: #d1fae5; color: #065f46; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
form.mnt select, form.mnt textarea { margin-top: 6px; }
form.mnt select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; background: #fff; }
.unit { display: block; }

[hidden] { display: none !important; }

body.login-screen { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, var(--accent-dark) 0 34vh, #eef2ef 34vh); }
body.login-screen .topbar.brand { justify-content: center; text-align: center; }
body.login-screen main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 28px 16px 48px; width: 100%; max-width: none; }
body.login-screen .login { width: 100%; max-width: 400px; margin: 0; padding: 22px 22px 20px; }
body.login-screen .login h1 { margin-bottom: 16px; }
body.login-screen .login .btnbar { margin-top: 6px; }
body.login-screen .login .btn.primary { width: 100%; }
form.user label { margin-top: 8px; }

.email-preview { margin-bottom: 10px; }
.email-preview .subj { font-weight: 650; margin: 4px 0 8px; }
.email-preview pre { white-space: pre-wrap; margin: 0; font: inherit; color: var(--ink); }

@media (max-width: 520px) {
  .topbar { gap: 2px; padding: 0 8px; overflow-x: auto; }
  .topbar b { white-space: nowrap; font-size: .92rem; }
  .topbar a, .topbar button.link { padding: 8px 5px; font-size: .82rem; }
}

/* v0.3.0 */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.summary .card { padding: 10px 12px; }
.summary b { font-size: 1.15rem; }
.late-txt { color: var(--late); }
.note { background: var(--due-bg); color: var(--due); border-radius: 8px; padding: 8px 10px; font-size: .88rem; margin: 8px 0; }
.small-btn { min-height: 34px; padding: 4px 12px; font-size: .88rem; }
.topbar .topnav { display: flex; align-items: center; }
.topbar button.link.on { text-decoration: underline; text-underline-offset: 6px; }
.tabbar { display: none; }
canvas.sig { display: block; width: 100%; height: 150px; border: 1px dashed var(--muted); border-radius: 8px; background: #fff; margin: 4px 0 6px; cursor: crosshair; }
.leasetext { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: .95rem; line-height: 1.45; }
ol.steps { list-style: none; padding: 0; margin: 4px 0 10px; }
ol.steps li { padding: 6px 0 6px 28px; position: relative; color: var(--muted); }
ol.steps li::before { content: ''; position: absolute; left: 4px; top: 9px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--stroke); }
ol.steps li.done { color: var(--ink); }
ol.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.badge.a-draft, .badge.a-void { background: #e8edf3; color: #334155; }
.badge.a-sent { color: var(--due); background: var(--due-bg); }
.badge.a-signed { background: #dbeafe; color: #1e40af; }
.badge.a-countersigned, .badge.a-uploaded { color: var(--ok); background: var(--ok-bg); }
.filebtn { position: relative; }
.banner { display: block; background: #dbeafe; color: #1e3a8a; border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; font-weight: 600; }
details summary { cursor: pointer; }
.sandbox { background: #fef3c7; color: #92400e; text-align: center; font-size: .8rem; font-weight: 700; padding: 4px; letter-spacing: .03em; }
@media (max-width: 640px) {
  .topbar .topnav { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--stroke); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--muted); font-size: .78rem; font-weight: 600; }
  .tabbar a .ic { font-size: 1.25rem; line-height: 1.2; }
  .tabbar a.on { color: var(--accent); }
  main { padding-bottom: 96px; }
  .modal { bottom: 0; }
}
@media (prefers-color-scheme: dark) { .tabbar a.on { color: #9cc3ff; } }

/* v0.3.0 branding: K&N forest-green monogram */
.brandmark { display: flex; align-items: center; gap: 10px; color: #fff !important; text-decoration: none; padding: 0 !important; }
.brandmark img { width: 36px; height: 36px; border-radius: 9px; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.brandmark b { display: block; font-family: Georgia, "Times New Roman", serif; font-weight: 600; font-size: 1.08rem; letter-spacing: .005em; }
.brandmark .sub { display: block; text-transform: uppercase; letter-spacing: .14em; font-size: .62rem; opacity: .85; }
.login-logo { display: block; width: 100%; max-width: 300px; margin: 2px auto 18px; }
body.login-screen .login { box-shadow: 0 10px 30px rgba(0,0,0,.18); border: 0; }
body.login-screen .login h1 { text-align: center; font-size: 1.1rem; color: var(--ink); }
.payhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.payhead-logo { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.payhead b { font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; }
@media (max-width: 640px) { .brandmark .sub { display: none; } .brandmark img { width: 32px; height: 32px; } }
@media (prefers-color-scheme: dark) { body.login-screen { background: linear-gradient(180deg, #0c2b1a 0 34vh, #0d1611 34vh); } .login-logo { background: #fff; border-radius: 10px; padding: 8px; } }

.login .center { text-align: center; }
.code-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.btnbar.spread { justify-content: space-between; }
.login button.link { background: none; border: 0; color: var(--accent); padding: 6px 0; cursor: pointer; font-size: .9rem; }

.unitpick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 4px; }
.unitpick .btn { padding: 16px 10px; font-size: 1.05rem; font-weight: 600; }

.badge.auto-deposit { background: var(--accent-soft, #e4efe8); color: var(--accent, #123c26); font-weight: 600; margin-left: 6px; vertical-align: middle; }
.confirm-deposit { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--accent, #123c26); background: var(--accent-soft, #e4efe8); margin: 0 0 12px; }
.confirm-deposit .btnbar { margin: 0; }
