/* Dholpur Rentbook dashboard. System fonts only, so it loads fast on a
   phone in Dholpur and works offline from any outside host. */
:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eaeee9;
  --fg: #1b2420;
  --muted: #59655f;
  --line: #d3d9d3;
  --accent: #1d6b57;
  --accent-fg: #ffffff;
  --accent-soft: #d9ede5;
  --ok: #1f7a4d;
  --ok-soft: #dbf0e3;
  --part: #8a5a07;
  --part-soft: #f8ecd2;
  --bad: #a8452f;
  --bad-soft: #f6e0d8;
  --info: #3a5f8a;
  --info-soft: #e1eaf4;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --surface: #192019; --surface-2: #212a25; --fg: #e4eae6;
    --muted: #98a59e; --line: #2e3833; --accent: #63c6a7; --accent-fg: #0d1a15;
    --accent-soft: #1a3a30; --ok: #6fd19c; --ok-soft: #173326; --part: #e3b45c;
    --part-soft: #372c15; --bad: #ee8d74; --bad-soft: #3b211a; --info: #8db4e2;
    --info-soft: #1b2a3a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 14px; margin-top: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 8px 0; }

.banner {
  background: var(--part-soft); color: var(--part); text-align: center;
  font-size: 13px; font-weight: 600; padding: 6px 16px;
}

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in {
  max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 8px 20px;
  flex-wrap: wrap; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.brand { font-weight: 700; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
.banner.test { background: #b3261e; color: #fff; font-weight: 700; font-size: 1.05em;
  padding: 10px 16px; letter-spacing: .01em; }
.me { display: inline-flex; align-items: center; gap: 6px; }
.me .avatar { width: 28px; height: 28px; font-size: 0; }
/* The logo: green house, marigold moustache, glasses in the ink colour. */
.sprite { position: absolute; width: 0; height: 0; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand i { font-style: normal; color: var(--accent); }
.mark { width: 30px; height: 30px; flex: none; --m1: var(--accent); --m2: #e0a11b; --m3: var(--fg); }
.gate .brand { font-size: 1.2em; font-weight: 700; text-decoration: none; color: var(--fg); }
.gate .mark { width: 40px; height: 40px; }
/* On phones the header puts .brand after the menu; on the login page it stays on top. */
.gate .brand, .gate .brand:first-child { order: -1; margin-bottom: 8px; }
/* A house heads the sections in it on the Tenants and Portions pages. */
h2.house { margin: 30px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--accent);
  font-size: 22px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
h2.house small { font-size: 14px; font-weight: 500; color: var(--muted); }
h2.house.unplaced { border-bottom-color: #e0a11b; }
.card-head h3 { margin: 0; font-size: 17px; }
.lives { font-size: 16px; margin: 4px 0 2px; }
.lives small { color: var(--muted); }
form.place { margin-top: 6px; }
small.room { display: block; margin: 2px 0 0 52px; color: var(--muted); }
/* On a phone the tenant list keeps name, rent, this month and balance on
   screen; the due day is on the tenant's page. */
@media (max-width: 560px) {
  .tenant-list thead { display: none; }
  .tenant-list, .tenant-list tbody { display: block; }
  /* Each tenant becomes two lines: name and room with the rent, then this
     month with the balance. */
  .tenant-list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px;
    padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tenant-list td { padding: 0; border: 0; }
  .tenant-list td.due { display: none; }
  .tenant-list td:nth-child(2), .tenant-list td:nth-child(5) { text-align: right; }
}
form.place select { max-width: 13em; }
/* The demo's banner: the stamp violet, so it is never taken for real books
   or for a test copy. */
.banner.test.demo { background: #5a3e9e; }
.banner .short { display: none; }
@media (max-width: 560px) {
  .banner .long { display: none; }
  .banner .short { display: inline; }
}
/* A demo receipt or agreement carries SAMPLE on itself, on screen and paper. */
.paper.sample { position: relative; overflow: hidden; }
.sample-mark { margin: 0 0 12px; padding: 6px 10px; border: 2px dashed #5a3e9e; border-radius: 8px;
  color: #5a3e9e; font-weight: 800; letter-spacing: .08em; text-align: center; }
.paper.sample::after { content: "SAMPLE"; position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%) rotate(-24deg); font-size: 96px; font-weight: 900;
  letter-spacing: .1em; color: rgba(90, 62, 158, .12); pointer-events: none; }
.banner.demo a { color: #fff; text-decoration: underline; margin-left: .4em; white-space: nowrap; }
.account { color: var(--muted); font-size: .9em; margin-left: .4em; }
.tick { display: inline-flex; gap: .25em; align-items: center; margin-right: .6em; white-space: nowrap; }
nav { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; min-width: 0; scrollbar-width: none; }
nav a {
  padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--muted);
  white-space: nowrap; font-size: 14px;
}
nav a:hover { background: var(--surface-2); color: var(--fg); }
nav a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin: 0; }

main {
  max-width: 1100px; margin: 0 auto; display: grid; gap: 18px;
  /* minmax(0, ...) lets wide content scroll inside its card instead of
     pushing the whole page sideways on a phone. */
  grid-template-columns: minmax(0, 1fr);
  padding: 22px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px));
}
.crumbs { font-size: 13px; margin-bottom: -10px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }

.flash { padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--info-soft); color: var(--info); }

.daynav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.daynav input[type="date"] { padding: 6px 8px; font-size: 15px; min-width: 0; flex: 1 1 130px; max-width: 180px; }
.daynav .btn { padding: 7px 12px; }
.card.attention { border-color: var(--part); box-shadow: inset 4px 0 0 var(--part); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.kpis div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 2px; }
.kpis span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpis b { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpis small { color: var(--muted); font-size: 12.5px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 18px; align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; display: grid; gap: 12px; min-width: 0;
}
.card.narrow { max-width: 620px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
.count { background: var(--surface-2); color: var(--muted); font-size: 13px; padding: 1px 8px; border-radius: 999px; vertical-align: middle; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
th.num { text-align: right; }
tr:last-child td { border-bottom: none; }
td small { display: block; color: var(--muted); font-size: 12.5px; }
td em, .doc em { color: var(--part); font-style: normal; font-size: 12.5px; }
tr.voided td { color: var(--muted); }
tr.voided td:nth-child(3) { text-decoration: line-through; }
tr.voided td small { text-decoration: none; }
.ledger td:first-child { width: 1%; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; white-space: nowrap;
}
.chip-paid { background: var(--ok-soft); color: var(--ok); }
.chip-part { background: var(--part-soft); color: var(--part); }
.chip-unpaid { background: var(--bad-soft); color: var(--bad); }
.chip-upcoming { background: var(--surface-2); color: var(--muted); }
.chip-advance { background: var(--info-soft); color: var(--info); }

.needs { list-style: none; margin: 0; padding: 0; display: grid; }
.need {
  display: flex; justify-content: space-between; align-items: center; gap: 8px 14px;
  flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.need:last-child { border-bottom: none; }
.need > div { display: grid; gap: 2px; min-width: 0; flex: 1 1 240px; }
.need small { color: var(--muted); font-size: 13px; }

form { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.stack { display: grid; gap: 10px; }
.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; max-width: 100%;
}
input[type="file"] { padding: 6px; font-size: 14px; }
textarea { width: 100%; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-fg); white-space: nowrap;
}
.btn.quiet { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-soft); }
.btn:hover { filter: brightness(1.05); }
button.link { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; }

.tenant-who { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.tenant-who span:last-child { text-decoration: underline; text-underline-offset: 2px; }
tr:has(.tenant-who) > td { vertical-align: middle; }
.avatar.big { width: 72px; height: 72px; }
.avatar.none.big { font-size: 11px; }
.avatar-link { display: block; flex: none; border-radius: 50%; }
.tenant-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tenant-head h1 { margin: 0; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 12px; }
.person { margin: 0; display: grid; justify-items: center; gap: 6px; text-align: center; min-width: 0; }
.person figcaption { display: grid; gap: 1px; font-size: 13.5px; overflow-wrap: anywhere; }
.person small { color: var(--muted); font-size: 12px; }
.person-up { margin: 0; }
.person-up label.btn { position: relative; cursor: pointer; }
.person-up input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.person-up label.busy { opacity: .6; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
@media (max-width: 600px) {
  .tenant-who { gap: 8px; }
  .tenant-who span:last-child { min-width: 8.5em; }
  tr:has(.tenant-who) > td:not(:first-child) { white-space: nowrap; }
  .avatar { width: 36px; height: 36px; }
  .avatar.none { font-size: 8.5px; padding: 2px; }
}
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; object-fit: cover;
  background: var(--surface-2); display: block; }
.avatar.none { display: grid; place-items: center; text-align: center; font-size: 10px;
  line-height: 1.15; color: var(--muted); font-weight: 600; padding: 4px;
  border: 1px dashed var(--muted); text-decoration: none; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.doc { margin: 0; display: grid; gap: 6px; align-content: start; min-width: 0; }
.doc img, .filebox {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2); display: block;
}
.filebox { display: grid; place-items: center; text-decoration: none; font-weight: 600; font-size: 14px; }
.doc figcaption { display: grid; gap: 2px; font-size: 13.5px; }
.doc small { color: var(--muted); font-size: 12px; }
.plain { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; font-size: 12.5px; }
.upload { border-top: 1px solid var(--line); padding-top: 14px; }

.gate { max-width: 460px; margin: 18vh auto 0; padding: 0 20px; display: grid; gap: 12px; }

.btn.wa { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn.quiet.wa { background: var(--surface); color: var(--ok); border-color: var(--line); }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* Receipts, statements and agreements: pages meant for tenants and paper. */
.paper-body { background: var(--surface-2); }
.paper-main { max-width: 760px; margin: 0 auto; display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr);
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.paper { background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 24px; display: grid; gap: 14px; min-width: 0; position: relative;
  grid-template-columns: minmax(0, 1fr); }
.paper h1 { font-size: 22px; }
.paper h2 { font-size: 15px; margin-top: 6px; }
.paper-head { display: flex; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  border-bottom: 2px solid var(--fg); padding-bottom: 12px; }
.paper-head .num { text-align: right; }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.big.bad { color: var(--bad); }
.lead { font-size: 16px; line-height: 1.6; }
.hi { color: var(--muted); font-weight: 500; }
.paper-table { font-size: 14px; }
.paper-table tfoot th { border-top: 2px solid var(--fg); border-bottom: none; font-size: 14px;
  color: var(--fg); text-transform: none; letter-spacing: 0; }
.paper-foot { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 14px; }
.signrow { display: flex; justify-content: flex-end; align-items: end; gap: 18px; }
.sig { border-top: 1px solid var(--fg); flex: 0 1 170px; min-width: 0; padding-top: 4px; font-size: 13px; text-align: center; }
/* The Pakka seal: bottom left, level with the signature line, stamped on
   a little crooked like a real rubber stamp. The same size on paper. */
.receipt-seal { width: 110px; height: 110px; flex: none; margin-right: auto; transform: rotate(-8deg); }
.waiting { margin: 0; }
/* On the agreement the seal is stamped over the end of the Licensor's
   signature line, so the line keeps its full width beside the Licensee's. */
.sealed { position: relative; }
.agreement-seal { position: absolute; right: 0; bottom: 14px; width: 96px; height: 96px;
  transform: rotate(-8deg); }
.revenue { border: 1px dashed var(--muted); width: 72px; height: 80px; display: grid; place-items: center;
  text-align: center; font-size: 11px; color: var(--muted); flex: none; }
.stamp-void { color: var(--bad); border: 2px solid var(--bad); border-radius: 8px; padding: 6px 10px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; justify-self: start; }
.paper.void .lead, .paper.void .paper-table { opacity: 0.55; }
.paper .paid { color: var(--ok); }
.btn .hi { color: inherit; opacity: 0.85; }
.paybox { display: grid; gap: 6px; background: var(--ok-soft); border-radius: 10px; padding: 14px; }
.big-btn { font-size: 16px; padding: 12px 18px; text-align: center; white-space: normal; }
.agreement { font-size: 15px; line-height: 1.65; }
.agreement .center { text-align: center; letter-spacing: 0.04em; text-transform: uppercase; }
.clauses { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.signatures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px 40px; margin-top: 28px; font-size: 13px; }
.signatures .line { border-top: 1px solid var(--fg); margin-bottom: 4px; height: 36px; }

@media print {
  @page { size: A4; margin: 16mm; }
  :root { color-scheme: light; --fg: #000; --muted: #444; --line: #bbb; --surface: #fff; }
  body, .paper-body { background: #fff; color: #000; }
  .noprint, .top, .banner, .crumbs { display: none !important; }
  .paper-main { padding: 0; max-width: none; }
  .paper { border: none; padding: 0; border-radius: 0; }
  .paybox { display: none; }
  .clauses li { break-inside: avoid; }
  .signatures { break-inside: avoid; }
  /* A test copy's receipt says so on paper too. */
  .banner.test { display: block !important; }
  .receipt-seal { width: 110px; height: 110px; transform: rotate(-8deg); }
  .agreement-seal { width: 96px; height: 96px; transform: rotate(-8deg); }
  .receipt-seal, .agreement-seal { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
}

@media (max-width: 560px) {
  .brand { order: 1; }
  .account { order: 1; }
  .who { order: 2; margin-left: auto; }
  nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .who span { display: none; }
  .paper { padding: 18px 16px; }
  .paper-head .num { text-align: left; }
  .kpis b { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Maintenance */
.maint-photo { display: block; max-width: 260px; margin: 6px 0; }
.maint-photo img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); display: block; }
.maint-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.maint-log li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.maint-log p { margin: 4px 0 0; }
.maint-log small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* Uploads */
.file-pick { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.pick { position: relative; cursor: pointer; overflow: hidden; }
.pick input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.upload-progress { width: 100%; max-width: 320px; height: 10px; }
.person-up { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* Paperwork */
.paperwork td { vertical-align: top; }
.paper-cell { display: grid; gap: 2px; text-decoration: none; color: inherit; min-width: 3.5em; }
.paper-cell small { color: var(--muted); font-size: 11.5px; line-height: 1.25; }
.paper-cell .chip { justify-self: start; }
