/* One warm light look: stone walls, deep green, brass fittings. Sizes in rem so the text-size button scales everything. */
:root {
  --bg: #f4f2ee; --surface: #fff; --ink: #1d2420; --muted: #4f5751; --line: #d6d0c4;
  --green: #1f4435; --brass: #a8853f; --on-green: #fff;
  --paid: #1d5e38; --part: #774f08; --due: #93302a;
  --paid-bg: #e2f0e6; --part-bg: #f8ecd2; --due-bg: #f7e0dd;
  --display: "Marcellus", Georgia, serif;
  --body: "Mulish", "Segoe UI", sans-serif;
  color-scheme: light;
  font-size: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.55 var(--body); }
.wrap { max-width: 1100px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; margin: 1.3rem 0 .5rem; }
p { margin: .25rem 0; }
.muted { color: var(--muted); font-size: .92rem; }
.big { font-size: 1.15rem; font-weight: 700; }
.error { color: var(--due); font-weight: 700; }
.error:empty, .note:empty { display: none; }
.note { background: var(--part-bg); padding: .5rem .75rem; font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.bar { background: var(--green); color: var(--on-green); border-bottom: 3px solid var(--brass); }
.bar .wrap { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; padding-block: .7rem; }
.brand { font: 1.6rem var(--display); color: inherit; text-decoration: none; }
.switch { display: flex; }
.switch button, .on-dark { background: transparent; color: var(--on-green); border-color: rgb(255 255 255 / .45); }
.switch button:first-child { border-radius: 4px 0 0 4px; }
.switch button:last-child { border-radius: 0 4px 4px 0; border-left: 0; }
.switch button[aria-pressed="true"] { background: var(--brass); border-color: var(--brass); color: #fff; }

button, input, select, textarea, .button {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid #b9b2a4; border-radius: 4px;
  padding: .55rem .9rem; min-width: 0; max-width: 100%; min-height: 2.75rem;
}
textarea { resize: vertical; font-size: .9rem; }
button, .button { cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
button:hover, .button:hover { border-color: var(--brass); }
.primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
.primary:hover { background: #2a5a46; }
.danger { background: var(--due); border-color: var(--due); color: #fff; }
.small { min-height: 2.3rem; padding: .3rem .7rem; font-size: .88rem; }
.link { background: none; border: 0; min-height: 0; padding: 0; color: var(--green); text-decoration: underline; font-weight: 600; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.end { justify-content: flex-end; }

main { padding-block: 1.6rem 3rem; display: flex; flex-direction: column; gap: 1rem; }
.notice { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; border: 1px solid var(--brass); background: var(--surface); padding: .6rem 1rem; }
.notice.warn { background: var(--part-bg); border-color: var(--part); font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 1.2rem 1.3rem; }

/* Home */
#home { display: flex; flex-direction: column; gap: 1rem; }
#home h1 + .muted { margin-top: -.6rem; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem; }
.card { background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.card:hover { border-color: var(--brass); box-shadow: 0 8px 24px rgb(29 36 32 / .12); }
.card svg { width: 100%; height: auto; display: block; background: #e7e2d7; border-bottom: 3px solid var(--brass); }
.card-body { padding: 1rem 1.2rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: .3rem 0 0; }
.figures dt { color: var(--muted); font-size: .85rem; }
.figures dd { margin: 0; font: 1.35rem var(--display); }
.counts { display: flex; flex-wrap: wrap; gap: .4rem; }
.go { color: var(--green); font-weight: 800; margin-top: .3rem; }
.tag { display: inline-block; font-weight: 700; font-size: .85rem; padding: .1rem .55rem; border-radius: 999px; }
.tag.paid { color: var(--paid); background: var(--paid-bg); }
.tag.part { color: var(--part); background: var(--part-bg); }
.tag.due { color: var(--due); background: var(--due-bg); }
.tag.vacant { color: var(--muted); background: #e7e3da; }
#taxPanel { border-left: 4px solid var(--brass); display: flex; flex-direction: column; gap: .3rem; }
#taxPanel strong { font-size: 1.2rem; }
.settings summary { cursor: pointer; font-weight: 700; }
.settings form { margin-top: 1rem; }

/* Property page */
.back { color: var(--green); font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.title { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: end; }
.months { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--line); padding: .5rem; }
.months > div { text-align: center; display: flex; flex-direction: column; align-items: center; }
.months strong { font: 1.35rem var(--display); }
.chunks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
.chunk { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--paid); padding: 1.1rem; display: flex; flex-direction: column; min-width: 0; }
.chunk.out { border-top-color: var(--brass); }
.chunk.pending { border-top-color: var(--due); }
.chunk > b { font: 1.9rem var(--display); margin-top: .3rem; }
.chunk ul { list-style: none; margin: .8rem 0; padding: 0; max-height: 17rem; min-height: 9rem; overflow-y: auto; border-top: 1px solid var(--line); flex: 1; }
.chunk li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.chunk li span { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.chunk li em { font-style: normal; font-weight: 800; white-space: nowrap; }
.acts { display: flex; flex-wrap: wrap; gap: .4rem; width: 100%; }

.clients { display: flex; flex-direction: column; gap: .8rem; margin-top: .6rem; }
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
.cell-acts { display: flex; gap: .4rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.print-only { display: none; }

dialog { width: min(600px, calc(100% - 20px)); max-height: 92vh; border: 0; border-top: 5px solid var(--brass); background: var(--bg); color: var(--ink); padding: 1.3rem; }
dialog.ask { width: min(460px, calc(100% - 20px)); }
dialog::backdrop { background: rgb(20 30 25 / .6); }
.head { display: flex; justify-content: space-between; gap: .75rem; align-items: start; margin-bottom: .9rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.fields label { display: flex; flex-direction: column; gap: .2rem; font-weight: 600; font-size: .95rem; min-width: 0; }
.wide { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border-radius: 999px; min-height: 2.3rem; padding: .25rem .9rem; font-weight: 600; }
.receipt { background: var(--surface); border: 1px dashed var(--muted); padding: 1rem; white-space: pre-wrap; font: .95rem/1.6 var(--body); margin: 0 0 .6rem; }
.status-line { margin: .4rem 0 1rem; }

/* People */
.people-panel { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; }
#people { display: flex; flex-direction: column; gap: 1rem; }
.people-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.person { background: var(--surface); border: 1px solid var(--line); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.person-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: start; }
.person h2 { font-size: 1.35rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.person .phone { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tag.role { background: #e6ece8; color: var(--green); }
.tag.you { background: var(--brass); color: #fff; }
.devices { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.devices li { display: flex; flex-wrap: wrap; gap: .4rem .8rem; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.devices li span { min-width: 0; flex: 1 1 12rem; }
.remove { color: var(--due); border-color: var(--due); }
.wide-note { grid-column: 1 / -1; }
.invite { flex-direction: column; align-items: stretch; background: var(--paid-bg); border-color: var(--paid); }
.roles { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.roles legend { font-weight: 700; margin-bottom: .4rem; }
.fields label.choice { flex-direction: row; gap: .7rem; align-items: start; background: var(--surface); border: 1px solid var(--line); padding: .7rem .8rem; cursor: pointer; font-weight: 400; }
.choice input { width: 1.3rem; height: 1.3rem; min-height: 0; margin-top: .15rem; flex: none; accent-color: var(--green); }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--muted); font-size: .88rem; }
.choice:has(input:checked) { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
/* View-only people see the records but no buttons that change them */
.view-only #addIn, .view-only #addOut, .view-only [data-pay], .view-only [data-remove], .view-only [data-remove-out],
.view-only #saveClient, .view-only #moveOut, .view-only #settingsForm button, .view-only label[for="restore"] { display: none !important; }

/* Sign-in page */
.who { font-weight: 600; }
.login { max-width: 30rem; padding-block: 2rem 3rem; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--brass); padding: 1.6rem 1.5rem; }
.login-card form, .login-card > div { display: flex; flex-direction: column; gap: .7rem; }
.login-card h1 { font-size: 1.9rem; }
.login-card label { font-weight: 700; margin-top: .4rem; }
.big-input { font-size: 1.4rem; padding: .7rem .9rem; letter-spacing: .03em; }
.code-input { letter-spacing: .5em; text-align: center; font-weight: 800; }
.wide-btn { width: 100%; min-height: 3.2rem; font-size: 1.1rem; }
.between { justify-content: space-between; }
.center { text-align: center; }
.dots { display: flex; justify-content: center; gap: 1rem; margin: .6rem 0; }
.dots i { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--green); }
.dots i.on { background: var(--green); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.keypad button { min-height: 3.6rem; font: 800 1.6rem var(--body); }
.keypad button:active { background: var(--paid-bg); }
#forgot, #notMe { align-self: center; margin-top: .4rem; }

@media (max-width: 820px) {
  .cards, .chunks, .people-list { grid-template-columns: minmax(0, 1fr); }
  .chunk ul { min-height: 0; }
  /* Client table becomes one card per unit */
  #clients thead { display: none; }
  #clients, #clients tbody, #clients tr, #clients td { display: block; }
  #clients tr { border-bottom: 2px solid var(--line); padding: .5rem 0; }
  #clients td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem .9rem; white-space: normal; text-align: right; }
  #clients td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  #clients td:last-child { justify-content: flex-end; }
  #clients td:last-child::before { content: none; }
}
@media (max-width: 480px) {
  .fields, .figures { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.7rem; }
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .months > div { grid-column: 1 / -1; grid-row: 1; }
  .bar .row, .switch { width: 100%; }
  .switch button, #textSize { flex: 1 1 auto; }
}
@media print {
  .bar, button, .button, .back, .notice, dialog, .months button { display: none !important; }
  body { background: #fff; font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chunks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chunk ul { max-height: none; overflow: visible; }
  .print-only { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
