:root {
  --bg: #f6f1e9; --card: #fffdf9; --ink: #22201c; --muted: #7a7266; --line: #e8e0d3;
  --accent: #b4532a; --accent-soft: #f6e2d6; --ok: #2f7d4f; --ok-soft: #dff0e4; --warn: #b7791f; --warn-soft: #fbefd5;
  --bad: #b3261e; --bad-soft: #fbe1de; --me: #b4532a; --sasha: #2d6a8f; --both: #6b5b95;
  --r: 16px; --shadow: 0 1px 2px rgba(60,40,20,.06), 0 4px 16px rgba(60,40,20,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.serif { font-family: Georgia, "Times New Roman", serif; }

/* layout */
.top { position: sticky; top: 0; z-index: 5; background: rgba(246,241,233,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px 10px; border-bottom: 1px solid transparent; }
.top h1 { font-family: Georgia, serif; font-size: 24px; flex: 1; }
.top .who { width: 36px; height: 36px; border-radius: 50%; border: 0; color: #fff; font-weight: 700; display: grid; place-items: center; }
main { max-width: 760px; margin: 0 auto; padding: 8px 14px calc(100px + var(--safe-b)); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + var(--safe-b)); }
.nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 11.5px; font-weight: 600; border-radius: 12px; }
.nav button .i { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
.nav button.on { color: var(--accent); }
.nav button.on .i { filter: none; opacity: 1; }
@media (min-width: 900px) { .nav { left: 50%; transform: translateX(-50%); width: 520px; bottom: 14px; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding-bottom: 6px; } }

/* sections */
.sec { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.sec h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; flex: 1; }
.sec .n { color: var(--muted); font-size: 13px; }
.hello { margin: 6px 2px 4px; }
.hello .d { color: var(--muted); font-size: 14px; }
.hello h2 { font-family: Georgia, serif; font-size: 26px; font-weight: 600; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line); min-height: 58px; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; cursor: pointer; }
.row .t { font-weight: 600; overflow-wrap: anywhere; }
.row .s { color: var(--muted); font-size: 13.5px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.row.done .t { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.row .amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14.5px; }

.chk { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #cbbfae; background: #fff; display: grid; place-items: center; padding: 0; transition: .15s; }
.chk svg { width: 16px; height: 16px; opacity: 0; }
.chk.on { background: var(--ok); border-color: var(--ok); }
.chk.on svg { opacity: 1; }
.chk:active { transform: scale(.9); }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #efe8dc; color: #5b5246; white-space: nowrap; }
.tag.me { background: #f6e2d6; color: var(--me); } .tag.sasha { background: #dcebf4; color: var(--sasha); } .tag.both { background: #e8e3f2; color: var(--both); }
.tag.ok { background: var(--ok-soft); color: var(--ok); } .tag.warn { background: var(--warn-soft); color: var(--warn); } .tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.cash { background: #e6f1dc; color: #3f6b1f; } .tag.bank { background: #dfe9f7; color: #2b4f86; }
.day { flex: none; width: 46px; text-align: center; border-radius: 12px; background: #f1ebe1; padding: 5px 0 4px; line-height: 1.05; }
.day b { display: block; font-size: 19px; }
.day span { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.day.late { background: var(--bad-soft); } .day.late b, .day.late span { color: var(--bad); }
.day.today { background: var(--accent); } .day.today b, .day.today span { color: #fff; }

/* summary tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tile { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 14px; }
.tile .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 600; }
.bar { height: 6px; border-radius: 6px; background: #eee5d8; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 6px; }

.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 2px; }
.monthnav h2 { font-family: Georgia, serif; font-size: 24px; font-weight: 600; text-transform: capitalize; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 18px; display: grid; place-items: center; }

.seg { display: flex; background: #ebe3d6; border-radius: 12px; padding: 3px; gap: 2px; margin: 8px 0; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 14px; color: #5b5246; white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.fab { position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 7; width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: #fff;
  font-size: 30px; font-weight: 300; box-shadow: 0 6px 18px rgba(180,83,42,.35); display: grid; place-items: center; }
@media (min-width: 900px) { .fab { right: calc(50% - 370px); } }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--accent); color: #fff; }
.btn.ghost { background: #efe8dc; color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.linkbtn { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 4px 0; font-size: 14px; }

/* apartments */
.apts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.apt { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; cursor: pointer; border: 0; text-align: left; display: block; width: 100%; }
.apt .h { display: flex; align-items: center; gap: 8px; }
.apt .num { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; }
.apt .nm { font-weight: 700; flex: 1; }
.apt .ten { margin-top: 10px; font-weight: 600; }
.apt .meta { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.apt.free .num { background: #eee; color: #888; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; padding: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 14px; }
.file { width: 86px; text-align: center; font-size: 11.5px; color: var(--muted); position: relative; }
.file a { display: block; width: 86px; height: 86px; border-radius: 12px; background: #efe8dc center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; font-size: 28px; text-decoration: none; }
.file .cap { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow); font-size: 12px; color: var(--bad); }
.upl { width: 86px; height: 86px; border-radius: 12px; border: 2px dashed #cbbfae; display: grid; place-items: center; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; text-align: center; padding: 6px; }
.upl input { display: none; }

/* lists */
.book { padding: 14px; border-top: 1px solid var(--line); }
.book:first-child { border-top: 0; }
.book .h { display: flex; gap: 10px; align-items: flex-start; }
.book .t { font-weight: 700; font-size: 16.5px; }
.book .a { color: var(--muted); font-size: 14px; }
.book .desc { margin-top: 8px; font-size: 14.5px; color: #4a443c; white-space: pre-wrap; }
.book .desc.clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.book .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; color: #5b5246; }
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.note { padding: 14px; border-top: 1px solid var(--line); cursor: pointer; }
.note:first-child { border-top: 0; }
.note .t { font-weight: 700; }
.note .b { white-space: pre-wrap; color: #4a443c; font-size: 14.5px; margin-top: 4px; }

/* banner */
.banner { background: #fff4e5; border: 1px solid #f1d9b5; border-radius: var(--r); padding: 12px 14px; margin-top: 12px; display: flex; gap: 12px; align-items: center; font-size: 14.5px; }
.banner .x { flex: 1; }

/* sheet (forms) */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(30,20,10,.38); animation: fade .18s; }
.sheet-card { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(22px + var(--safe-b)); animation: up .22s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 700px) { .sheet-card { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 560px; border-radius: 22px; animation: fade .18s; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet h3 { font-family: Georgia, serif; font-size: 22px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sheet h3 span { flex: 1; }
.f { display: block; margin-bottom: 12px; }
.f > span { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.f input, .f select, .f textarea { width: 100%; border: 1px solid #ddd2c2; border-radius: 12px; background: #fff; padding: 11px 12px; font-size: 16px; }
.f textarea { min-height: 88px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.acts { display: flex; gap: 10px; margin-top: 6px; }
.acts .btn { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid #ddd2c2; background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 14.5px; max-width: 90vw; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 360px; }
.login .logo { font-size: 46px; text-align: center; }
.login h1 { font-family: Georgia, serif; text-align: center; font-size: 32px; font-weight: 600; margin: 4px 0 22px; }
.err { color: var(--bad); font-size: 14px; margin: -4px 0 10px; min-height: 18px; }
