/* Rentals — one stylesheet, no framework. */

:root {
  --bg: #f1f4f3;
  --surface: #ffffff;
  --ink: #17292d;
  --muted: #5b6b6e;
  --faint: #8a9799;
  --line: #d8dfdd;
  --line-soft: #e8edec;
  --accent: #1d6670;
  --accent-ink: #12474e;
  --accent-weak: #e2eeee;
  --attention: #9a5b0e;
  --attention-weak: #f6ecdc;
  --danger: #a3322a;
  --danger-weak: #f7e4e2;
  --ok: #2b7149;
  --ok-weak: #e1f0e6;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --rail: 232px;
  --space: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a1c;
    --surface: #182427;
    --ink: #e4ecea;
    --muted: #9fb0b0;
    --faint: #738485;
    --line: #2b3a3d;
    --line-soft: #223033;
    --accent: #5fb3bc;
    --accent-ink: #8ccfd6;
    --accent-weak: #1d3337;
    --attention: #e0a456;
    --attention-weak: #33291a;
    --danger: #e8877f;
    --danger-weak: #3a2321;
    --ok: #7cc79b;
    --ok-weak: #1d3326;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: var(--ink); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 520;
}
.nav a:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-weak); color: var(--accent-ink); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-group { margin-top: 18px; padding: 0 10px 6px; font-size: 12px; color: var(--faint); }
.nav .soon { opacity: 0.55; cursor: default; }
.nav .soon:hover { background: none; color: var(--muted); }
.nav .soon small { margin-left: auto; font-size: 11px; white-space: nowrap; }
.nav a { white-space: nowrap; }
.rail-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line-soft); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent-weak); color: var(--accent-ink); font-size: 12px; font-weight: 700;
}
.me-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.me-links { font-size: 12px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkish:hover { text-decoration: underline; }

.main { min-width: 0; padding: 28px 36px 64px; }
.page { max-width: 1180px; margin: 0 auto; }

/* ---------- Page header ---------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { margin-top: 6px; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* The property header: the street address is the title. */
.address-title { font-size: 32px; letter-spacing: -0.02em; font-weight: 700; }
.address-sub { margin-top: 4px; font-size: 16px; color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.facts strong { color: var(--ink); font-weight: 600; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 560; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0d1a1c; } }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-quiet { border-color: transparent; background: none; color: var(--accent); }
.btn-quiet:hover { background: var(--accent-weak); }
.btn-danger { color: var(--danger); }

/* ---------- Panels, stats ---------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-body { padding: 16px 18px; }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.stack, .grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-2 > .panel + .panel, .grid-2 > * + * { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 18px; }
.figure { padding: 16px 18px; }
.figure + .figure { border-left: 1px solid var(--line-soft); }
.figure-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.figure-label { font-size: 13px; color: var(--muted); }
.figure a { color: inherit; }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
.data th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data th.num { text-align: right; }
.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--bg); }
.data .primary { font-weight: 600; color: var(--ink); }
.data .primary:hover { color: var(--accent); }
.data .secondary { display: block; font-size: 13px; color: var(--muted); }
.data tr.is-off td { color: var(--faint); }
.data tr.editing td { background: var(--accent-weak); vertical-align: middle; }
.data td input, .data td select { min-height: 32px; padding: 4px 8px; font-size: 14px; }

.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty p { margin: 0 auto 14px; max-width: 52ch; }

/* ---------- Filters ---------- */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.filters input[type="search"] { flex: 1 1 240px; }
.filters select { flex: 0 0 auto; width: auto; }
.result-count { font-size: 13px; color: var(--muted); padding: 10px 14px; }
.htmx-request .result-count, .htmx-request.result-count { opacity: 0.5; }

/* ---------- Pills ---------- */

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--ok-weak); color: var(--ok); }
.pill-off { background: var(--line-soft); color: var(--muted); }
.pill-commercial { background: var(--attention-weak); color: var(--attention); }
.pill-residential { background: var(--accent-weak); color: var(--accent-ink); }

/* ---------- Forms ---------- */

input, select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
input[type="file"] { padding: 6px; }

