/* Finance › PMA: Cash Position, Invoices, Profit & Loss, Yearly P&L (public/pma-finance.js). Charts reuse Health
   Check's bar colours (.hc-bar-in PMA blue, .hc-bar-out amber); lines use the palette's CSS variables, so light and
   dark both follow styles.css. */
[data-page="cash"], [data-page="invoices"], [data-page="forecast"], [data-page="pnl"], [data-page="pnl-years"] {
  --pf-s0: var(--pma-blue); --pf-s1: var(--ty-co); --pf-s2: var(--ty-ind); --pf-s3: var(--ty-st);
  --pf-s4: var(--ty-other); --pf-s5: var(--green); --pf-s6: var(--orange); --pf-s7: var(--violet);
}
[data-page="cash"] > div > .panel, [data-page="invoices"] .panel, [data-page="pnl"] .panel, [data-page="pnl-years"] .panel { margin-top: 18px; }
/* The page section is a grid: without this a wide P&L table would widen the whole page instead of scrolling. */
#cash-body, #invoices-body, #fc-body, #pnl-body, #pny-body { min-width: 0; }
.pf-note { margin: 12px 0 14px; }
.pf-kpis4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pf-kpis5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pf-kpis4 .kpi b, .pf-kpis5 .kpi b { font-size: 30px; }
.pf-kpis5 .kpi b small { font-size: 18px; color: var(--muted); }
.pf-ksub { display: block; margin-top: 4px; font-style: normal; font-size: 12px; color: var(--muted); }
@media (max-width: 1100px) { .pf-kpis4, .pf-kpis5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pf-tie { margin: 10px 0 0; }
.pf-up { color: var(--green); } .pf-down { color: var(--red); }
.amber-text { color: var(--amber); font-weight: 600; }

/* Owed to PMA / PMA owes */
.pf-context { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.pf-ctx { display: grid; gap: 2px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: inherit; text-decoration: none; }
.pf-ctx:hover { border-color: var(--pma-blue); }
.pf-ctx span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pf-ctx b { font-family: var(--display); font-size: 24px; }
.pf-ctx em { font-style: normal; font-size: 12px; color: var(--pma-blue); }
@media (max-width: 640px) { .pf-context { grid-template-columns: minmax(0, 1fr); } }

/* Tables */
.pf-tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); padding: 10px 12px; }
.pf-tbl tfoot td:first-child { padding-left: 20px; }
.pf-tbl tr.pf-card td { color: var(--ink-2); }
.pf-tbl tr.pf-credit td { color: var(--red); }
.pf-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--grey-soft); color: var(--ink-2); }
.pf-tag.rec { background: var(--pma-blue-soft); color: var(--pma-blue-ink); }
.pf-status { text-transform: capitalize; font-size: 12px; color: var(--ink-2); }
.pf-foot { margin: 14px 0 0; }
/* Long tables scroll inside the panel (headings and totals stay in view) rather than making the page very long. */
.pf-cap { max-height: 620px; overflow: auto; }
.pf-cap thead th { z-index: 1; }
.pf-cap tfoot td { position: sticky; bottom: 0; background: var(--panel); }
.pf-tools { margin: 4px 0 12px; }
.pf-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.pf-sec { margin-top: 26px; }
.pf-h { font-size: 20px; margin: 0 0 6px; }
.pf-h3 { font-size: 15px; margin: 18px 0 8px; }
.pf-tabs { margin-top: 12px; }
.pf-forecast { margin: 0 0 4px; font-weight: 600; }

/* Charts */
.pf-chart { margin-top: 4px; }
.pf-grid { stroke: var(--line); stroke-width: 1; }
.pf-grid.zero { stroke: var(--muted); }
.pf-axis { font-size: 10px; fill: var(--muted); }
.pf-line polyline { stroke-width: 1.6; stroke-linejoin: round; }
.pf-line.total polyline { stroke-width: 3; }
.pf-total { --c: var(--ink); } .pf-net { --c: var(--green); }
.pf-s0 { --c: var(--pf-s0); } .pf-s1 { --c: var(--pf-s1); } .pf-s2 { --c: var(--pf-s2); } .pf-s3 { --c: var(--pf-s3); }
.pf-s4 { --c: var(--pf-s4); } .pf-s5 { --c: var(--pf-s5); } .pf-s6 { --c: var(--pf-s6); } .pf-s7 { --c: var(--pf-s7); }
.pf-line polyline { stroke: var(--c); }
.pf-dot { fill: var(--c); stroke: var(--panel); stroke-width: 1; }
.pf-line.pf-net polyline { stroke-width: 2.5; }
.pf-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.pf-legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.pf-legend i.pf-in { height: 10px; background: var(--pma-blue); }
.pf-legend i.pf-out { height: 10px; background: var(--amber); opacity: .55; }

