/* =====================================================================
   Building Portal — one stylesheet, no framework, no build step.
   Mobile first: the caretaker's phone is the hardest case, so it is the
   default, and the desktop layout is the enhancement.
   ===================================================================== */

:root{
  --ink:#12211d;
  --ink-2:#41544e;
  --muted:#6d7f79;
  --paper:#f2f5f3;
  --surface:#ffffff;
  --surface-2:#e9eeeb;
  --line:#d3ddd8;
  --line-soft:#e3eae6;
  --brand:#12332a;
  --accent:#0d6b4f;
  --accent-ink:#ffffff;
  --accent-soft:#e2f0ea;
  --amber:#8a5a12;
  --amber-soft:#faedd9;
  --red:#9c3322;
  --red-soft:#fae5e0;
  --blue:#1c5478;
  --blue-soft:#e2edf4;
  --radius:10px;
  --shadow-1:0 1px 2px rgba(18,33,29,.06);
  --shadow-2:0 4px 16px -6px rgba(18,33,29,.25);
  --tap:48px;
  --sans:"Segoe UI",Roboto,system-ui,-apple-system,"Noto Sans Bengali","Hind Siliguri",sans-serif;
  --mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}
@media (prefers-color-scheme:dark){
  :root{
    --ink:#e2eae6; --ink-2:#b7c5bf; --muted:#879992;
    --paper:#0d1512; --surface:#16211d; --surface-2:#1e2b26;
    --line:#2b3a34; --line-soft:#223029;
    --brand:#0b1f19; --accent:#3fb289; --accent-ink:#06211a;
    --accent-soft:#12312a; --amber:#d9a257; --amber-soft:#33260f;
    --red:#e08b78; --red-soft:#331d18; --blue:#7fb6d9; --blue-soft:#152730;
    --shadow-1:0 1px 2px rgba(0,0,0,.5); --shadow-2:0 4px 16px -6px rgba(0,0,0,.7);
  }
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--paper); color:var(--ink);
  font-family:var(--sans); font-size:16px; line-height:1.5;
  -webkit-text-size-adjust:100%;
}
[hidden]{display:none !important}
h1,h2,h3,h4{margin:0 0 .4em; line-height:1.25; font-weight:650}
h1{font-size:1.4rem} h2{font-size:1.15rem} h3{font-size:1rem}
p{margin:0 0 .8em}
a{color:var(--accent)}
.muted{color:var(--muted)}
.small{font-size:.83rem}
.mono,.num{font-family:var(--mono); font-variant-numeric:tabular-nums}
.right{text-align:right}
.center{text-align:center}
.nowrap{white-space:nowrap}
.only-mobile{display:none}

/* ---------- boot ---------- */
.boot{min-height:100dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;padding:2rem}
.boot-mark{font-weight:700;letter-spacing:-.01em;font-size:1.2rem;color:var(--accent)}
.spinner{width:26px;height:26px;border:3px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spinner{animation-duration:2s}}

