/* Louisa — finance module (billing, payments, deposits, ledger, owners, reports). Builds on app.css tokens. */

/* Month picker */
.fin-month { display: inline-flex; align-items: center; height: 36px; background: #fff; border: 1px solid #cfd7e3; border-radius: 9px; box-shadow: var(--sh-1); overflow: hidden; }
.fin-month-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 100%; color: #475467; }
.fin-month-btn:hover { background: #f4f7fb; color: var(--ink); }
.fin-month-f { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; height: 100%; border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2); color: var(--muted); }
.fin-month-f input[type=month], .toolbar .fin-month-f input[type=month] { border: 0; box-shadow: none; height: 32px; min-width: 0; width: 150px; padding: 0 4px; font-weight: 600; color: var(--ink); background: transparent; }
.fin-month-f input[type=month]:focus { box-shadow: none; }

/* Toolbar helpers */
.toolbar .grow { flex: 1; }
.toolbar form.row { gap: 8px; flex-wrap: wrap; }
.toolbar .search input { min-width: 220px; }
.seg .n { display: inline-block; margin-left: 5px; font-size: 11.5px; color: var(--subtle); font-weight: 600; }
.seg a.on .n { color: var(--muted); }
.fin-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; flex: 1 1 520px; }
.fin-filters.wide { flex-basis: 100%; justify-content: flex-start; }
.fin-filters .search, .toolbar .fin-filters .search { flex: 2 1 220px; }
.fin-filters .search input, .toolbar .fin-filters .search input { width: 100%; min-width: 0; height: 36px; }
.fin-filters select, .fin-filters input[type=date], .fin-filters input[type=month] { width: auto; min-width: 140px; max-width: 230px; height: 36px; flex: 0 1 auto; }
.fin-filters.wide select { flex: 1 1 140px; }

/* Consistent spacing between stacked cards on finance pages (core .card + .card resets it) */
.fin .stack > .card + .card, .fin .stack > * + .card, .fin .stack > .card + * { margin-top: 16px; }