/* The P&L table: Xero's sections, accounts collapsible, labels pinned on the left when it scrolls sideways. */
.pf-scroll { margin-top: -6px; }
.pf-pnl { font-variant-numeric: tabular-nums; }
.pf-pnl th, .pf-pnl td { white-space: nowrap; padding: 7px 12px; font-size: 13px; }
.pf-pnl tbody th { text-align: left; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.pf-pnl thead th.num { text-align: right; }
.pf-pnl thead th a { color: inherit; text-decoration: underline dotted; }
.pf-pnl th:first-child { position: sticky; left: 0; z-index: 2; background: var(--panel); min-width: 220px; max-width: 320px; white-space: normal; box-shadow: 1px 0 0 var(--line); }
.pf-pnl thead th:first-child { z-index: 3; }
.pf-pnl tbody tr:hover th:first-child { background: var(--line-2); }
.pf-sec-row th { padding-top: 14px !important; }
.pf-tog { border: 0; background: transparent; padding: 0; font: 700 13px var(--font); color: var(--ink); cursor: pointer; text-align: left; }
.pf-tog:hover { color: var(--pma-blue); }
.pf-line-row th { padding-left: 36px !important; color: var(--ink-2) !important; }
.pf-line-row td { color: var(--ink-2); }
.pf-total-row th, .pf-total-row td { font-weight: 600 !important; border-top: 1px solid var(--line); }
.pf-key-row th, .pf-key-row td { font-weight: 700 !important; background: var(--grey-soft); }
.pf-key-row th:first-child { background: var(--grey-soft); }
.pf-net-row th, .pf-net-row td { border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.pf-pulled-row th { padding-left: 24px !important; color: var(--ink-2) !important; }
.pf-margin-row th, .pf-margin-row td { color: var(--muted) !important; font-size: 12px !important; }
.pf-chg-row th, .pf-chg-row td { font-size: 12px !important; color: var(--muted); }
.pf-chg-row:first-of-type th { border-top: 1px solid var(--line); }
.pf-chg { font-weight: 600; }
.pf-totcol { background: var(--pma-blue-soft); font-weight: 600; }
.pf-todate { font-size: 10px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--amber); }
.pf-grp { text-align: center !important; border-bottom: 0 !important; }
@media (max-width: 640px) {
  .pf-pnl th:first-child { min-width: 150px; max-width: 170px; }
  .pf-kpis4 .kpi b, .pf-kpis5 .kpi b { font-size: 24px; }
}

/* Recurring Forecast (#forecast, public/forecast.js) */
[data-page="forecast"] .panel { margin-top: 18px; }
.fc-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 14px 0 0; }
.fc-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.fc-seg button { border: 0; background: transparent; padding: 6px 12px; font: 600 12px var(--font); color: var(--muted); cursor: pointer; }
.fc-seg button + button { border-left: 1px solid var(--line); }
.fc-seg button[aria-pressed="true"] { background: var(--pma-blue); color: #fff; }
.fc-tabs { margin-top: 12px; }
.fc-right { display: inline-flex; align-items: center; gap: 8px; }
.fc-foot { margin: 10px 0 0; }
/* A table with a note (a paragraph) under it keeps a normal bottom margin; the usual negative one (flush with the panel's edge)
   would pull the note up under the table's last row. */
.table-wrap:has(+ p) { margin-bottom: 0; }
.fc-grid td, .fc-grid th { font-size: 12.5px; }
.fc-kpis3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fc-fees { margin-top: 12px; }
.fc-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.fc-filters select, .fc-filters input[type=month] { min-height: 32px; padding: 4px 8px; }
.fc-sub { border-top: 1px solid var(--line-2); padding-top: 10px; }
.fc-cols { position: relative; }
.fc-cols summary { cursor: pointer; color: var(--pma-blue); font-weight: 600; }
.fc-cols > div { position: absolute; z-index: 5; display: grid; gap: 4px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); white-space: nowrap; }
.fc-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.fc-lines-tbl td { font-size: 12.5px; white-space: nowrap; }
.fc-lines-tbl td.fc-desc { white-space: normal; min-width: 220px; max-width: 360px; }
.fc-soon td { background: var(--amber-soft); }
.fc-soon td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
.fc-flag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--amber); background: var(--amber-soft); padding: 1px 7px; border-radius: 4px; }
.fc-lines summary { cursor: pointer; font-weight: 600; }
.fc-lines ul { margin: 6px 0 0 16px; padding: 0; font-size: 12px; color: var(--ink-2); }
.fc-details > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; cursor: pointer; list-style: none; }
.fc-details > summary::-webkit-details-marker { display: none; }
.fc-details > summary h2::before { content: "▸ "; }
.fc-details[open] > summary h2::before { content: "▾ "; }
.fc-details[open] > summary { margin-bottom: 12px; }
.fc-exports { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
@media (max-width: 1100px) { .fc-kpis3 { grid-template-columns: minmax(0, 1fr); } }
/* "Print / PDF": the page alone, without the sidebar, controls or buttons; tables print in full. */
@media print {
  #sidebar, .page-actions, .fc-controls, .fc-tabs, [data-csv], .fc-filters, .fc-pager, .crumb { display: none !important; }
  .shell { display: block !important; }
  .main { padding: 0 !important; }
  .table-wrap { overflow: visible !important; max-height: none !important; }
  .panel { break-inside: avoid; box-shadow: none; }
  .pf-pnl th:first-child { position: static; }
}