/* ---------- top bar ---------- */
.topbar{
  position:sticky;top:0;z-index:40;
  display:flex;align-items:center;gap:.6rem;
  padding:.5rem .8rem;padding-top:max(.5rem,env(safe-area-inset-top));
  background:var(--brand);color:#eef5f1;box-shadow:var(--shadow-1);
}
.brand{display:flex;flex-direction:column;min-width:0;flex:1}
.brand-name{font-weight:650;font-size:1rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-sub{font-size:.72rem;opacity:.72;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar-right{display:flex;align-items:center;gap:.4rem}
.icon-btn{
  width:var(--tap);height:var(--tap);min-width:var(--tap);
  display:grid;place-items:center;background:transparent;border:0;color:inherit;
  border-radius:8px;cursor:pointer;
}
.icon-btn:hover{background:rgba(255,255,255,.1)}
.burger,.burger::before,.burger::after{display:block;width:20px;height:2px;background:currentColor;border-radius:2px}
.burger{position:relative}
.burger::before,.burger::after{content:"";position:absolute;left:0}
.burger::before{top:-6px} .burger::after{top:6px}
.pill-btn{
  background:rgba(255,255,255,.14);color:inherit;border:0;border-radius:999px;
  padding:.35rem .75rem;font:inherit;font-size:.8rem;cursor:pointer;min-height:36px;
}
.pill-btn:hover{background:rgba(255,255,255,.24)}
.avatar{
  width:38px;height:38px;border-radius:50%;border:0;cursor:pointer;
  background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:.85rem;
}
.usermenu{position:relative}
.popover{
  position:absolute;right:0;top:46px;min-width:230px;z-index:60;
  background:var(--surface);color:var(--ink);border:1px solid var(--line);
  border-radius:var(--radius);box-shadow:var(--shadow-2);overflow:hidden;
}
.popover-head{padding:.7rem .85rem;border-bottom:1px solid var(--line-soft);display:flex;flex-direction:column;gap:.15rem}
.popover-item{
  display:block;width:100%;text-align:left;background:none;border:0;
  padding:.7rem .85rem;font:inherit;color:inherit;cursor:pointer;text-decoration:none;
}
.popover-item:hover{background:var(--surface-2)}
.popover-item.danger{color:var(--red)}

/* ---------- layout ---------- */
.layout{display:flex;min-height:calc(100dvh - 52px)}
html:not(.is-narrow) .layout{background:linear-gradient(to right,var(--surface) 0 230px,transparent 230px)}
.sidenav{
  width:230px;flex:0 0 230px;background:var(--surface);border-right:1px solid var(--line);
  padding:.6rem .5rem 2rem;overflow-y:auto;
  position:sticky;top:52px;height:calc(100dvh - 52px);
}
.navlink{
  display:flex;align-items:center;gap:.6rem;
  padding:.6rem .7rem;border-radius:8px;color:var(--ink-2);
  text-decoration:none;font-size:.92rem;min-height:42px;
}
.navlink:hover{background:var(--surface-2);color:var(--ink)}
.navlink[aria-current="page"]{background:var(--accent-soft);color:var(--accent);font-weight:600}
.navlink .ico{width:20px;text-align:center;flex:0 0 20px}
.nav-group{margin:.9rem .7rem .3rem;font-size:.68rem;letter-spacing:.09em;text-transform:uppercase;color:var(--muted)}
.view{flex:1;min-width:0;padding:1rem;padding-bottom:5rem;outline:none}
.scrim{position:fixed;inset:0;background:rgba(6,14,11,.5);z-index:45}

.tabbar{
  position:fixed;left:0;right:0;bottom:0;z-index:40;
  display:flex;background:var(--surface);border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
}
.tabbar a{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  padding:.4rem .2rem;min-height:56px;font-size:.66rem;color:var(--muted);text-decoration:none;
}
.tabbar a[aria-current="page"]{color:var(--accent)}
.tabbar .ico{font-size:1.1rem}

.credit{
  padding:1.1rem .8rem 1.4rem;text-align:center;font-size:.72rem;color:var(--muted);
  border-top:1px solid var(--line-soft);
}

/* The one card in the application that destroys data. It is coloured
   like a warning because it is one. */
.danger-zone{border-color:var(--red);border-width:1px}
.danger-zone .card-head h2{color:var(--red)}
.danger-zone h3{font-size:.9rem;margin:.2rem 0 .4rem}
ul.tick{margin:.2rem 0 .6rem;padding-left:1.1rem;font-size:.85rem;color:var(--ink-2)}
ul.tick li{margin:.15rem 0}

/* ---------------------------------------------------------------------
   The narrow / wide switch.

   This used to be `@media (max-width:860px)`. It is now a class that
   JavaScript puts on <html>, because a media query answers "how wide is
   the viewport", and the question that actually matters is "is this a
   phone in someone's hand". Those come apart in one common case: Chrome
   on Android with "Desktop site" ticked reports a ~980px viewport on a
   360px screen, every width query goes false, and the phone gets the
   laptop layout and has to be pinch-zoomed. Owning the switch in JS
   means the physical screen and an explicit user choice can decide it
   too. See setLayout() in core/app.js.
   --------------------------------------------------------------------- */
html.is-narrow .only-mobile{display:flex}
html.is-narrow .sidenav{
  position:fixed;top:0;left:0;height:100dvh;z-index:50;
  transform:translateX(-100%);transition:transform .18s ease;
  padding-top:max(1rem,env(safe-area-inset-top));
}
html.is-narrow .sidenav.open{transform:none;box-shadow:var(--shadow-2)}
html.is-narrow .view{padding:.75rem;padding-bottom:6.5rem}
html.is-narrow .credit{padding-bottom:5rem}
html:not(.is-narrow) .tabbar,
html:not(.is-narrow) .scrim{display:none}
@media (prefers-reduced-motion:reduce){ .sidenav{transition:none} }

/* Fingers are not mouse pointers. Anything tappable gets the full 44px
   on the phone layout, which is the smallest target most people can hit
   reliably on the first try. Measured by scripts/mobile-audit.mjs, which
   fails the build if something drops below it. */
html.is-narrow .pill-btn,
html.is-narrow .btn.small,
html.is-narrow .avatar{min-height:44px}
html.is-narrow .avatar{width:44px;height:44px}
html.is-narrow .btn{min-height:44px}
html.is-narrow .navlink{min-height:48px}
html.is-narrow input,
html.is-narrow select,
html.is-narrow textarea{min-height:44px;font-size:16px}

/* ---------- page furniture ---------- */
.page-head{display:flex;flex-wrap:wrap;align-items:flex-start;gap:.6rem;margin-bottom:.9rem}
.page-head h1{flex:1;min-width:12rem;margin:0}
.page-head .sub{width:100%;margin:0;color:var(--muted);font-size:.85rem}
.toolbar{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin-bottom:.9rem}
.toolbar .grow{flex:1;min-width:8rem}
.spacer{flex:1}

.card{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
  box-shadow:var(--shadow-1);padding:.9rem 1rem;margin-bottom:.9rem;
}
.card > :last-child{margin-bottom:0}
.card-head{display:flex;align-items:center;gap:.5rem;margin:-.2rem 0 .7rem}
.card-head h2,.card-head h3{margin:0;flex:1}

.grid{display:grid;gap:.75rem}
.g-stats{grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));margin-bottom:.9rem}
.g-2{grid-template-columns:repeat(auto-fit,minmax(16rem,1fr))}
.g-form{grid-template-columns:repeat(auto-fit,minmax(13rem,1fr))}

.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:.75rem .85rem;box-shadow:var(--shadow-1)}
.stat .label{font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--muted);display:block}
.stat .value{font-family:var(--mono);font-variant-numeric:tabular-nums;font-size:1.32rem;font-weight:650;display:block;margin-top:.15rem;word-break:break-word}
.stat .foot{font-size:.75rem;color:var(--muted);display:block;margin-top:.15rem}
.stat.good .value{color:var(--accent)}
.stat.bad  .value{color:var(--red)}

.bar{height:8px;border-radius:999px;background:var(--surface-2);overflow:hidden;margin-top:.4rem}
.bar > span{display:block;height:100%;background:var(--accent);border-radius:999px}
.bar.warn > span{background:var(--amber)}
.bar.over > span{background:var(--red)}

