/* Manager app: navy rail shell + ledger content. Desktop-first, works on phones. */

body.app { font-size: var(--t-md); }
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }

/* Rail */
.rail { background: var(--shell); color: var(--shell-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 20px 12px; gap: 20px; }
.rail .wordmark { color: var(--shell-ink); padding: 0 8px; }
.rail .wordmark__mark { color: var(--shell-ink); --paper: var(--shell); }
.rail__bldg { display: grid; gap: 2px; padding: 12px; border: 1px solid var(--shell-2); border-radius: var(--r-1); background: rgba(255,255,255,.03); }
.rail__bldg .label-caps { color: var(--shell-ink-2); }
.rail__bldg strong { font-size: var(--t-md); line-height: 1.25; }
.rail__bldg a { color: var(--shell-ink-2); font-size: var(--t-sm); }
.rail nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--r-1); color: var(--shell-ink-2); text-decoration: none; font-weight: 600; }
.rail nav a:hover { background: var(--shell-2); color: var(--shell-ink); }
.rail nav a[aria-current="page"] { background: var(--paper); color: var(--ink); }
.rail nav a[aria-current="page"] .icon { color: var(--stamp); }
.rail nav a:focus-visible { box-shadow: 0 0 0 2px var(--shell), 0 0 0 4px var(--shell-ink); }
.rail__badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--owed-tint); color: var(--owed); font-size: 12px; font-weight: 800; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.rail__foot { margin-top: auto; display: grid; gap: 4px; padding: 12px 12px 0; border-top: 1px solid var(--shell-2); font-size: var(--t-sm); color: var(--shell-ink-2); }
.rail__foot a { color: var(--shell-ink-2); display: inline-flex; gap: 8px; align-items: center; min-height: 40px; text-decoration: none; }
.rail__foot a:hover { color: var(--shell-ink); }

/* Main */
.main { min-width: 0; padding: 32px 40px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--rule); }
.page-head h1 { font-size: var(--t-3xl); }
.page-head p { color: var(--ink-2); margin-top: 4px; }
.page-head__actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.section-title { font-family: var(--font-cond); font-size: var(--t-xl); font-weight: 800; margin-bottom: 12px; }

/* Ledger totals: one receipt-style totals line, not metric cards */
.totals { display: grid; grid-template-columns: 1.4fr 1fr 1fr; background: var(--slip); border: 1px solid var(--rule); }
.totals > div { padding: 20px 24px; border-right: 1px solid var(--rule); display: grid; gap: 6px; align-content: start; }
.totals > div:last-child { border-right: 0; }
.totals .amount { font-size: var(--t-4xl); }
.totals .of { color: var(--ink-2); font-size: var(--t-sm); }
.totals .of .num { font-weight: 700; color: var(--ink); }
.totals__split { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--t-sm); color: var(--ink-2); margin-top: 4px; }
.totals__split span { display: inline-flex; gap: 6px; align-items: center; }

/* Entrance map: every apartment as a cell, the buzzer panel at a glance */
.entrance { border: 1px solid var(--rule); border-top: 0; background: var(--slip); padding: 16px 24px 20px; }
.entrance__head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.entrance__legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--t-sm); color: var(--ink-2); }
.entrance__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cellkey { width: 14px; height: 14px; display: inline-block; border: 1px solid var(--ink-3); }
.entrance__cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; }
.cell { position: relative; height: 44px; display: grid; place-items: center; font-family: var(--font-cond); font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums; border: 1px solid var(--rule); background: var(--slip); color: var(--ink); cursor: pointer; padding: 0; border-radius: 0; }
.cell:hover { border-color: var(--ink-2); }
.cell .icon { position: absolute; top: 3px; right: 3px; width: 11px; height: 11px; stroke-width: 2.5; }
.cell--paid, .cellkey--paid { background: var(--paid-mark); border-color: var(--paid-mark); color: #fff; }
.cell--cash, .cellkey--cash { background: var(--paid-tint); border-color: var(--paid-mark); color: var(--paid); }
.cell--partial, .cellkey--partial { background: repeating-linear-gradient(135deg, var(--owed-tint) 0 5px, var(--slip) 5px 10px); border-color: var(--owed-mark); border-style: dashed; color: var(--owed); }
.cell--owed, .cellkey--owed { background: var(--slip); border-color: var(--owed-mark); color: var(--owed); }

/* Filters bar */
.filters { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 32px 0 12px; }
.filters .search { position: relative; width: min(280px, 100%); }
.filters .search .input { min-height: 40px; padding-left: 38px; font-size: var(--t-md); }
.filters .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-2); }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.table td.actions { text-align: right; white-space: nowrap; }
.owed-num { color: var(--owed); font-weight: 700; }
.table tr.is-flash td { animation: rowflash 1.6s var(--ease-out); }
@keyframes rowflash { from { background: var(--paid-tint); } to { background: transparent; } }

