:root {
  --bg: #f1f5f2; --card: #fff; --text: #17201a; --muted: #66726a; --line: #e2e9e4;
  --brand: #037a27; --brand2: #0fa044; --brand-ink: #fff; --ok: #12805c; --warn: #b7791f; --bad: #c53030;
  --ok-bg: #e3f6ee; --warn-bg: #fdf3dc; --bad-bg: #fde8e8; --info-bg: #eaf0ec;
  --shadow: 0 1px 2px rgba(16, 40, 24, .06), 0 6px 18px rgba(16, 40, 24, .06);
  --shadow-lg: 0 2px 4px rgba(16, 40, 24, .08), 0 12px 28px rgba(16, 40, 24, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1511; --card: #18211b; --text: #e9f1ec; --muted: #94a39a; --line: #263229;
    --brand: #4cc77a; --brand2: #2f9e59; --brand-ink: #08130c; --ok: #4cd6a0; --warn: #f0b84a; --bad: #ff8080;
    --ok-bg: #10302a; --warn-bg: #3a2f14; --bad-bg: #3d1c1c; --info-bg: #212c25;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }

/* ---------- top bar: menu button, logo, user, then the main navigation ---------- */
#bar { position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow); }
#top { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: var(--brand-ink); padding: calc(10px + env(safe-area-inset-top)) 12px 10px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
#top .brand { flex: 1; min-width: 0; font-size: 17px; letter-spacing: .01em; }
#top small { font-weight: 400; opacity: .9; text-align: right; line-height: 1.2; display: block; font-size: 12px; }
#top small i { font-style: normal; opacity: .8; text-transform: capitalize; }
.who-me { display: flex; align-items: center; gap: 8px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .18); color: inherit; padding: 0; display: grid; place-content: center; gap: 4px; font-size: 18px; transition: background .2s, transform .15s; }
.iconbtn:hover { background: rgba(255, 255, 255, .28); }
.iconbtn:active { transform: scale(.92); }
.iconbtn span { display: block; width: 20px; height: 2.5px; border-radius: 2px; background: currentColor; transition: transform .3s var(--ease), opacity .2s; }
body.menu-open #menubtn span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
body.menu-open #menubtn span:nth-child(2) { opacity: 0; }
body.menu-open #menubtn span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

#tabs { display: flex; justify-content: center; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs a { position: relative; flex: 1; max-width: 150px; min-width: 62px; text-align: center; padding: 8px 4px 9px; color: var(--muted); text-decoration: none; font-size: 12px; transition: color .2s, background .2s; }
#tabs a b { display: block; font-size: 18px; font-weight: 400; transition: transform .25s var(--ease); }
#tabs a:hover { background: var(--info-bg); }
#tabs a:active b { transform: scale(.88); }
#tabs a::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); transition: width .3s var(--ease), left .3s var(--ease); }
#tabs a.on { color: var(--brand); font-weight: 600; }
#tabs a.on::after { width: 60%; left: 20%; }
#tabs a.on b { transform: translateY(-1px) scale(1.12); }

/* ---------- side menu ---------- */
#scrim { position: fixed; inset: 0; background: rgba(8, 20, 12, .5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 40; }
body.menu-open #scrim { opacity: 1; pointer-events: auto; }
#drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); background: var(--card); z-index: 41; display: flex; flex-direction: column;
  transform: translateX(-102%); visibility: hidden; transition: transform .32s var(--ease), visibility 0s .32s; box-shadow: var(--shadow-lg); }
body.menu-open #drawer { transform: none; visibility: visible; transition: transform .32s var(--ease), visibility 0s; }
body.menu-open { overflow: hidden; }
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(14px + env(safe-area-inset-top)) 14px 14px; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: var(--brand-ink); }
.dhead .brand { align-items: center; }
.dhead b { font-size: 16px; }
.dbody { overflow-y: auto; padding: 6px 10px calc(20px + env(safe-area-inset-bottom)); flex: 1; }
.dsec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 8px 4px; }
.mi { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 11px 10px; font-size: 15px; transition: background .15s, transform .15s; }
.mi:hover { background: var(--info-bg); }
.mi:active { transform: scale(.98); background: var(--info-bg); }
.mi .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--info-bg); display: grid; place-items: center; font-size: 18px; flex: none; }
.mi .lbl { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.mi .lbl small { font-size: 12px; }
.mi .chev { color: var(--muted); font-size: 20px; }
body.menu-open .mi { animation: slideIn .4s var(--ease) both; animation-delay: calc(var(--i) * 28ms + 120ms); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

/* ---------- page ---------- */
#view { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(40px + env(safe-area-inset-bottom)); }
#view.enter > * { animation: rise .4s var(--ease) both; }
#view.enter > *:nth-child(2) { animation-delay: .04s; } #view.enter > *:nth-child(3) { animation-delay: .08s; }
#view.enter > *:nth-child(4) { animation-delay: .12s; } #view.enter > *:nth-child(5) { animation-delay: .16s; }
#view.enter > *:nth-child(6) { animation-delay: .2s; } #view.enter > *:nth-child(n+7) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.skel { height: 74px; border-radius: 16px; margin-bottom: 10px; background: linear-gradient(90deg, var(--info-bg) 25%, var(--card) 50%, var(--info-bg) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel.short { height: 44px; width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

h2 { font-size: 20px; margin: 4px 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 20px 0 8px; }
h3.row { text-transform: none; letter-spacing: 0; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); transition: transform .18s var(--ease), box-shadow .2s, border-color .2s; }
.card.click { cursor: pointer; }
.card.click:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.card.click:active { transform: scale(.985); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--info-bg); color: var(--text); white-space: nowrap; }