/* ---------- alerts ---------- */
.alert{
  display:flex;gap:.65rem;align-items:flex-start;
  border-left:4px solid var(--accent);background:var(--accent-soft);
  padding:.7rem .85rem;border-radius:0 8px 8px 0;margin-bottom:.5rem;
  color:var(--ink);text-decoration:none;
}
.alert.high{border-left-color:var(--red);background:var(--red-soft)}
.alert.normal{border-left-color:var(--amber);background:var(--amber-soft)}
.alert .a-body{flex:1;min-width:0}
.alert .a-title{font-weight:600}
.alert .a-meta{font-size:.8rem;color:var(--ink-2)}

.empty{padding:1.8rem 1rem;text-align:center;color:var(--muted);border:1px dashed var(--line);border-radius:var(--radius)}

/* ---------- badges ---------- */
.badge{
  display:inline-block;padding:.12rem .45rem;border-radius:5px;
  font-size:.7rem;font-weight:600;letter-spacing:.03em;text-transform:uppercase;
  border:1px solid transparent;white-space:nowrap;
}
.b-paid,.b-posted,.b-approved,.b-active,.b-ok{background:var(--accent-soft);color:var(--accent);border-color:var(--accent)}
.b-partial,.b-pending_approval,.b-submitted,.b-returned,.b-pending{background:var(--amber-soft);color:var(--amber);border-color:var(--amber)}
.b-overdue,.b-rejected,.b-reversed,.b-partly_reversed,.b-cancelled,.b-inactive{background:var(--red-soft);color:var(--red);border-color:var(--red)}
.b-unpaid,.b-draft,.b-waived,.b-closed{background:var(--surface-2);color:var(--muted);border-color:var(--line)}
.b-open{background:var(--blue-soft);color:var(--blue);border-color:var(--blue)}
.chips{display:flex;flex-wrap:wrap;gap:.25rem;margin-top:.3rem}

/* ---------- forms ---------- */
label.field{display:flex;flex-direction:column;gap:.25rem;font-size:.82rem;color:var(--ink-2);margin-bottom:.6rem}
label.field > span.req::after{content:" *";color:var(--red)}
input,select,textarea{
  font:inherit;color:var(--ink);background:var(--surface);
  border:1px solid var(--line);border-radius:8px;
  padding:.6rem .65rem;min-height:var(--tap);width:100%;
}
textarea{min-height:5rem;resize:vertical}
input:focus,select:focus,textarea:focus,button:focus-visible,a:focus-visible{
  outline:2px solid var(--accent);outline-offset:1px;
}
input[type=checkbox]{width:22px;height:22px;min-height:22px;accent-color:var(--accent)}
.check{display:flex;align-items:center;gap:.6rem;min-height:var(--tap);font-size:.92rem}
.hint{font-size:.76rem;color:var(--muted)}
fieldset{border:1px solid var(--line);border-radius:var(--radius);padding:.8rem;margin:0 0 .9rem}
legend{font-size:.78rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:0 .3rem}

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:.4rem;
  min-height:var(--tap);padding:.6rem 1.1rem;border-radius:8px;
  border:1px solid var(--line);background:var(--surface);color:var(--ink);
  font:inherit;font-weight:600;cursor:pointer;text-decoration:none;
}
.btn:hover{background:var(--surface-2)}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.primary:hover{filter:brightness(1.06)}
.btn.danger{color:var(--red);border-color:var(--red)}
.btn.danger:hover{background:var(--red-soft)}
.btn.small{min-height:36px;padding:.3rem .65rem;font-size:.82rem;font-weight:600}
.btn-row{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.9rem}
.btn-big{width:100%;min-height:64px;font-size:1rem;flex-direction:column;gap:.15rem}
.btn-big .ico{font-size:1.3rem}
.btn-big .sub{font-size:.72rem;font-weight:400;color:var(--muted)}

/* ---------- tables ---------- */
.tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);margin-bottom:.9rem}
table{border-collapse:collapse;width:100%;font-size:.88rem}
th,td{padding:.55rem .7rem;text-align:left;border-bottom:1px solid var(--line-soft);vertical-align:top}
thead th{
  position:sticky;top:0;background:var(--surface-2);color:var(--muted);
  font-size:.7rem;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;
  border-bottom:1px solid var(--line);z-index:1;
}
tbody tr:last-child td{border-bottom:0}
tbody tr.clickable{cursor:pointer}
tbody tr.clickable:hover{background:var(--surface-2)}
td.num,th.num{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;white-space:nowrap}
tfoot td{font-weight:700;background:var(--surface-2);border-top:2px solid var(--line)}

/* Card-style rows on a phone: tables are unreadable at 360px. */
html.is-phone table.stack thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
html.is-phone table.stack tr{display:block;border-bottom:1px solid var(--line);padding:.55rem .7rem}
html.is-phone table.stack tr:last-child{border-bottom:0}
html.is-phone table.stack td{display:flex;justify-content:space-between;gap:1rem;border:0;padding:.15rem 0}
html.is-phone table.stack td::before{content:attr(data-l);color:var(--muted);font-size:.78rem;flex:0 0 auto}
html.is-phone table.stack td.num{text-align:right}
html.is-phone table.stack td.primary{font-weight:650;font-size:1rem}
html.is-phone table.stack td.primary::before{font-weight:400}