/* Toast-like confirmation (inline, not floating chrome) */
.flash { margin-bottom: 16px; }

/* Two-column work layout (setup, payments) */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.split--wide-left { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.sticky { position: sticky; top: 24px; }

/* Onboarding checklist */
.progress { height: 8px; background: var(--paper-deep); border: 1px solid var(--rule); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--paid-mark); transition: width .6s var(--ease-out); }
.steps { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); background: var(--slip); }
.step { display: grid; grid-template-columns: 44px 1fr auto; gap: 16px; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--rule); }
.step:last-child { border-bottom: 0; }
.step__mark { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--ink-3); font-family: var(--font-cond); font-weight: 800; font-size: 1.125rem; color: var(--ink-2); }
.step--done .step__mark { background: var(--paid-mark); border-color: var(--paid-mark); color: #fff; }
.step--current { background: #FBF8EF; }
.step--current .step__mark { border-color: var(--stamp); color: var(--stamp); }
.step h3 { font-size: var(--t-lg); }
.step p { color: var(--ink-2); font-size: var(--t-sm); margin-top: 2px; }
.step--done h3 { color: var(--ink-2); }

/* Audit trail */
.trail { list-style: none; margin: 0; padding: 0; position: relative; }
.trail li { position: relative; padding: 0 0 18px 28px; }
.trail li::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: -8px; width: 1px; background: var(--rule); }
.trail li:last-child::before { display: none; }
.trail li::after { content: ""; position: absolute; left: 2px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--slip); border: 2px solid var(--stamp); }
.trail time { display: block; font-size: var(--t-sm); color: var(--ink-2); }
.trail .who { font-weight: 700; }
.trail li.struck .what { text-decoration: line-through; text-decoration-color: var(--error); color: var(--ink-2); }
.trail li.struck::after { border-color: var(--ink-3); }

