/* public/tools/money.css - the Money page's own styles for the Overview, Income and Deposits rooms (moved out of
   money.html's inline <style> 2026-11-19; unchanged). The workspace (sidebar, lists, drawers) is money-books.css. */
/* Page-specific only - anything reusable belongs in design-system.css.
   Tokens via var(--*); never hardcode colors / spacing. */

/* ─── Page body ─── */
.money-body { padding: var(--s-5) 1.5rem var(--s-10); }
.money-room { display: none; }
.money-room.active { display: block; }
.money-empty { margin: var(--s-6) 1.5rem; }

/* One head row per room: the segmented control left, a quiet line right. */
.money-roomhead {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s-3); margin-bottom: var(--s-4);
}
.money-roomhead-meta {
  margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  color: var(--ink-3); font-size: var(--text-sm);
}
/* The segmented control is list-shell's .list-grains; as buttons they need the reset. */
.money-seg .ls-grain { border: 0; background: transparent; font-family: inherit; cursor: pointer; min-height: 44px; padding: 0 var(--s-4); }
.money-seg .ls-grain.active { background: var(--surface); }
.money-seg .ls-grain:focus-visible { outline: none; box-shadow: var(--ring); }

/* ─── Stat strip: one bordered surface, cells split by hairlines ───
   (the 1px gap shows the border colour between cells; a wrapping flex row, not a
   grid, so a short last row stretches instead of leaving an empty grey cell) */
.money-stats {
  display: flex; flex-wrap: wrap;
  gap: 1px; background: var(--border-subtle);
  border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  overflow: hidden; margin-bottom: var(--s-5);
}
.money-stats > .ds-kpi { flex: 1 1 210px; border: 0; border-radius: 0; padding: var(--s-5); min-width: 0; }
.money-stats > .ds-kpi[hidden] { display: none; }
.money-stats .ds-kpi-label { text-transform: none; letter-spacing: 0; font-size: var(--text-sm); font-weight: 600; color: var(--ink-3); }
.money-stats .ds-kpi-value { font-size: var(--text-2xl); overflow-wrap: anywhere; }
.money-kpi-note { font-size: var(--text-xs); color: var(--ink-3); margin-top: var(--s-2); line-height: 1.45; }
.money-kpi-note:empty { display: none; }
/* "Estimate" next to a number that is one (was a warning glyph). */
.money-flag {
  display: inline-flex; align-items: center; padding: 1px var(--s-2); border-radius: var(--r-full);
  background: var(--warn-soft); color: var(--warn-ink);
  font-size: var(--text-xs); font-weight: 700; cursor: help;
}
.money-flag[hidden] { display: none; }

/* ─── Panels: flat, bordered, no resting shadow (design-system-v2 4) ─── */
.money-panel {
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--r-md); overflow: hidden; min-width: 0;
}
.money-panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5) var(--s-3);
}
.money-panel-title { margin: 0; font-size: var(--text-md); font-weight: 650; letter-spacing: var(--tracking-snug); color: var(--ink); }
.money-panel-meta { color: var(--ink-3); font-size: var(--text-sm); }
.money-panel-body { padding: 0 var(--s-5) var(--s-5); }
/* A table inside a panel runs edge to edge: no second box inside the first. */
.money-panel .ds-table-wrap { border: 0; border-radius: 0; border-top: 1px solid var(--border-subtle); }
.ds-table .ds-table-num   { text-align: right; }
.ds-table .ds-table-empty { text-align: center; color: var(--ink-3); padding: var(--s-5); }
.money-aging-total td { background: var(--surface-2); }
.money-overdue { color: var(--danger-ink); font-weight: 600; }

/* Overview: the chart full width, then unpaid invoices beside the coming-soon column. */
.money-ov-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-4); margin-top: var(--s-4); }
.money-ov-side { display: grid; gap: var(--s-4); align-content: start; }
@media (max-width: 960px) { .money-ov-grid { grid-template-columns: 1fr; } }

.money-sparkline-svg { display: block; width: 100%; height: 160px; overflow: visible; }
.money-chart-empty { margin: 0; padding: var(--s-6) 0; text-align: center; color: var(--ink-3); font-size: var(--text-sm); }

