/* Self-hosted styles — system font stack, no external fonts or CDNs. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1d2630;
  --muted: #5d6b79;
  --line: #e4e8ee;
  --line-strong: #d4dae2;
  --brand: #1f6f5c;
  --brand-strong: #1a5e4e;
  --brand-ink: #ffffff;
  --brand-tint: #eaf3f0;
  --danger: #b3261e;
  --danger-tint: #fdecea;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --focus-ring: 0 0 0 3px rgba(31, 111, 92, .32);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --leading: 1.55;
  --font-head: 600;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: var(--leading);
}
a { color: var(--brand); }
.muted { color: var(--muted); }

/* Auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px;
}
.brand { margin: 0 0 4px; font-size: 20px; color: var(--brand); }
.card form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
input, select, textarea {
  font-size: 15px; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink); width: 100%; font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
select[multiple] { padding: 4px; }
button {
  font-size: 15px; padding: 10px 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--brand); color: var(--brand-ink); cursor: pointer; font-weight: 600;
  transition: background .12s ease, box-shadow .12s ease;
}
button:hover { background: var(--brand-strong); filter: none; }
button:active { background: var(--brand-strong); transform: translateY(0.5px); }
button:focus-visible, .btn:focus-visible, .actions a:focus-visible, .sidebar a:focus-visible {
  outline: none; box-shadow: var(--focus-ring);
}
.alert {
  background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2;
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}

/* App chrome */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 24px;
}
.topbar-brand { font-weight: 700; color: var(--brand); }
.topbar-nav { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.sep { color: var(--line); }
.inline { display: inline; }
button.link { background: none; color: var(--brand-strong); padding: 2px 4px; font-weight: 600; border-radius: var(--radius-sm); }
button.link:hover { text-decoration: none; background: var(--brand-tint); filter: none; }
button.link.danger { color: var(--danger); }
button.link.danger:hover { background: var(--danger-tint); color: var(--danger); }

.shell { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 53px); }
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; }
.sidebar a {
  display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.sidebar a:hover { background: var(--brand-tint); }
.sidebar a.active { background: var(--brand); color: var(--brand-ink); }
.content { padding: 24px; max-width: 960px; }

/* Page header */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
h1 { font-size: 22px; font-weight: var(--font-head); letter-spacing: -0.01em; line-height: 1.25; margin: 0; }
.btn {
  display: inline-block; background: var(--brand); color: var(--brand-ink);
  padding: 9px 14px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: background .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--brand-strong); filter: none; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.flash-ok { background: #e7f4ef; color: #15543f; border: 1px solid #b9e0d2; }
.flash-err { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2; }

/* Data table */
table.data { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.data th, table.data td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); font-size: 14px; }
table.data th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:last-child td { border-bottom: 0; }
.col-actions { width: 1%; }
.actions { display: flex; align-items: center; gap: var(--space-4); white-space: nowrap; min-height: 32px; }
.actions a, .actions form.inline { margin: 0; }
.actions a, .actions button.link { padding: 5px 9px; border-radius: var(--radius-sm); line-height: 1.2; text-decoration: none; }
.actions form.inline { display: inline-flex; }
.actions a:hover, .actions button.link:hover { background: var(--brand-tint); text-decoration: none; filter: none; }
.actions button.link.danger { color: var(--danger); }
.actions button.link.danger:hover { background: var(--danger-tint); color: var(--danger); }
/* Hairline pause before a destructive action — appears only when Delete/NSF is present. */
.actions form.inline:has(button.link.danger) { margin-left: var(--space-1); padding-left: 10px; border-left: 1px solid var(--line); }

.badge { display: inline-block; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; letter-spacing: .01em; line-height: 1.5; white-space: nowrap; }
.badge-vacant { background: #eef1f4; color: #51606e; }
.badge-occupied { background: #e7f4ef; color: #15543f; }
.badge-unavailable { background: #fdecea; color: var(--danger); }
.badge-ts      { background: #eef0fb; color: #3a3f8f; }
.badge-parking { background: #fdf6e3; color: #7a5a00; }
.badge-locker  { background: #f0eefa; color: #5a3f8f; }
.badge-draft { background: #eef1f4; color: #51606e; }
.badge-active { background: #e7f4ef; color: #15543f; }
.badge-ended { background: #fdf2e3; color: #8a5a12; }
.badge-terminated { background: #fdecea; color: var(--danger); }

/* Forms */
.form { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 24px; max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.form label.check input { width: auto; }
.err { color: var(--danger); font-size: 12px; }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 6px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-5); }
.kpi-value { font-size: 28px; font-weight: 700; }
.kpi-label { font-size: 13px; font-weight: 600; margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Lease statement + accounting UI */
.summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.actions-card { padding: 18px; margin-bottom: 18px; }
.actions-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.actions-bar:not(:last-child) { margin-bottom: 14px; }
.btn-sm { font-size: 13px; padding: 7px 11px; border: 0; border-radius: var(--radius-sm); background: var(--brand); color: var(--brand-ink); cursor: pointer; font-weight: 600; transition: background .12s ease, box-shadow .12s ease; }
.btn-sm:hover { background: var(--brand-strong); filter: none; }
.pay-form { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.pay-form .row { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.pay-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
h2.sub { font-size: 16px; font-weight: var(--font-head); letter-spacing: -0.005em; margin: var(--space-6) 0 var(--space-3); }
table.data tfoot th { background: #fafbfc; font-size: 13px; text-transform: none; color: var(--ink); border-top: 2px solid var(--line); }
.prewrap { white-space: pre-wrap; }
.btn-muted { background: #eef1f4; color: var(--ink); text-decoration: none; display: inline-block; border-radius: var(--radius-sm); }
.btn-muted:hover { background: #e3e7ec; filter: none; }

/* Maintenance: priority + status badges */
.pri-low { background: #eef1f4; color: #51606e; }
.pri-normal { background: #e8eef7; color: #33507a; }
.pri-high { background: #fdf2e3; color: #8a5a12; }
.pri-urgent { background: #fdecea; color: var(--danger); }
.mr-open { background: #e8eef7; color: #33507a; }
.mr-in_progress { background: #fdf2e3; color: #8a5a12; }
.mr-resolved { background: #e7f4ef; color: #15543f; }
.mr-closed { background: #eef1f4; color: #51606e; }
.mr-cancelled { background: #fdecea; color: var(--danger); }

.inline-assign { display: flex; align-items: flex-end; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; flex-wrap: wrap; }
.inline-assign label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.inline-assign select { min-width: 220px; }
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.comment.internal { background: #fcfbf3; border-color: #ece6c9; }
.c-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }

/* Tabs (timeshare sub-nav) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand-strong); border-bottom-color: var(--brand); }

/* Maintenance photos */
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* Lease cards */
.lease-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.lease-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.lease-card-head { padding: 16px 18px 14px; flex: 1; }
.lease-card-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.lease-card-property { font-size: 15px; font-weight: 700; margin: 6px 0 2px; }
.lease-card-unit { font-size: 12px; color: var(--muted); }
.lease-card-rent { font-size: 20px; font-weight: 700; white-space: nowrap; text-align: right; padding-top: 2px; }
.lease-card-tenant { font-size: 14px; margin: 8px 0 0; }
.lease-card-dates { font-size: 12px; color: var(--muted); margin-top: 6px; }
.lease-card-foot { border-top: 1px solid var(--line); padding: 10px 18px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: #fafbfc; }
.lc-spacer { flex: 1; }
.lc-action { background: none; border: 0; padding: 5px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--brand); }
.lc-action:hover { background: var(--bg); filter: none; }
.lc-primary { background: var(--brand); color: var(--brand-ink); }
.lc-primary:hover { filter: none; background: var(--brand-strong); }
.lc-danger { color: var(--danger); }

/* Lease detail page */
.ls-info-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; margin-bottom: 18px; }
.ls-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 24px; }
.ls-field-full { grid-column: 1 / -1; }
.ls-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
.ls-value { font-size: 14px; font-weight: 500; }
.kpi-alert { border-color: #f5c6c2; background: #fefbfb; }
.ls-pay-card { background: var(--card); border: 2px solid var(--brand); border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; }
.ls-pay-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.ls-pay-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.ls-pay-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.ls-pay-field input, .ls-pay-field select { margin: 0; }
.ls-pay-btn { background: var(--brand); color: var(--brand-ink); font-size: 14px; padding: 10px 20px; border: 0; border-radius: 8px; font-weight: 700; cursor: pointer; }
.ls-pay-btn:hover { filter: none; background: var(--brand-strong); }
.ls-actions-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.ls-section-head { display: flex; align-items: center; gap: 12px; margin: 24px 0 10px; border-bottom: 2px solid var(--line); padding-bottom: 8px; }
.ls-addcharge-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; }
.ls-addcharge-btn { background: #eef1f4; color: var(--ink); font-size: 14px; padding: 9px 18px; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; }
.ls-addcharge-btn:hover { background: #e3e7ec; filter: none; }
.ac-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.ac-fields { display: flex; flex-direction: column; gap: 12px; }
.ac-fields .ls-addcharge-btn { align-self: flex-start; margin-top: 4px; }
.ac-billcol { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@media (max-width: 760px) { .ac-grid { grid-template-columns: 1fr; } }
.ls-bill-cell { white-space: nowrap; }
.ls-bill-link { display: inline-block; font-size: 13px; text-decoration: none; margin-right: 8px; }
.ls-bill-link:hover { text-decoration: underline; }

/* Drag-and-drop file upload */
.dz-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.dz-field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.dz { width: 100%; }
.dz-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 2px dashed var(--line); border-radius: 10px; padding: 18px; cursor: pointer; color: var(--muted);
  background: #fafbfc; transition: border-color .15s, background .15s, color .15s; }
.dz-drop:hover { border-color: var(--brand); color: var(--ink); }
.dz-drop:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.dz.is-over .dz-drop { border-color: var(--brand); background: #e7f4ef; color: var(--brand); }
.dz.is-over .dz-preview { border-color: var(--brand); background: #e7f4ef; }
.dz-icon { color: var(--brand); }
.dz-prompt { font-size: 13px; }
.dz-browse { color: var(--brand); font-weight: 600; text-decoration: underline; }
.dz-hint { font-size: 11px; }
.dz-preview { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.dz-pv-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.dz-pv-head .dz-name { flex: 1; }
.dz-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dz-size { font-size: 12px; color: var(--muted); flex: none; }
.dz-pv-open { font-size: 12px; font-weight: 600; text-decoration: none; flex: none; }
.dz-pv-open:hover { text-decoration: underline; }
.dz-pv-body { background: #f4f5f7; display: flex; justify-content: center; align-items: flex-start; }
.dz-pv-img { max-width: 100%; max-height: 360px; object-fit: contain; display: block; }
.dz-pv-frame { width: 100%; height: 420px; border: 0; display: block; background: #fff; }
.dz-remove { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; flex: none; }
.dz-remove:hover { background: #fdecea; color: var(--danger); filter: none; }
.dz-remove:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.dz-error { color: var(--danger); font-size: 12px; margin-top: 6px; }

/* Compact dropzone (per-charge-row attach) */
.dz-mini { display: inline-flex; align-items: center; gap: 6px; }
.dz-mini.is-over .dz-mini-trigger { border-color: var(--brand); color: var(--brand); background: #e7f4ef; }
.dz-mini.is-over .dz-mini-chip { outline: 2px dashed var(--brand); outline-offset: 2px; border-radius: 6px; }
.dz-mini-trigger { background: none; border: 1px dashed var(--line); color: var(--muted); font-size: 12px;
  font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.dz-mini-trigger:hover { border-color: var(--brand); color: var(--brand); filter: none; background: #fafbfc; }
.dz-mini-chip { display: inline-flex; align-items: center; gap: 6px; }
.dz-mini-name { font-size: 12px; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dz-mini-remove { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.dz-mini-remove:hover { color: var(--danger); filter: none; }
.dz-mini-upload { background: var(--brand); color: #fff; border: 0; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.dz-mini-upload:hover { filter: none; background: var(--brand-strong); }
.dz-mini-trigger:focus-visible, .dz-mini-remove:focus-visible, .dz-mini-upload:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Utilities */
.num { text-align: right; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-ok { color: #15543f; font-weight: 600; }
.sidebar-sep { height: 1px; background: var(--line); margin: 8px 4px; }

/* List toolbar (search + stats) */
.list-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search-box input { width: 100%; padding-left: 36px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.list-stats { display: flex; gap: 18px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.list-stats strong { color: var(--ink); font-weight: 700; }

/* Tenant list */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex: none; letter-spacing: .02em; }
.tenant-cell { display: flex; align-items: center; gap: 11px; }
.tenant-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.tenant-email { font-size: 12px; color: var(--muted); line-height: 1.25; }
.tenants-table td { vertical-align: middle; white-space: nowrap; }
.tenants-table td:first-child { white-space: normal; }
.tenants-table th { vertical-align: middle; }
.unit-badge { display: inline-block; background: #eef1f4; color: #51606e; border-radius: 6px; padding: 2px 8px;
  font-size: 12px; font-weight: 500; text-decoration: none; margin: 1px 3px 1px 0; white-space: nowrap; }
.unit-badge:hover { background: #dde3ea; color: var(--ink); }
.badge-portal { background: #e7f4ef; color: #15543f; }
.badge-nologin { background: #eef1f4; color: #8a93a0; }
.empty-row { text-align: center; color: var(--muted); padding: 28px 14px !important; }

/* Rent roll */
.rr-kpis { grid-template-columns: repeat(4, 1fr); }
.rr-amount { font-size: 22px; }
.rr-cur { font-size: 11px; font-weight: 700; letter-spacing: .04em; opacity: .6; margin-left: 4px; }
.rr-table { table-layout: fixed; }
.rr-table th:nth-child(1), .rr-table td:nth-child(1) { width: 15%; }
.rr-table th:nth-child(2), .rr-table td:nth-child(2) { width: 23%; }
.rr-table th:nth-child(3), .rr-table td:nth-child(3) { width: 14%; }
.rr-table th:nth-child(4), .rr-table td:nth-child(4) { width: 18%; }
.rr-table th:nth-child(5), .rr-table td:nth-child(5) { width: 16%; }
.rr-table th:nth-child(6), .rr-table td:nth-child(6) { width: 14%; }
.rr-sub { font-size: 11px; margin-top: 3px; }
.rr-nudge { background: #fdf6e3; border: 1px solid #f0e3bf; color: #7a5a00; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; margin: 0 0 16px; }
.rr-prop-row td { background: #f0f4f8; border-top: 2px solid var(--line); border-bottom: 0; padding: 8px 14px; }
.rr-prop-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rr-prop-num { font-size: 13px; font-weight: 600; }
.rr-unit-cell { padding-left: 22px !important; }
.rr-unit-link { text-decoration: none; color: var(--ink); font-weight: 500; }
.rr-unit-link:hover { color: var(--brand); text-decoration: underline; }

@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar a { margin-bottom: 0; white-space: nowrap; }
}