/* Pager */
.fin-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line-2); font-size: 13px; flex-wrap: wrap; }
.fin-pages { display: flex; gap: 4px; align-items: center; }
.fin-pages a, .fin-pages span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: 600; color: #344054; font-size: 13px; }
.fin-pages a { border: 1px solid var(--line); background: #fff; }
.fin-pages a:hover { border-color: #b8c3d3; color: var(--ink); }
.fin-pages .on { background: var(--primary); color: #fff; }
.fin-pages .off { color: var(--subtle); border: 1px solid var(--line-2); }
.fin-pages .gap { min-width: 16px; color: var(--subtle); }

/* KPI extras */
.fin-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.fin-kpis.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.fin-kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi .kpi-foot { margin-top: 8px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.kpi .kpi-foot b { color: var(--ink); font-weight: 600; }
.kpi-value.red { color: var(--red); } .kpi-value.green { color: var(--green); } .kpi-value.blue { color: var(--primary); } .kpi-value.teal { color: var(--teal); }

/* Method chips & tiles */
.fin-method { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #344054; white-space: nowrap; }
.fin-method .ic { color: var(--muted); }
.fin-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.fin-tile { display: flex; gap: 12px; align-items: center; padding: 13px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-1); color: inherit; transition: border-color .12s, box-shadow .12s; min-width: 0; }
a.fin-tile:hover { border-color: #c4cfde; color: inherit; box-shadow: var(--sh-2); }
.fin-tile.on { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 95, 174, .12); }
.fin-tile .li-ic { width: 36px; height: 36px; }
.fin-tile small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.fin-tile b { display: block; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-tile em { font-style: normal; font-size: 12px; color: var(--muted); }
.fin-tile.dark { background: linear-gradient(140deg, #1d5aa6, #143f75); border-color: transparent; color: #fff; }
.fin-tile.dark small, .fin-tile.dark em { color: rgba(255, 255, 255, .78); }
.fin-tile.dark b { color: #fff; }
.fin-tile.dark .li-ic { background: rgba(255, 255, 255, .14); color: #fff; }

/* Tables */
.table .fin-amt { font-weight: 600; color: var(--ink); }
.table .fin-amt.neg { color: var(--red-600); }
.table .fin-amt.pos { color: var(--green-600); }
.table .fin-amt.subtle { color: var(--subtle); }
.table td.muted-cell { color: var(--muted); }
.table tr.is-void td { color: var(--subtle); }
.table tr.is-void .t-main, .table tr.is-void .fin-amt { text-decoration: line-through; color: var(--subtle); }
.table tr.fin-grp td { background: #f7f9fc; font-weight: 700; color: var(--ink); }
.table td.fin-ind { padding-left: 30px !important; }
.table .fin-run { color: #344054; }
.table .chk { width: 34px; }
.table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: middle; }
.fin-tick { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; background: var(--green-50); color: var(--green); box-shadow: inset 0 0 0 1px #c9e8d4; }
.fin-tick.off { background: #f2f4f7; color: #c0c8d4; box-shadow: none; }
.table .act { width: 1%; white-space: nowrap; text-align: right; }

/* Void / inline popover forms */
.fin-pop .pop-m { width: 300px; padding: 12px; }
.fin-pop .pop-m .field { margin-bottom: 10px; }
.fin-pop .pop-m p { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.fin-pop summary.btn { list-style: none; }

/* Notes & explainers */
.fin-explain { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.fin-explain > div { display: flex; gap: 10px; align-items: flex-start; }
.fin-explain b { display: block; color: var(--ink); font-size: 13px; }
.fin-explain small { color: var(--muted); display: block; line-height: 1.45; }

/* Summary rows (statements) */
.fin-sumrow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
.fin-sumrow > div { background: #fff; padding: 12px 14px; }
.fin-sumrow small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.fin-sumrow b { display: block; font-size: 19px; color: var(--ink); letter-spacing: -.02em; margin-top: 2px; }
.fin-sumrow .hl { background: #f2f8f4; }
.fin-sumrow .hl b { color: var(--green); }

/* Hero amount (payment / deposit) */
.fin-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.fin-hero .amt { font-size: 34px; font-weight: 800; color: var(--ink); letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.fin-hero .lbl { color: var(--muted); font-size: 13px; font-weight: 500; }

/* Calc ladder (deposit refund / reconciliation) */
.fin-calc { display: flex; flex-direction: column; }
.fin-calc > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.fin-calc > div:last-child { border-bottom: 0; }
.fin-calc span { color: var(--muted); }
.fin-calc b { color: var(--ink); font-variant-numeric: tabular-nums; }
.fin-calc .tot { border-top: 1px solid var(--line); border-bottom: 0; padding-top: 10px; margin-top: 2px; }
.fin-calc .tot span { color: var(--ink); font-weight: 600; }
.fin-calc .tot b { font-size: 18px; }
.fin-diff { border-radius: 10px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-top: 10px; }
.fin-diff.ok { background: var(--green-50); color: var(--green-600); box-shadow: inset 0 0 0 1px #c9e8d4; }
.fin-diff.bad { background: var(--red-50); color: var(--red-600); box-shadow: inset 0 0 0 1px #f6cfcf; }
.fin-diff b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* Bank account cards */
.fin-accts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.fin-acct { display: block; padding: 15px 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-2); color: inherit; position: relative; overflow: hidden; }
.fin-acct::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(closest-side, rgba(31, 95, 174, .08), rgba(31, 95, 174, 0)); }
.fin-acct.escrow::after { background: radial-gradient(closest-side, rgba(29, 135, 150, .1), rgba(29, 135, 150, 0)); }
a.fin-acct:hover { border-color: #c4cfde; color: inherit; }
.fin-acct.on { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 95, 174, .12); }
.fin-acct .nm { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fin-acct .nm b { color: var(--ink); font-size: 13.5px; }
.fin-acct .bal { font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.fin-acct small { color: var(--muted); display: block; margin-top: 2px; }

/* Share bars (P&L categories, occupancy) */
.fin-share { display: flex; align-items: center; gap: 10px; }
.fin-share .bar { flex: 1; margin-top: 0; min-width: 60px; height: 6px; }
.fin-share em { font-style: normal; font-size: 12px; color: var(--muted); width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* Mini monthly chart (P&L) */
.fin-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.fin-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.fin-chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.fin-chart .bars i { display: block; width: 40%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.fin-chart .bars i.in { background: #2f8f5b; }
.fin-chart .bars i.out { background: #e0a43a; }
.fin-chart-x { display: flex; gap: 10px; padding: 6px 4px 0; }
.fin-chart-x span { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); min-width: 0; }
.fin-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.fin-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Deadline list (deposits) */
.fin-due { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); color: inherit; }
.fin-due:last-child { border-bottom: 0; }
a.fin-due:hover { color: inherit; background: #fafcff; }
.fin-due .cal { width: 46px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.fin-due .cal small { display: block; background: var(--red-50); color: var(--red-600); font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 2px 0; letter-spacing: .04em; }
.fin-due .cal.ok small { background: var(--primary-50); color: var(--primary-700); }
.fin-due .cal b { display: block; font-size: 17px; color: var(--ink); padding: 3px 0 4px; }

/* Letterhead & printable sheet */
.fin-lh { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--ink); margin-bottom: 20px; }
.fin-lh-co { display: flex; gap: 12px; align-items: center; }
.fin-lh-co b { display: block; font-size: 16px; color: var(--ink); }
.fin-lh-co span { display: block; color: var(--muted); font-size: 12.5px; }
.fin-lh-doc { text-align: right; }
.fin-lh-doc b { display: block; font-size: 18px; color: var(--ink); letter-spacing: -.01em; }
.fin-lh-doc span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.fin-to { margin: 0 0 18px; display: flex; flex-direction: column; gap: 1px; }
.fin-to small { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 11px; font-weight: 600; }
.fin-to b { color: var(--ink); font-size: 15px; }
.fin-to span { color: #344054; }
body.fin-print { background: #eef2f7; margin: 0; }
.fin-print-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; gap: 10px; padding: 10px 18px; background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.fin-sheet { max-width: 820px; margin: 24px auto 40px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 40px 44px; box-shadow: var(--sh-3); }
.fin-sheet .table th { background: #f7f9fc; }
.fin-sheet h3 { font-size: 14px; margin: 18px 0 8px; }
.fin-sheet p { color: #344054; }
.fin-sheet .fine { font-size: 12px; color: var(--muted); }
.fin-sheet .page-break { break-before: page; }
.fin-form1099 { border: 1.5px solid #1d2433; border-radius: 6px; margin-bottom: 22px; break-inside: avoid; }
.fin-form1099 .hd { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1.5px solid #1d2433; background: #f7f9fc; }
.fin-form1099 .hd b { font-size: 15px; color: var(--ink); }
.fin-form1099 .bd { display: grid; grid-template-columns: 1fr 1fr; }
.fin-form1099 .bd > div { padding: 10px 14px; border-right: 1px solid #c9d1dc; border-bottom: 1px solid #c9d1dc; min-height: 58px; }
.fin-form1099 .bd > div:nth-child(2n) { border-right: 0; }
.fin-form1099 small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.fin-form1099 .box b { font-size: 20px; color: var(--ink); }
@media print {
  body.fin-print { background: #fff; }
  .fin-sheet { box-shadow: none; border: 0; margin: 0; padding: 0; max-width: none; }
  .fin-print-bar { display: none; }
  .fin-lh { border-bottom-color: #000; }
}

/* Receipt (payment detail) */
@media print {
  .fin .grid.g-main { display: block; }
  .fin .fin-receipt { border: 0; }
  .fin .top .sub, .fin .crumb { display: none; }
}
.fin-receipt .card-b { padding: 24px 26px; }
.fin-receipt .fin-lh { border-bottom: 1px solid var(--line); padding-bottom: 16px; }

/* Checklist (reconcile) */
.fin-sticky { position: sticky; top: 16px; }
.fin-recon-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.table tr.is-on td { background: #f4faf6; }
.table tbody tr.is-on:hover td { background: #edf7f0; }

/* Owner portal property bars */
.fin-prop { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.fin-prop:last-child { border-bottom: 0; }
.fin-prop img { width: 64px; height: 48px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #eef2f7; flex: none; }
.fin-prop .grow b { display: block; color: var(--ink); }
.fin-prop .grow small { color: var(--muted); display: block; }
.fin-prop .bar { margin-top: 6px; }
.fin-prop .val { text-align: right; min-width: 110px; }
.fin-prop .val b { display: block; color: var(--ink); font-variant-numeric: tabular-nums; }
.fin-prop .val small { color: var(--muted); }

/* Utility preview */
.fin-preview-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 13px; }
.fin-loading { opacity: .5; transition: opacity .15s; }

/* Responsive */
@media (max-width: 1280px) {
  .fin-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fin-kpis.k5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .fin-kpis, .fin-kpis.k5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-explain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-sticky { position: static; }
}
@media (max-width: 900px) {
  .fin-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-sumrow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-sheet { padding: 22px 18px; margin: 12px; }
  .fin-lh { flex-direction: column; }
  .fin-lh-doc { text-align: left; }
  .toolbar .search, .toolbar .search input { width: 100%; }
  .toolbar .search { flex: 1 1 100%; }
  .fin-filters select, .fin-filters input { min-width: 0; flex: 1 1 140px; }
}
@media (max-width: 900px) {
  .fin .table:not(.fin-stmt) td { white-space: nowrap; }
  .fin .card-h { flex-wrap: wrap; }
  .fin .top-t .sub { font-size: 13px; }
}
@media (max-width: 520px) {
  .fin-tile.dark { grid-column: 1 / -1; }
  .fin-tile b { white-space: normal; overflow: visible; font-size: 15.5px; }
  .fin-tile { padding: 11px 12px; gap: 10px; }
  .fin-tile .li-ic { width: 30px; height: 30px; }
  .fin-prop { flex-wrap: wrap; }
  .fin-prop .val { width: 100%; text-align: left; padding-left: 78px; display: flex; gap: 8px; align-items: baseline; }
  .fin-month-f input[type=month] { width: 120px; }
  .fin-kpis, .fin-kpis.k5, .fin-kpis.k3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .fin-explain { grid-template-columns: minmax(0, 1fr); }
  .fin-tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .fin-hero .amt { font-size: 28px; }
  .fin-pager { justify-content: center; }
  .fin-form1099 .bd { grid-template-columns: 1fr; }
  .fin-form1099 .bd > div { border-right: 0; }
  .fin-prop .val { min-width: 0; }
  .fin-due { flex-wrap: wrap; row-gap: 10px; }
  .fin-due .grow { flex: 1 1 calc(100% - 60px); }
  .fin-due > .row { flex: 1 1 100%; padding-left: 58px; justify-content: space-between; }
}
.fin-prop .fin-share { margin-top: 6px; }
.fin-prop .fin-share .bar { margin-top: 0; }