/* ---------- toasts & modal ---------- */
.toasts{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(72px + env(safe-area-inset-bottom));z-index:90;display:flex;flex-direction:column;gap:.4rem;width:min(94vw,26rem)}
.toast{
  background:var(--brand);color:#eef5f1;padding:.7rem .9rem;border-radius:8px;
  box-shadow:var(--shadow-2);font-size:.88rem;
}
.toast.err{background:var(--red);color:#fff}
.toast.ok{background:var(--accent);color:var(--accent-ink)}

.modal-scrim{position:fixed;inset:0;background:rgba(6,14,11,.55);z-index:80;display:flex;align-items:flex-end;justify-content:center;padding:0}
.modal{
  background:var(--surface);width:100%;max-width:36rem;max-height:92dvh;overflow-y:auto;
  border-radius:14px 14px 0 0;box-shadow:var(--shadow-2);padding:1rem 1rem 1.4rem;
}
.modal-head{display:flex;align-items:center;gap:.5rem;margin-bottom:.8rem}
.modal-head h2{margin:0;flex:1;font-size:1.05rem}
html:not(.is-phone) .modal-scrim{align-items:center;padding:1.5rem}
html:not(.is-phone) .modal{border-radius:14px}

/* ---------- auth ---------- */
.auth{min-height:100dvh;display:flex;align-items:center;justify-content:center;padding:1.2rem}
.auth-card{width:min(100%,25rem);background:var(--surface);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow-2);padding:1.4rem}
.auth-mark{text-align:center;margin-bottom:1.1rem}
.auth-mark .dot{width:44px;height:44px;border-radius:12px;background:var(--accent);color:var(--accent-ink);display:grid;place-items:center;margin:0 auto .6rem;font-weight:700}
.auth-tabs{display:flex;gap:.3rem;background:var(--surface-2);border-radius:8px;padding:3px;margin-bottom:1rem}
.auth-tabs button{flex:1;min-height:40px;border:0;background:none;font:inherit;font-weight:600;color:var(--muted);border-radius:6px;cursor:pointer}
.auth-tabs button[aria-selected="true"]{background:var(--surface);color:var(--ink);box-shadow:var(--shadow-1)}