/* Email preview (reminders) */
.letter { background: #fff; border: 1px solid var(--ink-3); max-width: 600px; }
.letter__meta { padding: 14px 24px; border-bottom: 1px solid var(--rule-soft); font-size: var(--t-sm); color: var(--ink-2); display: grid; gap: 2px; }
.letter__meta b { color: var(--ink); font-weight: 700; }
.letter__body { padding: 28px 24px 32px; display: grid; gap: 14px; font-size: var(--t-md); line-height: 1.6; }
.letter__amount { padding: 16px; background: var(--paper); border: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.letter__foot { padding: 16px 24px; border-top: 1px solid var(--rule-soft); font-size: 13px; color: var(--ink-3); }

/* Bulk paste preview */
.paste-preview { max-height: 420px; overflow: auto; }
.paste-preview .input { min-height: 36px; padding: 4px 10px; font-size: var(--t-md); width: 110px; }
.row-error td { background: var(--error-tint); }

/* Login */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth__side { background: var(--shell); color: var(--shell-ink); padding: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth__side .wordmark { color: var(--shell-ink); }
.auth__side .wordmark__mark { --paper: var(--shell); }
.auth__quote { font-family: var(--font-cond); font-size: var(--t-3xl); font-weight: 800; line-height: 1.1; max-width: 16ch; }
.auth__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; color: var(--shell-ink-2); }
.auth__list li { display: flex; gap: 10px; align-items: flex-start; }
.auth__list .icon { color: var(--shell-ink); margin-top: 3px; }
.auth__main { display: grid; place-items: center; padding: 40px 24px; }
.auth__card { width: min(400px, 100%); display: grid; gap: 20px; }
.auth__card h1 { font-size: var(--t-3xl); }
.auth__card > p { color: var(--ink-2); }

@media (max-width: 1100px) {
  .split, .split--wide-left { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 8px 12px; z-index: 20; }
  .rail__bldg, .rail__foot { display: none; }
  .rail nav { width: 100%; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .rail nav ul { display: flex; gap: 4px; }
  .rail nav a { white-space: nowrap; min-height: 40px; }
  .main { padding: 24px 16px 48px; }
  .page-head h1 { font-size: var(--t-2xl); }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals > div:first-child { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--rule); }
  .totals > div { padding: 16px; }
  .totals .amount { font-size: var(--t-3xl); }
  .entrance { padding: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth__side { padding: 20px 16px; }
  .auth__quote, .auth__list { display: none; }
  .step { grid-template-columns: 40px 1fr; padding: 16px; }
  .step > :last-child { grid-column: 2; justify-self: start; }
  /* Ledger table becomes stacked rows on phones */
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; }
  .table--stack tr { padding: 12px 16px; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; }
  .table--stack td { padding: 0; border: 0; }
  .table--stack td[data-l]::before { content: attr(data-l) ": "; color: var(--ink-2); font-weight: 500; }
  .table--stack td.apt { grid-row: span 2; font-size: 1.5rem; min-width: 2ch; }
  .table--stack td.num { text-align: left; }
  .table--stack td.hide-sm { display: none; }
  .table--stack td.actions { grid-column: 1 / -1; text-align: left; margin-top: 6px; }
  .table--stack tfoot { display: none; }
}

/* Fixes from the render round */
.shell { grid-template-columns: 248px minmax(0, 1fr); }
.shell > * { min-width: 0; }
.rail__bldg a { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.filters .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.table td.actions, .table td.when { white-space: nowrap; }
@media (max-width: 1360px) { .table .hide-md { display: none; } }
@media (max-width: 900px) { .shell { grid-template-columns: minmax(0, 1fr); } }
.rail nav a, .rail__bldg { border-radius: 0; }
@media (max-width: 900px) {
  .rail nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}
.rail__select { width: 100%; min-height: 40px; margin: 2px 0 4px; padding: 6px 32px 6px 10px; background: var(--shell); color: var(--shell-ink); border: 1px solid var(--shell-ink-2); border-radius: var(--r-1); font-weight: 700; font-size: var(--t-md); appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23E9E5D8' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.rail__select:focus-visible { box-shadow: 0 0 0 2px var(--shell), 0 0 0 4px var(--shell-ink); }
.rail__select option { color: var(--ink); background: var(--slip); }
/* Company overview */
.pct { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; min-width: 140px; }
.pct .progress { height: 6px; }
body.has-demo-bar .rail { padding-bottom: 80px; }
@media (max-width: 900px) { body.has-demo-bar .rail { padding-bottom: 10px; } }

/* Auth pages */
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--stamp); font: inherit; font-size: var(--t-sm); font-weight: 600; text-decoration: underline; text-underline-offset: .18em; cursor: pointer; }
.auth__demo { padding-top: 16px; border-top: 1px solid var(--rule); }
.auth__card--wide { width: min(520px, 100%); }
.er__icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; }
.l-consent { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.l-consent input { margin-top: 2px; }
.choices--stack { flex-direction: column; align-items: stretch; }
.choices--stack .choice { width: 100%; }

/* Platform admin: same shell, marked so staff never confuse it with a customer account */
.rail--admin { border-top: 4px solid var(--owed-mark); }
.rail--admin .rail__bldg { border-color: var(--owed-mark); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px dashed var(--rule-soft); margin: 0; font-size: var(--t-md); }
.kv dt { color: var(--ink-2); }
.lead-msg { margin-top: 8px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--rule-soft); font-size: var(--t-md); white-space: pre-wrap; }
