:root {
    color-scheme: light;
    --ink: #172b26;
    --muted: #71817b;
    --green: #15765b;
    --green-dark: #105d48;
    --green-pale: #e7f3ee;
    --line: #e7ece9;
    --surface: #fff;
    --page: #f6f8f6;
    --danger: #b54747;
    font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--page); font-size: 14px; }
a { color: inherit; text-decoration: none; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 max(calc((100vw - 1200px) / 2), 32px); }
.topbar-row { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.user-menu { display: flex; flex: 0 0 auto; align-items: center; gap: 14px; margin-left: auto; }
.user-name { max-width: 200px; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.main-nav { display: flex; gap: 4px; margin: 0 -14px 0 15px; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a { flex: 0 0 auto; padding: 12px 14px 13px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
.main-nav a:hover, .main-nav a.active { color: var(--green); }
.main-nav a.active { border-bottom-color: var(--green); }
.brand { display: flex; flex: 0 0 auto; align-items: center; }
.brand img { display: block; width: 190px; height: auto; }
.tenant-context { display: flex; min-width: 0; flex: 1 1 auto; flex-direction: column; justify-content: center; gap: 3px; }
.tenant-context span { color: var(--green); font-size: 9px; font-weight: 700; letter-spacing: 1px; }
.tenant-context strong { overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.tenant-context > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.tenant-context.has-logo { flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; }
.tenant-logo { width: 36px; height: 36px; flex: none; border-radius: 6px; object-fit: contain; }
.nav-button { border: 0; padding: 8px 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
.nav-button:hover, .text-button:hover { color: var(--green); }
.page { max-width: 1200px; margin: 0 auto; padding: 42px 32px 72px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif; letter-spacing: -.5px; }
h1 { margin-bottom: 7px; font-size: 31px; line-height: 1.2; }
h2 { margin-bottom: 5px; font-size: 18px; }
h3 { margin-bottom: 6px; font-size: 16px; }
.eyebrow { margin-bottom: 9px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.3px; }
.muted, .stat-note { color: var(--muted); }
.page-heading .muted, .section-heading .muted { margin-bottom: 0; }
.button { display: inline-flex; min-height: 42px; justify-content: center; align-items: center; gap: 8px; border: 1px solid var(--green); border-radius: 7px; padding: 0 16px; background: var(--green); color: white; font: 600 13px "Avenir Next", Avenir, "Segoe UI", sans-serif; cursor: pointer; transition: background .15s, border-color .15s; }
.button:hover { background: var(--green-dark); border-color: var(--green-dark); }
.button:disabled, .button:disabled:hover { border-color: #b5c4bd; background: #b5c4bd; cursor: not-allowed; }
.button-secondary { background: white; color: var(--ink); border-color: var(--line); }
.button-secondary:hover { color: var(--green); background: #f7fbf9; border-color: #b5d7ca; }
.button-full { width: 100%; margin-top: 4px; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 24px; }
.stats-four { grid-template-columns: repeat(4, 1fr); }
.stats-five { grid-template-columns: repeat(5, 1fr); }
.net-cash-card { border-color: #b5d7ca; background: var(--green-pale); }
.cash-row td { background: var(--green-pale); }
@media (max-width: 1100px) { .stats-five { grid-template-columns: repeat(3, 1fr); } }
.stat-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 6px #203b2e08; }
.stat-card { display: flex; flex-direction: column; min-height: 154px; padding: 21px 23px; }
.stat-label { color: var(--muted); font-weight: 600; }
.stat-card strong { margin: 10px 0 12px; font: 800 29px "Avenir Next", Avenir, "Segoe UI", sans-serif; letter-spacing: -1px; }
.stat-card a, .text-link { color: var(--green); font-size: 12px; font-weight: 700; }
.stat-note { margin-top: auto; font-size: 12px; }
.panel { padding: 23px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 12px; color: #788780; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 700; letter-spacing: .75px; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 12px; border-bottom: 1px solid #eef1ef; vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.status { display: inline-block; border-radius: 20px; padding: 5px 9px; background: #f0f2f1; color: #56635e; font-size: 10px; font-weight: 700; }
.status-paid { background: #e5f4ed; color: #15714f; }
.status-partial { background: #fff3dc; color: #9a6a13; }
.status-overdue { background: #fae9e7; color: #aa4841; }
.status-due { background: #edf2f7; color: #536e88; }
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 38px 16px 30px; text-align: center; }
.empty-state p { margin-bottom: 18px; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 12px; border-radius: 50%; background: var(--green-pale); color: var(--green); font-size: 22px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 315px; align-items: start; gap: 20px; }
.directory-panel { min-width: 0; }
.homeowner-modal[hidden], .homeowner-modal:not([open]) { display: none !important; }
.homeowner-modal { width: min(720px, calc(100vw - 32px)); max-width: none; max-height: min(90vh, 900px); overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 26px; background: var(--surface); color: var(--ink); box-shadow: 0 18px 60px #10281d38; }
.homeowner-modal::backdrop { background: #10281d80; }
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.modal-heading h2 { margin-bottom: 4px; }
.modal-heading .muted { margin: 0; font-size: 13px; }
.modal-close { width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 25px; line-height: 1; cursor: pointer; }
.modal-close:hover { background: var(--page); color: var(--ink); }
.homeowner-modal .form-actions { margin-top: 6px; }
.homeowner-modal .form-actions .button { min-width: 110px; }
.detail-form { margin-top: 18px; }
.detail-form .button { align-self: flex-start; }
.opening-balance-panel { margin-bottom: 20px; }
.payment-history-panel { margin-bottom: 20px; }
.voided-row td { color: var(--muted); }
.voided-row td strong { text-decoration: line-through; }
.category-add { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 16px; }
.category-add label { flex: 1; }
.payee-merge { display: flex; align-items: center; gap: 8px; }
.payee-merge select { min-width: 160px; }
.import-modal { width: min(900px, calc(100vw - 32px)); }
.import-mapping-table select { min-width: 200px; }
.import-summary { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--page); }
.import-summary p { margin: 0; }
.import-issues { max-height: 320px; overflow-y: auto; }
.detail-panel + .detail-panel { margin-top: 20px; }
.advance-quote { min-height: 24px; }
.advance-quote-summary { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--page); }
.advance-quote-summary dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.advance-quote-summary dd { margin: 0; }
.opening-balance-panel h3 { margin: 20px 0 10px; }
.payment-entry-panel { margin-bottom: 20px; }
.dues-panel + .dues-panel { margin-top: 20px; }
.dues-panel tfoot td { border-top: 2px solid var(--line); }
.payment-entry-panel .inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.payment-entry-panel .inline-form label { display: grid; gap: 6px; min-width: 220px; }
.payment-allocation-list { display: grid; max-width: 720px; margin: 12px 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.payment-allocation-header, .payment-allocation-option { display: grid; grid-template-columns: 14px minmax(0, 1fr) 110px 130px; align-items: center; gap: 12px; padding: 7px 12px; }
.payment-allocation-header { background: var(--page); color: #788780; font-size: 10px; font-weight: 700; letter-spacing: .75px; text-transform: uppercase; }
.payment-allocation-option { border-top: 1px solid var(--line); font-weight: 500; cursor: pointer; }
.payment-allocation-option:hover { background: var(--page); }
.payment-allocation-option input[type="checkbox"] { width: 14px; height: 14px; margin: 0; padding: 0; accent-color: var(--green); }
.payment-allocation-option input[type="number"] { height: 32px; text-align: right; }
.allocation-remaining, .payment-allocation-header span:nth-child(3), .payment-allocation-header span:nth-child(4) { text-align: right; }
.allocation-remaining { color: var(--muted); }
#payment-allocation-total.allocation-mismatch { color: #aa4841; }
.homeowner-actions { display: flex; justify-content: flex-end; gap: 12px; }
.homeowner-modal input[type="file"] { height: auto; min-height: 40px; padding: 8px; }
.directory-search { max-width: 420px; margin-bottom: 4px; }
.search-status { min-height: 16px; margin: 0 0 8px; font-size: 12px; }
tr[hidden] { display: none; }
.form-panel h2 { margin-bottom: 4px; }
.form-panel > .muted { margin-bottom: 20px; font-size: 13px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; color: #34443e; font-size: 12px; font-weight: 600; }
input, select { width: 100%; min-width: 0; height: 40px; border: 1px solid #dfe6e2; border-radius: 6px; padding: 0 10px; outline: none; background: white; color: var(--ink); font: 400 13px "Avenir Next", Avenir, "Segoe UI", sans-serif; }
input:focus, select:focus { border-color: #69a98e; box-shadow: 0 0 0 3px #15765b18; }
input::placeholder { color: #a5b0aa; }
.optional, .field-hint { color: #91a099; font-weight: 400; }
.field-hint { font-size: 11px; }
.stack-form .field-hint { display: block; margin-top: 5px; }
.field-error { margin: -8px 0 0; color: var(--danger); font-size: 11px; }
.stack-form .field-error { margin-top: -7px; }
.alert { margin-bottom: 18px; border-radius: 7px; padding: 12px 15px; }
.alert-success { background: #e7f5ed; color: #176444; }
.alert-error { background: #fbecea; color: #9f3934; }
.alert-warning { background: #fff3dc; color: #7a5410; }
.profile-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.profile-notice p { margin: 2px 0 0; }
.plain-fieldset { display: flex; min-width: 0; flex-direction: column; gap: 12px; margin: 0; padding: 0; border: 0; }
.plain-fieldset:disabled { opacity: .55; }
.action-cell { text-align: right; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--green); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.system-table { margin-bottom: 20px; }
.check-label { flex-direction: row; align-items: center; }
.check-label input { width: 16px; height: 16px; }
.loading-screen { display: grid; min-height: 100vh; place-items: center; color: var(--muted); }
.narrow-page { max-width: 740px; }
.back-link { display: inline-block; margin-bottom: 17px; color: var(--green); font-size: 13px; font-weight: 600; }
.edit-panel { padding: 30px; }
.edit-panel h1 { font-size: 26px; }
.edit-panel > .muted { margin-bottom: 24px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.create-charge-panel { margin-bottom: 20px; }
.rate-panel { margin-bottom: 20px; }
.logo-panel { margin-bottom: 20px; }
.logo-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; }
.logo-preview { display: grid; width: 160px; height: 110px; place-items: center; border: 1px dashed var(--line); border-radius: 8px; background: var(--page); }
.logo-preview img { max-width: 140px; max-height: 90px; object-fit: contain; }
.logo-editor .inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.logo-editor input[type="file"] { height: auto; min-height: 40px; padding: 8px; }
.profile-panel .stack-form, .profile-panel fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.profile-panel fieldset, .profile-panel .form-actions { grid-column: 1 / -1; }
.profile-panel legend { grid-column: 1 / -1; }
.sub-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: -12px 0 28px; border-bottom: 1px solid var(--line); }
.sub-tab { margin-bottom: -1px; padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.sub-tab:hover { color: var(--ink); }
.sub-tab.active { border-bottom-color: var(--green); color: var(--green); }
.rate-table th { white-space: normal; vertical-align: bottom; }
.rate-table .wrap-cell { min-width: 120px; white-space: normal; overflow-wrap: anywhere; }
.rate-table .homeowner-actions { justify-content: flex-start; margin-top: 6px; }
.text-button.download-rate-document { padding: 0; color: var(--green); text-decoration: underline; }
.charge-form { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1.2fr auto; align-items: end; gap: 13px; }
.charge-form .button { min-height: 40px; white-space: nowrap; }
.charge-form .field-error { margin-top: 0; }
.empty-inline { padding: 8px 0 3px; color: var(--muted); }
.empty-inline a { margin-left: 5px; color: var(--green); font-weight: 700; }
.payment-form { display: flex; align-items: center; gap: 6px; }
.payment-form input { width: 100px; height: 34px; font-size: 12px; }
.payment-form input[type="text"] { width: 95px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 0, #e2f1e9, var(--page) 55%); }
.login-panel { width: min(100%, 410px); padding: 34px; }
.login-brand { margin-bottom: 34px; }
.login-brand img { width: min(100%, 300px); }
.login-panel h1 { font-size: 27px; }
.login-panel > .muted { margin-bottom: 25px; }
.login-panel .alert { margin-bottom: 18px; }

@media (max-width: 900px) {
    .content-grid { grid-template-columns: 1fr; }
    .form-panel { order: -1; }
    .charge-form { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
    .topbar { padding: 0 16px; }
    .topbar-row { flex-wrap: wrap; gap: 8px 16px; padding: 10px 0 4px; }
    .tenant-context { order: 3; flex-basis: 100%; }
    .user-menu { gap: 10px; }
    .user-name { display: none; }
    .main-nav { margin: 0 -16px; padding: 0 2px; }
    .main-nav a { padding: 10px 12px 11px; font-size: 13px; }
    .brand img { width: 154px; }
    .page { padding: 28px 16px 48px; }
    h1 { font-size: 26px; }
    .page-heading { align-items: flex-start; }
    .page-heading > .button, .page-actions .button { min-height: 38px; padding: 0 10px; font-size: 11px; }
    .stats { grid-template-columns: 1fr; gap: 11px; }
    .stat-card { min-height: 130px; }
    .panel { padding: 17px; }
    .homeowner-modal { padding: 18px; }
    .profile-panel .stack-form, .profile-panel fieldset { grid-template-columns: 1fr; }
    .payment-allocation-header, .payment-allocation-option { grid-template-columns: 14px minmax(0, 1fr) 90px 100px; gap: 8px; }
    .charge-form { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
    .payment-form { min-width: 255px; }
}

/* Cases */
.cases-panel .inline-form, .case-category-form, #case-category-new, #case-attachment-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
.cases-panel .inline-form label, #case-attachment-form label, .case-category-form label:not(.check-label), #case-category-new label { display: grid; gap: 6px; min-width: 200px; }
.case-status-filters { display: flex; flex-wrap: wrap; gap: 8px; }

/* Construction permits: the fee, bond and settlement forms, attachments and kinds of work lay out like the case forms. */
#permit-fee-form, #permit-bond-form, #permit-settle-form, #permit-attachment-form, .permit-type-form, #permit-type-new { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
#permit-fee-form label, #permit-bond-form label, #permit-settle-form label, #permit-attachment-form label,
.permit-type-form label:not(.check-label), #permit-type-new label { display: grid; gap: 6px; min-width: 160px; }
.case-facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 16px 0 24px; }
.case-facts dt { color: #56635e; font-weight: 700; }
.case-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.case-facts small, .case-event small { display: block; color: #56635e; }
.case-timeline { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 14px; }
.case-event { border-left: 3px solid #dfe5e2; padding-left: 10px; }
.case-event p { margin: 6px 0 0; white-space: pre-wrap; }

/* A column of separate cards, one per section (the HOA subscription page). */
.panel-stack { display: grid; gap: 20px; align-content: start; min-width: 0; }
.panel-stack > .panel .case-facts { margin-bottom: 0; }
/* Cards shrink to the column, so a wide table scrolls inside its card instead of widening the page. */
.panel-stack > .panel { min-width: 0; }

/* Agents: the add form under the list, and one block per release. */
.agent-new-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 16px; }
.agent-new-form label { display: grid; gap: 6px; min-width: 240px; }
.release { padding: 16px 0; border-top: 1px solid var(--line); }
.release:first-of-type { border-top: 0; padding-top: 0; }