.form { max-width: 760px; }
.form-section { padding: 20px 22px; }
.form-section + .form-section { border-top: 1px solid var(--line-soft); }
.form-section > h2 { margin-bottom: 4px; }
.form-section > .muted { margin-bottom: 16px; font-size: 14px; }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.field { grid-column: span 3; }
.field.wide { grid-column: 1 / -1; }
.field.third { grid-column: span 2; }
.field .label { display: block; margin-bottom: 5px; font-size: 13.5px; font-weight: 600; }
.field .help { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.field .errors { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--danger); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field .optional { font-weight: 400; color: var(--faint); }
.checks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.checks.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.checks label { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; font-weight: 450; }
.checks input { margin-top: 3px; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.radio-row { display: flex; gap: 18px; }
.radio-row label { display: flex; align-items: center; gap: 6px; }
.form-actions { display: flex; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line-soft); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }
.form-errors { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-weak); color: var(--danger); font-size: 14px; }

/* ---------- Messages ---------- */

.flash { margin-bottom: 18px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-weak); color: var(--ok); font-size: 14px; font-weight: 550; }
.flash.error { background: var(--danger-weak); color: var(--danger); }

/* ---------- Tabs (Files / Notes / History) ---------- */

.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line-soft); }
.tab {
  padding: 12px 10px 10px; border: 0; border-bottom: 2px solid transparent; background: none;
  font: inherit; font-size: 14px; font-weight: 560; color: var(--muted); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab-body { min-height: 120px; }
.loading { padding: 24px 18px; color: var(--faint); font-size: 14px; }

.file-list, .note-list, .history { list-style: none; margin: 0; padding: 0; }
.file-list li, .note-list li, .history li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.file-list li:last-child, .note-list li:last-child, .history li:last-child { border-bottom: 0; }
.file-icon { width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm); background: var(--accent-weak); color: var(--accent-ink); display: grid; place-items: center; font-size: 11px; font-weight: 700; overflow: hidden; }
.file-icon img { width: 100%; height: 100%; object-fit: cover; }
.grow { flex: 1; min-width: 0; }
.file-name { font-weight: 560; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: 10px; align-items: flex-start; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.inline-form > :first-child { flex: 1 1 220px; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.change { font-size: 13px; color: var(--muted); margin-top: 4px; }
.change b { color: var(--ink); font-weight: 560; }
.change del { color: var(--faint); }

/* ---------- Login ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; padding-bottom: 26px; font-size: 18px; }
.auth-card .panel-body { padding: 24px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; min-height: 42px; }

/* ---------- Mobile ---------- */

.mobile-bar { display: none; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding: 18px 16px 96px; }
  .address-title { font-size: 26px; }
  h1 { font-size: 22px; }
  .fields { grid-template-columns: 1fr; }
  .field, .field.third { grid-column: 1 / -1; }
  .checks.cols { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .hide-sm { display: none; }
  .filters select { flex: 1 1 40%; }
  .mobile-bar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 10;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .mobile-bar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); }
  .mobile-bar a[aria-current="page"] { color: var(--accent); }
  .mobile-bar svg { width: 22px; height: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.hide-lg { display: none; }
@media (max-width: 760px) { .hide-lg { display: block; } }

/* ---------- Phase 2 ---------- */
.owed { color: var(--danger); }
.credit { color: var(--ok); }
.nowrap { white-space: nowrap; }
.flash.warn { background: var(--attention-weak); color: var(--attention); }
.pager { border-top: 1px solid var(--line-soft); border-bottom: 0; justify-content: space-between; }
.data tr.voided td { color: var(--faint); }
.data tr.voided td:nth-child(3), .data tr.voided td:nth-child(4) { text-decoration: line-through; }
.balance-box .big-money { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin-top: 2px; }
.aging { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.aging b { color: var(--ink); font-weight: 600; }
.signup-code { font-size: 22px; font-weight: 700; letter-spacing: 0.08em; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }

/* "More" menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(23, 41, 45, 0.12);
}
.menu-list a { padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink); }
.menu-list a:hover { background: var(--bg); text-decoration: none; }

/* Report tables */
.report-total td { font-weight: 700; border-top: 1px solid var(--line); }
.report-section td { font-weight: 650; background: var(--bg); }
.subtle-indent td:first-child { padding-left: 28px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .grid-3 { grid-template-columns: 1fr; } }
.link-list { display: flex; flex-direction: column; }
.link-list a { display: block; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.link-list a:last-child { border-bottom: 0; }
.link-list a:hover { background: var(--bg); text-decoration: none; }
.link-list b { display: block; font-weight: 600; color: var(--accent-ink); }
.link-list span { display: block; font-size: 13px; color: var(--muted); }
.filters input[type="date"] { width: auto; flex: 0 0 auto; }
.data.batch td { vertical-align: top; }
.data.batch select, .data.batch input { min-height: 34px; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.45; }
.pdf-frame { width: 100%; height: 78vh; border: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--bg); }
.inline-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