.person { display: flex; align-items: center; gap: 12px; }
.av { --h: 140; flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 55% 42%), hsl(calc(var(--h) + 30) 60% 52%)); }
#top .av { width: 36px; height: 36px; font-size: 13px; border: 2px solid rgba(255, 255, 255, .5); }
.card.st-paid { border-left: 4px solid var(--ok); } .card.st-pending { border-left: 4px solid var(--warn); }
.card.st-partial { border-left: 4px solid var(--warn); } .card.st-overdue { border-left: 4px solid var(--bad); }

/* search */
.search { position: relative; margin-bottom: 10px; }
.search .mag { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .7; pointer-events: none; }
.search input { padding: 12px 40px 12px 38px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-size: 16px; }
.search .x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%) scale(.6); width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 0; background: var(--info-bg); color: var(--muted); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); }
.search.has .x { opacity: 1; transform: translateY(-50%); pointer-events: auto; }
.search input::-webkit-search-cancel-button { display: none; }

/* dashboard */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px; border-radius: 20px; margin-bottom: 12px; color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand), var(--brand2)); box-shadow: var(--shadow-lg); }
.hero .hi { font-size: 21px; font-weight: 700; } .hero .sub { opacity: .9; font-size: 13.5px; }
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
.ring { --p: 0; width: 78px; height: 78px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, .25) 0); animation: fill 1s var(--ease) both; }
.ring b { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); font-size: 16px; }
@keyframes fill { from { --p: 0; } }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); transition: transform .18s var(--ease), box-shadow .2s; }
.stat .ico { --c: var(--brand); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-style: normal; font-size: 17px; margin-bottom: 8px;
  background: color-mix(in srgb, var(--c) 14%, transparent); }
.stat b { display: block; font-size: 24px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.click { cursor: pointer; }
.stat.click:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat.click:active { transform: scale(.97); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--info-bg); color: var(--brand); white-space: nowrap; }
.pill.paid, .pill.resolved, .pill.free { background: var(--ok-bg); color: var(--ok); }
.pill.partial, .pill.pending, .pill.in_progress { background: var(--warn-bg); color: var(--warn); }
.pill.overdue, .pill.open { background: var(--bad-bg); color: var(--bad); }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 11px; padding: 8px 14px; cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s, filter .2s; }
button:hover { box-shadow: var(--shadow); }
button:active { transform: scale(.95); }
button.primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: var(--brand-ink); border-color: transparent; font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--bad); }
button.small { padding: 5px 12px; font-size: 13px; border-radius: 99px; }
button:disabled { opacity: .5; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.filters { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters button { border-radius: 99px; padding: 6px 16px; text-transform: capitalize; white-space: nowrap; }
.filters button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); box-shadow: var(--shadow); }
.beds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bed { border: 1px solid transparent; border-radius: 99px; padding: 3px 10px; font-size: 12.5px; background: var(--ok-bg); color: var(--ok); }
.bed.full { background: var(--info-bg); color: var(--text); }

/* modal bottom sheet */
#modal { position: fixed; inset: 0; background: rgba(8, 20, 12, .5); backdrop-filter: blur(2px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s both; }
#modal[hidden] { display: none; }
#modal .sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); animation: sheetUp .32s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 640px) { #modal { align-items: center; } #modal .sheet { border-radius: 22px; } }
#modal .actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s var(--ease); z-index: 60; max-width: 90%; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.login { max-width: 360px; margin: 10vh auto 0; animation: rise .5s var(--ease) both; box-shadow: var(--shadow-lg); border-radius: 22px; padding: 18px; }
.login h1 { text-align: center; color: var(--brand); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
.secret { font: 600 22px ui-monospace, Menlo, monospace; letter-spacing: .08em; text-align: center; padding: 12px; background: var(--info-bg); border-radius: 12px; margin: 10px 0; user-select: all; }

.brand { display: flex; align-items: center; gap: 8px; }
.brand img { height: 32px; width: 32px; object-fit: contain; background: #fff; border-radius: 9px; padding: 3px; }
/* the logo has black wording on a transparent background, so it always sits on a white panel */
.login .logo { display: block; width: 100%; max-width: 280px; margin: 0 auto 8px; background: #fff; border-radius: 12px; padding: 10px; }
.occ { display: grid; grid-template-columns: 74px 1fr 52px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.occ > span:last-child { text-align: right; }
.bar { height: 10px; background: var(--info-bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); border-radius: 99px; transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
a { color: var(--brand); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