.dl{display:grid;grid-template-columns:auto 1fr;gap:.3rem .9rem;font-size:.9rem;margin:0}
.dl dt{color:var(--muted)}
.dl dd{margin:0;word-break:break-word}
.print-only{display:none}
@media print{
  .topbar,.sidenav,.tabbar,.toolbar,.credit,.btn,.scrim{display:none !important}
  .view{padding:0}
  .card{box-shadow:none;border:0}
  .print-only{display:block}
  body{background:#fff}
}

/* ---------- notification bell ---------- */
#bellBtn{position:relative}
.bell-count{
  position:absolute;top:2px;right:2px;min-width:16px;height:16px;
  padding:0 3px;border-radius:999px;background:var(--red);color:#fff;
  font-size:.62rem;line-height:16px;font-weight:700;text-align:center;
}
#bellPanel{width:min(21rem,calc(100vw - 2rem));max-height:70vh;overflow-y:auto}
#bellPanel .popover-item{display:block;text-decoration:none;white-space:normal;line-height:1.35}
#bellPanel .popover-item.unread{background:var(--accent-soft)}
#bellPanel .popover-item b{display:block;font-size:.85rem}

/* ---------- report letterhead (screen + print) ---------- */
.letterhead{display:none}
.letterhead .lh-name{font-size:1.35rem;font-weight:700;letter-spacing:-.01em;margin:0}
.letterhead .lh-addr{color:var(--ink-2);font-size:.85rem;margin:.15rem 0 0}
.letterhead .lh-rule{border:0;border-top:2px solid var(--accent);margin:.6rem 0 .5rem}
.letterhead .lh-title{font-size:1.05rem;font-weight:700;margin:0}
.letterhead .lh-meta{display:flex;justify-content:space-between;gap:1rem;
  font-size:.8rem;color:var(--muted);margin-top:.2rem}

@media print{
  /* The letterhead exists only on paper: on screen the page already has
     a heading and the building name sits in the top bar. */
  .letterhead{display:block;margin-bottom:.8rem}
  .page-head,.alert,.bar,.badge.b-draft{display:none !important}
  .grid.g-stats{display:grid !important;grid-template-columns:repeat(4,1fr);gap:.4rem}
  .stat{border:1px solid #ccc;padding:.4rem .5rem;break-inside:avoid}
  .stat .value{font-size:1rem}
  table{font-size:10pt;width:100%;border-collapse:collapse}
  th{background:#12332a !important;color:#fff !important;
     -webkit-print-color-adjust:exact;print-color-adjust:exact}
  th,td{border:1px solid #bbb;padding:3px 5px}
  tfoot td{font-weight:700;background:#f0f0f0 !important;
     -webkit-print-color-adjust:exact;print-color-adjust:exact}
  thead{display:table-header-group}      /* repeat headings on every page */
  tr{break-inside:avoid}
  section.card{break-inside:auto;margin-bottom:.6rem}
  h2{font-size:1rem;margin:.7rem 0 .3rem;break-after:avoid}
  .tablewrap{overflow:visible !important}
  @page{size:A4;margin:14mm 12mm 16mm}
}

/* ---------- flat page: owner, tenant, who pays ---------- */
.person{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem 1rem;padding:.75rem 0;border-bottom:1px solid var(--line-soft)}
.person-role{flex:0 0 6.5rem;display:flex;flex-direction:column;align-items:flex-start;gap:.2rem;font-size:.82rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}
.person-main{flex:1 1 12rem;min-width:0;overflow-wrap:anywhere}
.person-acts{display:flex;flex-wrap:wrap;gap:.4rem}
.pays{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem 1rem;padding-top:.85rem}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.seg-btn{min-height:var(--tap);min-width:6rem;padding:0 1rem;border:0;background:var(--surface);color:var(--ink);font:inherit;font-weight:600;cursor:pointer}
.seg-btn + .seg-btn{border-left:1px solid var(--line)}
.seg-btn.on{background:var(--accent);color:var(--accent-ink)}
.seg-btn:disabled{cursor:default;opacity:.75}
.hint.ok-line{color:var(--accent)}
.warn-line{color:var(--amber);font-size:.88rem}
@media (max-width:600px){
  .person-role{flex-basis:100%;flex-direction:row;align-items:center}
  .person-acts{flex-basis:100%}
  .person-acts .btn{flex:1}
}

/* ---------- reminders ---------- */
.rem-who{background:var(--surface-2);border-radius:var(--radius);padding:.6rem .8rem;margin-bottom:.6rem}
.rem-text{width:100%;min-height:12rem;font-family:var(--sans);line-height:1.45}
.rem-sent{white-space:pre-wrap;overflow-wrap:anywhere;font-family:var(--sans);font-size:.92rem;background:var(--surface-2);border-radius:var(--radius);padding:.75rem .9rem;margin:.3rem 0 0;max-height:22rem;overflow:auto}
.rem-count{display:inline-block;font-size:.85rem;font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--ink-2)}
.rem-count.hot{color:var(--red);font-weight:600}
.rem .btn-row{flex-wrap:wrap}
.chip{min-height:44px;padding:0 .7rem;border:1px solid var(--line);border-radius:999px;background:var(--surface);color:var(--ink);font-family:var(--mono);font-size:.85rem;cursor:pointer}
.chip:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
.ph-help{margin:.5rem 0}
.ph-help summary{cursor:pointer;color:var(--accent);min-height:var(--tap);display:flex;align-items:center}
.ph-help li{margin:.2rem 0}
@media print{ .person-acts,.seg,.chip{display:none} }

/* ---------- receipts ---------- */
.row-acts{display:inline-flex;flex-wrap:wrap;gap:.35rem}
.receipt-actions{flex-wrap:wrap;margin-top:.8rem}
.receipt-view.is-reversed{opacity:.75}
/* "Print" on a receipt prints the receipt — not the page behind it. */
@media print{
  body.printing-receipt #app,
  body.printing-receipt #toasts{display:none !important}
  body.printing-receipt .modal-scrim{position:static;background:none;display:block;padding:0}
  body.printing-receipt .modal{box-shadow:none;border:0;max-width:none;width:auto;max-height:none;overflow:visible;margin:0 auto}
  body.printing-receipt .modal-head,
  body.printing-receipt .modal .btn-row,
  body.printing-receipt .modal .muted.small,
  body.printing-receipt .receipt-actions{display:none !important}
  body.printing-receipt #receiptBody{max-width:120mm;margin:10mm auto;border:1px solid #bbb;padding:8mm}
}

/* ---------- a list of choices, each with a sentence ---------- */
.choice-list{display:flex;flex-direction:column;gap:.4rem}
.choice{display:flex;gap:.6rem;align-items:flex-start;padding:.6rem .75rem;border:1px solid var(--line);border-radius:var(--radius);cursor:pointer;min-height:var(--tap)}
.choice input{margin-top:.2rem;flex:none;width:1.1rem;height:1.1rem}
.choice span{display:flex;flex-direction:column;gap:.1rem}
.choice.on{border-color:var(--accent);background:var(--accent-soft)}

/* ---------- reports: tabs, monthly report ---------- */
.tabs{display:flex;gap:.3rem;flex-wrap:wrap;margin:0 0 .9rem;border-bottom:1px solid var(--line)}
.tab{display:inline-flex;align-items:center;min-height:var(--tap);padding:0 1rem;text-decoration:none;color:var(--ink-2);
  font-weight:600;border-bottom:3px solid transparent;margin-bottom:-1px}
.tab.on{color:var(--accent);border-bottom-color:var(--accent)}
.report-controls .ctl{flex:1 1 9rem;min-width:8rem}
.report-controls .quick{display:flex;gap:.4rem;align-items:flex-end;padding-bottom:.1rem}
.report-actions{display:flex;gap:.5rem;flex-wrap:wrap}
.report-title{margin:.2rem 0 0}
.report-period{margin:.1rem 0 .8rem}
.report-table .dept-row td{font-weight:700;background:var(--surface-2)}
.report-table .cat-row td:first-child{padding-left:1.6rem}
.result dd{font-weight:700}
.result dd.good{color:var(--accent)} .result dd.bad{color:var(--red)}
.signoff{display:grid;grid-template-columns:repeat(3,1fr);gap:1.5rem;padding-top:2.4rem}
.sign{text-align:center;font-size:.9rem}
.sign-line{border-top:1px solid var(--ink-2);margin-bottom:.3rem}
.no-detail .detail-page{display:none}
.report-end{text-align:center;margin-top:1rem}
@media (max-width:600px){ .signoff{grid-template-columns:1fr;gap:2.2rem} }
@media print{
  .tabs,.report-controls,.report-title,.report-period{display:none !important}
  .page-break{break-before:page;page-break-before:always}
  .report-table .dept-row td{background:#eef2f0 !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .signoff{grid-template-columns:repeat(3,1fr) !important;break-inside:avoid;border:0}
  .report .card{padding:.2rem 0}
  .report h2{font-size:12pt;margin:.2rem 0}
  .report h3{font-size:10.5pt}
  .report .hint{font-size:8pt}
}
.nowrap{white-space:nowrap}
@media print{
  .detail-page table{font-size:8.5pt}
  .detail-page th,.detail-page td{padding:2px 4px}
  .detail-page td.mono{font-size:8pt}
}

/* ---------- Committee & Rules ---------- */
.visually-hidden{position:absolute !important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.hero{position:relative;border-radius:16px;padding:1.6rem 1.4rem 1.4rem;margin-bottom:1rem;color:#fff;
  background:linear-gradient(135deg,var(--brand) 0%,var(--accent) 100%);box-shadow:var(--shadow-2)}
.hero-kicker{font-size:.8rem;letter-spacing:.08em;text-transform:uppercase;opacity:.8;font-weight:600}
.hero-title{margin:.2rem 0 .1rem;font-size:clamp(1.4rem,3.6vw,2rem);line-height:1.2;color:#fff}
.hero-term{display:inline-block;margin-top:.35rem;padding:.15rem .6rem;border-radius:999px;background:rgba(255,255,255,.18);font-size:.85rem;font-weight:600}
.hero-intro{margin:.7rem 0 0;max-width:46rem;opacity:.92}
.hero-edit{position:absolute;top:.8rem;right:.8rem;background:rgba(255,255,255,.14);color:#fff;border-color:rgba(255,255,255,.35)}
.members{display:grid;gap:.9rem;grid-template-columns:repeat(auto-fill,minmax(15rem,1fr));margin-bottom:1rem}
.members.leads{grid-template-columns:repeat(auto-fit,minmax(17rem,1fr))}
.members.compact{grid-template-columns:repeat(auto-fill,minmax(13rem,1fr));margin-top:.8rem}
.member{position:relative;display:flex;flex-direction:column;align-items:center;text-align:center;gap:.6rem;
  background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:1.2rem 1rem 1rem;box-shadow:var(--shadow-1)}
.member.lg{padding:1.6rem 1.2rem 1.2rem;border-top:4px solid var(--accent)}
.member.sm{flex-direction:row;text-align:left;align-items:center;padding:.7rem .8rem}
.member-body{display:flex;flex-direction:column;gap:.15rem;min-width:0;width:100%}
.member.sm .member-body{width:auto}
.member-position{color:var(--accent);font-weight:700;font-size:.78rem;letter-spacing:.06em;text-transform:uppercase}
.member-name{margin:0;font-size:1.08rem;line-height:1.3;overflow-wrap:anywhere}
.member.lg .member-name{font-size:1.25rem}
.member-flat{font-size:.85rem;color:var(--ink-2)}
.member-about{margin:.3rem 0 0;font-size:.88rem;color:var(--ink-2)}
.member-contact{display:flex;flex-direction:column;gap:.1rem;margin-top:.3rem;font-size:.88rem;overflow-wrap:anywhere}
.member-contact a{min-height:32px;display:inline-flex;align-items:center;justify-content:center}
.member.sm .member-contact a{justify-content:flex-start}
.member-edit{position:absolute;top:.5rem;right:.5rem}
.m-avatar{border-radius:50%;object-fit:cover;flex:none;background:var(--surface-2);border:3px solid var(--surface);box-shadow:0 0 0 1px var(--line)}
.m-avatar.lg{width:132px;height:132px} .m-avatar.md{width:104px;height:104px} .m-avatar.sm{width:52px;height:52px;border-width:2px}
.m-avatar.initials{display:flex;align-items:center;justify-content:center;font-weight:700;color:#fff;
  background:hsl(var(--h) 38% 42%);font-size:2.4rem;letter-spacing:.02em}
.m-avatar.lg.initials{font-size:2.9rem} .m-avatar.sm.initials{font-size:1.1rem}
.former summary{cursor:pointer;font-weight:600;min-height:var(--tap);display:flex;align-items:center}
.photo-row{display:flex;align-items:center;gap:1rem;flex-wrap:wrap;margin-bottom:.6rem}
.photo-preview .m-avatar.lg{width:96px;height:96px;font-size:2rem}
.chip-row{display:flex;flex-wrap:wrap;gap:.4rem;margin:-.2rem 0 1rem}
.filter-chip{min-height:40px;padding:0 .9rem;border:1px solid var(--line);border-radius:999px;background:var(--surface);color:var(--ink);font:inherit;font-size:.9rem;cursor:pointer}
.filter-chip.on{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.doc-group{margin-bottom:1.2rem}
.doc-group h2{font-size:.85rem;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);margin:.2rem 0 .5rem}
.doc-row{display:flex;gap:.9rem;align-items:center;text-decoration:none;color:inherit;background:var(--surface);
  border:1px solid var(--line);border-radius:12px;padding:.85rem 1rem;margin-bottom:.5rem;min-height:var(--tap)}
.doc-row:hover{border-color:var(--accent)}
.doc-icon{flex:none;width:2.4rem;height:2.4rem;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;
  font-weight:700;background:var(--accent-soft);color:var(--accent)}
.doc-icon.c-constitution{background:var(--blue-soft);color:var(--blue)}
.doc-icon.c-notice{background:var(--amber-soft);color:var(--amber)}
.doc-icon.c-decision{background:var(--surface-2);color:var(--ink-2)}
.doc-main{display:flex;flex-direction:column;gap:.15rem;min-width:0;flex:1}
.doc-title{font-weight:700;display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;overflow-wrap:anywhere}
.doc-meta{font-size:.82rem;color:var(--muted)}
.doc-summary{font-size:.9rem;color:var(--ink-2)}
.doc-go{font-size:1.6rem;color:var(--muted)}
.doc-article{max-width:52rem;padding:1.4rem 1.4rem 1.6rem}
.doc-kicker{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap;font-weight:600;color:var(--ink-2)}
.doc-heading{margin:.6rem 0 .2rem;font-size:clamp(1.35rem,3.4vw,1.8rem);line-height:1.25}
.doc-lead{font-size:1.05rem;color:var(--ink-2);margin:.8rem 0 0;padding-left:.8rem;border-left:3px solid var(--accent)}
.doc-body{margin-top:1rem;line-height:1.7;font-size:1rem}
.doc-body p{margin:.5rem 0}
.doc-h{font-size:1.15rem;margin:1.4rem 0 .4rem;padding-bottom:.25rem;border-bottom:1px solid var(--line-soft)}
h3.doc-h{font-size:1.02rem;border:0}
.rule{display:flex;gap:.6rem;margin:.45rem 0}
.rule.sub{margin-left:1.6rem}
.rule-no{flex:none;min-width:2.2rem;font-weight:700;color:var(--accent);font-variant-numeric:tabular-nums}
.doc-list{margin:.4rem 0 .4rem 1.2rem;padding:0}
.doc-list li{margin:.25rem 0}
.doc-file{display:flex;align-items:center;gap:.8rem;margin-top:1.4rem;padding:.8rem;border:1px dashed var(--line);border-radius:12px;flex-wrap:wrap}
.doc-file-icon{width:2.6rem;height:2.6rem;border-radius:8px;background:var(--red-soft);color:var(--red);display:flex;align-items:center;justify-content:center;font-weight:800;font-size:.75rem}
.doc-file-name{flex:1;min-width:10rem;overflow-wrap:anywhere}
.doc-editor{font-family:var(--sans);line-height:1.5}
@media (max-width:600px){
  .hero{padding:1.3rem 1rem 1.1rem;border-radius:12px}
  .hero-edit{position:static;margin-top:.8rem}
  .doc-article{padding:1rem}
}
@media print{
  .hero{color:#000;background:none !important;box-shadow:none;border:1px solid #bbb}
  .hero-title{color:#000}
  .member-edit,.hero-edit,.chip-row{display:none !important}
  .doc-page .doc-kicker,.doc-page .doc-heading{display:none}
  .doc-article{border:0;padding:0;max-width:none}
  .doc-file .btn{display:none}
}

/* ---------- backup ---------- */
.backup-hero{display:flex;gap:1rem;align-items:center}
.backup-hero h2{margin:0 0 .15rem}
.backup-hero p{margin:0}
.backup-mark{flex:none;width:3rem;height:3rem;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.4rem;font-weight:800}
.backup-hero.fresh .backup-mark{background:var(--accent-soft);color:var(--accent)}
.backup-hero.stale .backup-mark{background:var(--amber-soft);color:var(--amber)}
.backup-contents{margin:.6rem 0 1rem 1.1rem;padding:0;color:var(--ink-2);font-size:.92rem}
.backup-contents li{margin:.2rem 0}
.btn.big{min-height:52px;padding:0 1.4rem;font-size:1.02rem}
.backup-progress{list-style:none;margin:1rem 0 0;padding:0;columns:2 16rem;font-size:.88rem}
.backup-progress li{display:flex;justify-content:space-between;gap:.6rem;padding:.2rem 0;border-bottom:1px solid var(--line-soft);break-inside:avoid}
.backup-progress li.skipped{color:var(--muted)}

/* ---------- receipts & photos on an entry ---------- */
.attach-grid{display:grid;gap:.8rem;grid-template-columns:repeat(auto-fill,minmax(10.5rem,1fr));margin-bottom:.8rem}
.attach-tile{margin:0;display:flex;flex-direction:column;gap:.35rem;min-width:0}
.attach-thumb{display:flex;align-items:center;justify-content:center;aspect-ratio:3/4;max-height:16rem;width:100%;padding:0;overflow:hidden;
  border:1px solid var(--line);border-radius:10px;background:var(--surface-2);cursor:zoom-in}
.attach-thumb img{width:100%;height:100%;object-fit:contain;display:block;background:#fff}
.attach-pdf{font-weight:800;font-size:1.1rem;color:var(--red);background:var(--red-soft);padding:.5rem .8rem;border-radius:8px}
.attach-loading{color:var(--muted)}
.attach-tile figcaption{display:flex;flex-direction:column;gap:.15rem;align-items:flex-start}
.attach-name{font-size:.88rem;font-weight:600;overflow-wrap:anywhere}
.attach-empty{grid-column:1/-1;margin:0}
.attach-removed{margin-top:.6rem}
.attach-removed summary{cursor:pointer;color:var(--muted);font-size:.88rem;min-height:36px;display:flex;align-items:center}
.attach-removed ul{margin:.3rem 0 0 1rem;padding:0}
label.btn.disabled{opacity:.55;pointer-events:none}
.modal .attach-card{margin-top:1rem;border-style:dashed;box-shadow:none}
@media print{
  body.printing-receipt .attach-card{display:none !important}
  .attach-card .btn,.attach-card .hint{display:none !important}
}

/* ---- v5: owners with several flats, combined payments, monthly bills ---- */
.bad-text{color:var(--red)}
.owe-list{margin:.4rem 0 .8rem;padding-left:1.1rem}
.owe-list li{margin:.15rem 0}
.pay-lines{display:flex;flex-direction:column;gap:.5rem;margin:.6rem 0}
.pay-line{display:grid;grid-template-columns:auto 1fr minmax(7rem,9rem);align-items:center;gap:.7rem;
  padding:.55rem .7rem;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);cursor:pointer}
.pay-line input[type=checkbox]{width:22px;height:22px}
.pay-line input[type=number]{min-height:var(--tap);text-align:right}
.pay-line input:disabled{opacity:.45}
.pay-flat{display:flex;flex-direction:column;min-width:0}
.pay-total{font-size:1.1rem;text-align:right;margin:.3rem 0 .9rem}
.rate-now{padding:.6rem .8rem;border-radius:var(--radius);background:var(--paper)}
.rate-now.temp{background:var(--amber-soft);color:var(--amber)}
.bill-list{display:grid;gap:.8rem;grid-template-columns:repeat(auto-fill,minmax(320px,1fr))}
.bill-card{margin:0}
.bill-card.sent{opacity:.8}
.bill-head{display:flex;justify-content:space-between;gap:.8rem;align-items:flex-start}
.bill-head h3{margin:0 0 .15rem}
.bill-total{display:flex;flex-direction:column;align-items:flex-end;white-space:nowrap}
.bill-total b{font-size:1.15rem}
.bill-lines{width:100%;border-collapse:collapse;margin:.6rem 0;font-size:.92rem}
.bill-lines td{padding:.3rem .2rem;border-top:1px solid var(--line-soft)}
.bill-lines td.num{text-align:right;white-space:nowrap}
.bill-foot{display:flex;align-items:center;justify-content:space-between;gap:.6rem;flex-wrap:wrap}
@media (max-width:520px){
  .bill-list{grid-template-columns:1fr}
  .pay-line{grid-template-columns:auto 1fr;}
  .pay-line input[type=number]{grid-column:1 / -1}
}
.bill-lines th{font-size:.75rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.03em;padding:.2rem;text-align:left}
.bill-lines th.num{text-align:right}

/* ---- v7: who owns & who pays, duplicates, fixing wrong entries ---- */
.dup-card{border-color:var(--amber);background:var(--amber-soft)}
.dup-row{display:flex;justify-content:space-between;align-items:center;gap:.8rem;padding:.6rem 0;border-top:1px solid var(--line)}
.dup-who{display:flex;flex-direction:column;gap:.15rem;min-width:0}
.pick-card{display:flex;gap:.7rem;align-items:flex-start;padding:.7rem .8rem;margin:.45rem 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);cursor:pointer}
.pick-card input{width:20px;height:20px;margin-top:.15rem;flex:none}
.pick-card:has(input:checked){border-color:var(--accent);background:var(--accent-soft)}
.sub-box{margin:.3rem 0 .6rem 2rem}
.seg-sm .seg-btn{min-width:4.6rem;padding:0 .7rem}
.owner-sum{display:flex;justify-content:space-between;align-items:center;gap:.8rem;flex-wrap:wrap;border-color:var(--accent);background:var(--accent-soft)}
.owner-sum-text{min-width:0}
.bulk-owner{margin-bottom:1rem}
.bulk-owner p{margin:.2rem 0 .5rem}
.tenant-note{display:block;color:var(--amber);margin-top:.15rem}
@media (max-width:520px){
  .dup-row{flex-direction:column;align-items:stretch}
  .sub-box{margin-left:0}
}

/* ---- v9: dashboard money in/out by department, LPG ---- */
.dept-grid{display:grid;grid-template-columns:1fr 1fr;gap:1.2rem;margin-top:.6rem}
.dept-title{display:flex;justify-content:space-between;padding:.2rem 0 .5rem;border-bottom:1px solid var(--line-soft);margin-bottom:.3rem}
.dept-row summary{display:grid;grid-template-columns:minmax(6rem,9rem) 1fr auto;align-items:center;gap:.6rem;min-height:var(--tap);cursor:pointer;list-style:none;padding:0 .2rem;border-radius:6px}
.dept-row summary::-webkit-details-marker{display:none}
.dept-row summary:hover{background:var(--paper)}
.dept-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dept-bar{height:10px;background:var(--line-soft);border-radius:999px;overflow:hidden}
.dept-bar span{display:block;height:100%;border-radius:0 4px 4px 0}
.dept-row.in .dept-bar span{background:var(--accent)}
.dept-row.out .dept-bar span{background:var(--blue)}
.dept-amt{min-width:5.5rem;text-align:right;font-weight:600}
.dept-cats{list-style:none;margin:.1rem 0 .6rem;padding:0 0 0 1rem;border-left:2px solid var(--line-soft)}
.dept-cats li{display:flex;justify-content:space-between;gap:.6rem;padding:.25rem .2rem;font-size:.9rem;color:var(--ink-2,var(--muted))}
.lpg-line{display:flex;justify-content:space-between;align-items:center;gap:.6rem;min-height:var(--tap);margin-top:.8rem;padding:.4rem .8rem;border:1px solid var(--line);border-radius:var(--radius);color:var(--ink);text-decoration:none}
@media (max-width:720px){ .dept-grid{grid-template-columns:1fr} }

/* ---- v10: slip preview, PAID / DUE seals ---- */
.slip-frame{display:flex;justify-content:center;padding:.6rem;background:var(--paper);border:1px solid var(--line);border-radius:var(--radius);max-height:62vh;overflow:auto}
.slip-img{width:100%;max-width:380px;height:auto;box-shadow:0 2px 10px rgba(0,0,0,.08)}
.slip-actions{margin-top:.8rem}
#slipPrint{display:none}
@media print{
  body.printing-slip > *:not(#slipPrint){display:none !important}
  body.printing-slip #slipPrint{display:flex !important;justify-content:center}
  body.printing-slip #slipPrint img{width:90mm;height:auto}
}
.bill-lines td:first-child{white-space:nowrap}
/* ---- v13: owner / tenant on the month grid ---- */
.who-cell{display:flex;flex-direction:column;gap:.15rem;min-width:0}
.who-line{display:flex;align-items:center;gap:.4rem;flex-wrap:wrap}
.who-role{font-size:.72rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);min-width:3.4rem}
.who-line.pays > span:nth-child(2){font-weight:600}
/* ---- v14: removing a person ---- */
.warn-box{border:1px solid var(--amber);background:var(--amber-soft);border-radius:var(--radius);padding:.6rem .8rem;margin:.6rem 0}
.warn-box p{margin:.2rem 0}
.removed-people{margin-top:1rem}
.removed-people summary{cursor:pointer;font-weight:600;min-height:var(--tap);display:flex;align-items:center}