/* ─── Coming soon: a line icon, a title, one sentence, a chip ─── */
.money-soon {
  display: flex; gap: var(--s-4); align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  padding: var(--s-5);
}
.money-soon-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.money-soon-icon svg { width: 22px; height: 22px; }
.money-soon-title { margin: 0 0 var(--s-1); font-size: var(--text-md); font-weight: 650; color: var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.money-soon-text { margin: 0; color: var(--ink-3); font-size: var(--text-sm); line-height: 1.5; max-width: 62ch; }
.money-soon-link { text-decoration: none; color: inherit; }
.money-soon-link:hover { border-color: var(--border); }
.money-kpi-lines { list-style: none; margin: var(--s-2) 0 0; padding: 0; color: var(--ink-3); font-size: var(--text-xs); line-height: 1.5; }
.money-kpi-lines li { display: flex; justify-content: space-between; gap: var(--s-3); }
.money-kpi-lines li.is-warn { color: var(--warn-ink, var(--ink-2)); }
/* The Cash on hand card (2026-11-23): section heads, the quiet words after a name, an old statement struck, the cards toggle.
   It takes twice the room of a number tile so each account stays on one line. */
.money-stats > .ds-kpi[data-widget="cash_on_hand"] { flex: 2 1 360px; }
.money-kpi-lines li.money-kpi-sec {
  margin-top: var(--s-3); padding-top: var(--s-2); border-top: 1px solid var(--border-subtle);
  font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2);
}
.money-kpi-lines li.money-kpi-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.money-kpi-lines li.money-kpi-sec span:last-child { color: var(--ink); text-transform: none; letter-spacing: 0; }
.money-kpi-lines .money-kpi-sub { color: var(--ink-3); font-weight: 400; }
.money-kpi-lines li.is-off > span:last-child { text-decoration: line-through; }
.money-kpi-more {
  margin-top: var(--s-2); padding: var(--s-1) 0; min-height: 32px; border: 0; background: none; cursor: pointer;
  color: var(--brand, var(--accent)); font-size: var(--text-xs); font-weight: 600;
}
.money-kpi-more:focus-visible { outline: 2px solid var(--focus-ring, var(--brand)); outline-offset: 2px; border-radius: var(--r-sm); }
.money-kpi-more[hidden] { display: none; }
.money-soon-chip {
  display: inline-flex; align-items: center; padding: 1px var(--s-2); border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-2); font-size: var(--text-xs); font-weight: 700;
}
/* A whole room that is not built yet: the same card, larger and centred. */
.money-soon-room { flex-direction: column; align-items: center; text-align: center; padding: var(--s-12) var(--s-6); }
.money-soon-room .money-soon-icon { width: 56px; height: 56px; }
.money-soon-room .money-soon-icon svg { width: 28px; height: 28px; }
.money-soon-room .money-soon-title { justify-content: center; font-size: var(--text-lg); }

/* ─── Income: the shared list, framed as one panel ─── */
.money-listpanel { border: 1px solid var(--border-subtle); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.money-listpanel .list-subtabs:empty { display: none; }
/* The compact head's tab row holds nothing here (no scope tabs, no primary action). */
.money-listpanel .list-tabrow:has(.list-head-primary:empty):not(:has(.list-scope-tabs)) { display: none; }

@media (max-width: 640px) {
  .money-body { padding: var(--s-4) var(--s-4) var(--s-8); }
  .money-empty { margin: var(--s-4); }
  .money-roomhead > .list-grains { width: 100%; }
  .money-stats > .ds-kpi { flex-basis: 40%; padding: var(--s-4); }
  .money-stats .ds-kpi-value { font-size: var(--text-xl); }
  .money-panel-head { padding: var(--s-4) var(--s-4) var(--s-3); }
  .money-panel-body { padding: 0 var(--s-4) var(--s-4); }
  .money-soon { padding: var(--s-4); }
  .money-soon-room { padding: var(--s-8) var(--s-4); }
  /* Unpaid invoices is three short columns: it stays a table on a phone instead of
     the shared table's one-card-per-row layout. */
  .ds-table.money-aging-table { display: table; }
  .money-aging-table thead { display: table-header-group; }
  .money-aging-table tbody { display: table-row-group; }
  .money-aging-table tr { display: table-row; padding: 0; }
  .money-aging-table td { display: table-cell; width: auto; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); }
  .money-aging-table td::before { content: none; }
}

/* A person without permission to download or print (money.js sets body.money-no-export from /api/money/access):
   a browser print of the Money page shows one short centered message and nothing else, in both themes. */
@media print {
  body.money-no-export { background: #fff !important; color: #000 !important; }
  body.money-no-export > * { display: none !important; }
  body.money-no-export::before {
    content: "Printing is turned off for your account.";
    display: block;
    margin-top: 40vh;
    text-align: center;
    font: 600 20px/1.4 system-ui, sans-serif;
    color: #000;
  }
}
