/* Sprout — Finance pages. Builds on the tokens and components in styles.css. */

/* Sidebar sub-links */
.nav .nav-sub { padding: 8px 12px 8px 42px; font-size: 14px; }
.nav .nav-sub.active::before { top: 4px; bottom: 4px; }

.pos { color: var(--accent); }
[data-theme="dark"] .pos { color: var(--accent-2); }
.neg { color: var(--danger); }
.ok { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: 13px; font-weight: 600; }
.ok svg { width: 14px; height: 14px; }

/* Sub-navigation */
.fin-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; margin: -8px 0 20px; max-width: 100%; }
.fin-tabs a {
  padding: 12px 16px; border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500;
  min-height: 40px; display: inline-flex; align-items: center; transition: color var(--dur-2) ease, background var(--dur-2) ease;
}
.fin-tabs a:hover { color: var(--text); }
.fin-tabs a[aria-current="page"] { background: var(--hero); color: #fff; font-weight: 600; }

.fin-note { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: 13px; background: var(--surface); border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; }
.fin-note svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.fin-group { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 24px 0 12px; }

/* Overview */
.fin-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.fin-kpis .kpi { padding-bottom: 24px; }
.kpi-value small { font-size: 16px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-value.neg { color: var(--danger); }
.hero-kpi { background: var(--hero); color: #fff; }
.hero-kpi .kpi-label, .hero-kpi .kpi-delta { color: rgba(255,255,255,.85); }
.fin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.fin-wide { grid-column: 1 / -1; }

.ob-list, .acct-list, .spend, .insights, .tx-list, .bill-list, .pay-hist, .budgets, .set-list { list-style: none; margin: 0; padding: 0; }
.ob-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ob-row:last-child { border-bottom: 0; }
.ob-date { width: 44px; height: 48px; border-radius: 12px; background: var(--surface-2); flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.ob-date small { font-size: 10px; text-transform: uppercase; color: var(--muted); }
.ob-date b { font-size: 16px; }
.ob-row.is-late .ob-date { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.ob-row.is-paid { opacity: .6; }
.ob-main { flex: 1; min-width: 0; }
.ob-main strong { display: block; font-weight: 600; }
.ob-main small { color: var(--muted); font-size: 13px; }
.ob-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ob-total { text-align: right; color: var(--muted); margin-top: 12px; }
.ob-total b { color: var(--text); font-size: 18px; }

.spend-total { font-size: 34px; font-weight: 700; letter-spacing: -.03em; margin: -8px 0 16px; }
.spend li { display: grid; grid-template-columns: 150px 1fr auto 44px; align-items: center; gap: 12px; padding: 8px 0; }
.spend-name { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spend-name i, .tx-dot, .cat-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.spend-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.spend-bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.spend-amt { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.spend-pct { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

.acct-list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 8px; border: 0; background: none;
  border-radius: 8px; cursor: pointer; text-align: left; transition: background var(--dur-2) ease;
}
.acct-list button:hover { background: var(--surface-2); }
.acct-list span { display: flex; flex-direction: column; font-weight: 600; }
.acct-list small { color: var(--muted); font-weight: 400; font-size: 13px; }
.acct-list b { font-variant-numeric: tabular-nums; }
.acct-total { display: flex; justify-content: space-between; border-top: 1px solid var(--text); margin-top: 8px; padding: 12px 8px 0; font-weight: 600; }
.acct-total b { font-size: 18px; }

/* Forecast */
.fc-rows { list-style: none; margin: 0 0 12px; padding: 0; }
.fc-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-variant-numeric: tabular-nums; }
.fc-rows li small { color: var(--muted); font-size: 13px; }
.fc-rows li.total { border-top: 1px solid var(--text); margin-top: 8px; padding-top: 12px; font-size: 16px; }
.fc-chart { width: 100%; height: auto; display: block; margin: 4px 0 8px; }
.fc-safety { stroke: var(--danger); stroke-dasharray: 4 4; opacity: .7; }
.fc-label { fill: var(--danger); font-size: 11px; }
.fc-area { fill: var(--accent); opacity: .1; }
.fc-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.fc-low { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.fc-verdict { padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; }
.fc-verdict.good { background: var(--accent-soft); color: var(--accent); }
.fc-verdict.bad { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
[data-theme="dark"] .fc-verdict.good { color: var(--accent-2); }

/* Insights list */
.insights { display: flex; flex-direction: column; gap: 8px; }
.insights li { position: relative; padding: 12px 16px 12px 32px; border-radius: 12px; background: var(--surface-2); font-size: 14px; line-height: 1.45; }
.insights li::before { content: ""; position: absolute; left: 14px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.insights li.good::before { background: #3fae6a; }
.insights li.warn::before { background: var(--warn); }
.insights li.bad::before { background: var(--danger); }

/* Accounts */
.acct-grid, .loan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.acct-card, .loan { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.acct-card .btn, .loan .btn { margin-top: 8px; }
.acct-top { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.acct-top .icon-btn { width: 36px; height: 36px; background: var(--surface-2); }
.acct-top .icon-btn svg { width: 17px; height: 17px; }
.acct-type { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .03em; }
.acct-card h3, .loan h3 { font-size: 18px; font-weight: 700; }
.acct-bal { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 8px 0; width: 100%; }
.cc-grid dt { color: var(--muted); font-size: 13px; }
.cc-grid dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.cc-grid dd.big { font-size: 22px; font-weight: 700; }
.acct-card .kbar, .loan .kbar { width: 100%; }
.kbar.hot i { background: var(--warn); }
.kbar.over i { background: var(--danger); }
.loan-total { margin-top: 8px; }
.loan h4 { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 16px 0 4px; }
.pay-hist { width: 100%; }
.pay-hist li { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; font-size: 14px; }
.pay-hist li:last-child { border-bottom: 0; }

/* Transactions */
.tx-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.tx-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tx-filters label.grow { flex: 1; min-width: 200px; }
.tx-filters select, .tx-filters input { height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font-size: 14px; font-weight: 400; color: var(--text); }
.tx-filters .sub { margin-left: auto; }
.tx-day { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 20px 0 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.tx-day:first-child { margin-top: 0; }
.tx-day span { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.tx-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tx-row:last-child { border-bottom: 0; }
.tx-main { flex: 1; min-width: 0; }
.tx-main strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main small { color: var(--muted); font-size: 13px; }
.tx-cat { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 8px; font-size: 13px; max-width: 150px; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }
.tx-del { width: 34px; height: 34px; background: none; color: var(--muted); }
.tx-del svg { width: 15px; height: 15px; }
.tx-del:hover { color: var(--danger); background: var(--surface-2); }

/* Bills */
.bill-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.bill-list li:last-child { border-bottom: 0; }
.bill-list strong { display: block; font-weight: 600; }
.bill-list small { color: var(--muted); font-size: 13px; }

/* Budgets */
.budgets li { display: grid; grid-template-columns: 170px 1fr 140px; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.budgets li:last-child { border-bottom: 0; }
.budget-bar { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.budget-input { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.budget-input input { width: 100%; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; font-size: 14px; color: var(--text); }

/* Insights page */
.health { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.health .kpi { padding-bottom: 20px; }
.health .kpi-value { font-size: 28px; }
.proj-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.proj-table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); }
.proj-table td { padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.proj-table tr:last-child td { border-bottom: 0; }

/* Forms */
.fin-form { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.fin-form .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.form-error { color: var(--danger); font-size: 13px; font-weight: 600; }
.seg-radio { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; align-self: flex-start; }
.seg-radio label { flex-direction: row !important; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg-radio input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-radio input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.credit-only { display: flex; flex-direction: column; gap: 16px; }
.credit-only[hidden], .to-acct[hidden], .cat-field[hidden] { display: none !important; }

/* Settings → Finance */
.set-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-list strong { display: block; }
.set-list small { color: var(--muted); }
.set-list + .btn { margin-top: 12px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.cat-chip button { width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.cat-chip button:hover { background: var(--line); color: var(--danger); }
.cat-chip svg { width: 13px; height: 13px; }
.add-cat { display: flex; gap: 8px; margin-top: 12px; max-width: 420px; }
.add-cat .input { flex: 1; }

/* Responsive */
@media (max-width: 1280px) {
  .health { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .fin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .fin-kpis { grid-template-columns: 1fr; }
  .health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spend li { grid-template-columns: 110px 1fr auto; }
  .spend-pct { display: none; }
  .tx-cat { display: none; }
  .tx-amt { min-width: 0; }
  .budgets li { grid-template-columns: 1fr; gap: 8px; }
  .cc-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Bank SMS: status line, Check these, setup steps ---------- */
.sms-status { display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; color: var(--muted); font-size: 13px; }
.sms-status svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.sms-status.silent, .sms-status.silent svg { color: var(--warn); }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; }
.sms-review-link { display: flex; align-items: center; gap: 12px; padding: 16px 20px; margin-bottom: 16px; color: inherit; text-decoration: none; transition: background var(--dur-2, .2s) var(--ease-out); }
.sms-review-link:hover { background: var(--surface); }
.sms-review-link span { flex: 1; }
.sms-review-link strong { display: block; }
.sms-review-link small { color: var(--muted); font-size: 13px; }
.sms-review-link svg { width: 18px; height: 18px; color: var(--muted); }
.sms-review { margin-bottom: 16px; }
.sms-list { list-style: none; margin: 0; padding: 0; }
.sms-item { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.sms-item:first-child { border-top: 0; padding-top: 4px; }
.sms-item strong { display: flex; gap: 12px; align-items: baseline; font-size: 14px; }
.sms-item small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.sms-item .sms-raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; overflow-wrap: anywhere; opacity: .85; }
.sms-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.tx-src { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.sms-steps { margin: 2px 0 12px; font-size: 13px; color: var(--muted); }
.sms-steps summary { cursor: pointer; color: var(--text); font-weight: 600; padding: 8px 0; }
.sms-steps ol { margin: 8px 0 0 20px; padding: 0; display: grid; gap: 8px; }
.sms-steps code { font-size: 13px; background: var(--surface); padding: 1px 8px; border-radius: 8px; }
@media (max-width: 640px) { .sms-item { grid-template-columns: 1fr; } .sms-acts { justify-content: flex-start; } }
.modal-card textarea { padding: 12px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: inherit; font-family: inherit; font-size: 13px; font-weight: 400; line-height: 1.45; resize: vertical; }

/* ---------- Loans: the EMI sheet ---------- */
.loan-sheet-wrap { display: grid; gap: 16px; margin-bottom: 16px; }
.table-scroll { overflow-x: auto; margin: 0 -4px; }
.ltable { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.ltable th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.ltable td { padding: 12px 12px; border-bottom: 1px solid var(--line); }
.ltable .num { text-align: right; font-variant-numeric: tabular-nums; }
.ltable .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--muted); }
.ltable tfoot td { border-bottom: 0; font-weight: 700; padding-top: 16px; }
.ltable tr.is-closed td { opacity: .5; }
.lstatus { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; color: var(--accent); background: var(--accent-soft); }
.lstatus.closed { color: var(--muted); background: var(--surface); }
.lsum { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0; }
.lsum div { display: grid; gap: 4px; padding: 12px 16px; border-radius: 12px; background: var(--surface); }
.lsum dt { color: var(--muted); font-size: 13px; }
.lsum dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lsum .lsum-day dd { font-size: 16px; font-weight: 600; }
.loan-import { list-style: none; margin: 0 0 8px; padding: 0; max-height: 300px; overflow: auto; display: grid; gap: 8px; }
.loan-import li { display: grid; gap: 2px; padding: 12px 12px; border-radius: 12px; background: var(--surface); }
.loan-import small { color: var(--muted); font-size: 13px; }
.ltable th, .ltable td { padding-left: 8px; padding-right: 8px; }
.ltable td.wrap { white-space: normal; min-width: 96px; max-width: 132px; line-height: 1.3; }
.ltable .mono { font-size: 11px; }

/* Dashboard project rows open the project */
.proj-open { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.proj-open:hover strong { color: var(--accent); }
.ltable tr.is-theirs td { color: var(--muted); }
.ltable .lpayer { display: block; font-size: 11px; color: var(--muted); }
.ltable .ledit { width: 30px; height: 30px; }
.loan-names { margin: 0 0 12px; }
.lsum-label { margin: 16px 0 8px; }
.lsum dd small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.loan-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.li-who { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.li-who label { font-size: 13px; }
.modal-card .danger-btn { align-self: flex-start; }

/* ---------- Every day: today and money with people ---------- */
.money-today { margin-bottom: 16px; }
.money-today .card-head .btn { white-space: nowrap; }
.people-sum { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.people-sum span { flex: 1; min-width: 120px; display: grid; gap: 2px; padding: 12px 12px; border-radius: 12px; background: var(--surface); }
.people-sum small { color: var(--muted); font-size: 13px; }
.people-sum b { font-size: 16px; font-variant-numeric: tabular-nums; }
.people-list { list-style: none; margin: 0; padding: 0; }
.people-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.people-list li:first-child { border-top: 0; }
.people-list strong { display: block; font-size: 14px; }
.people-list small { color: var(--muted); font-size: 13px; }
.field-acts { display: flex; align-items: center; gap: 12px; }
.field-acts .input { height: 34px; width: 110px; }
.people-fields { display: grid; gap: 12px; }

/* Anything hidden in a Finance form stays hidden, whatever its layout style */
.fin-form [hidden] { display: none !important; }
.fin-form .type-hint { margin: -4px 0 0; color: var(--muted); font-size: 13px; }
.fin-form .seg-radio { flex-wrap: wrap; }
.fin-form .mode-row { display: flex; gap: 8px; }
.fin-form .mode-row label { flex: 1; }
.people-group + .people-group { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.pg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.pg-head h4 { margin: 0; font-size: 14px; }
.pg-head span { flex: 1; color: var(--muted); font-size: 13px; }
.pg-head b { color: var(--text); font-variant-numeric: tabular-nums; }
.people-group .day-empty { margin: 0; padding: 4px 0; }
.people-list .pl-amt { margin-left: auto; font-variant-numeric: tabular-nums; }
.people-list li > div { min-width: 0; }
.fin-form .seg-radio:not(.mode-row) { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.fin-form .seg-radio:not(.mode-row) label span { display: block; text-align: center; }
.fin-form .mode-row { display: grid; grid-template-columns: 1fr 1fr; }
.fin-form .mode-row label span { display: block; text-align: center; white-space: nowrap; }

/* Investments */
.inv-card .cc-grid small { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 4px; }
.inv-card dd.pos { color: var(--accent); }
.inv-card dd.neg, .inv-card dd.bad { color: var(--danger); }
.inv-card dd.good { color: var(--accent); }
.inv-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.inv-acts .btn { margin-top: 4px; }
.inv-hint { color: var(--warn); font-size: 13px; }
.inv-alloc-card { margin-bottom: 8px; }
.inv-alloc { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; }
.inv-alloc i { min-width: 4px; }
.inv-legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 16px; font-size: 14px; }
.inv-legend li { display: flex; align-items: center; gap: 8px; }
.inv-legend li i { width: 10px; height: 10px; border-radius: 50%; }
.inv-legend small { color: var(--muted); }
.inv-closed { margin-top: 16px; }
.inv-closed summary { cursor: pointer; font-weight: 600; }
