/* =====================================================================
   MONEY — the personal finance app inside the agent workspace.
   Its own look (sans, violet accent, light and dark) so it reads as an
   app rather than a portal page. Designed in Figma: "Chikoti Portal:
   Agent Top Bar + Personal Finance". Every colour is a token below; the
   portal's own tokens are remapped inside .money-app so the shared
   screens from fin.js (budget, accounts, goals, import) theme with it.
   ===================================================================== */
.money-app {
  --m-bg: #f5f6f8; --m-surface: #ffffff; --m-surface-2: #f0f2f4; --m-line: #e4e7ea; --m-line-soft: #eef0f2;
  --m-ink: #171b21; --m-muted: #5c6672; --m-faint: #8d97a2;
  --m-accent: var(--brand, #1d2733); --m-accent-ink: var(--brand-ink, #0d131b); --m-accent-soft: var(--brand-soft, #e3e8ef);
  --m-pos: #16a34a; --m-pos-soft: #dcfce7; --m-neg: #e11d48; --m-neg-soft: #ffe4e9; --m-warn: #d97706; --m-warn-soft: #fef3c7;
  --m-shadow: 0 1px 2px rgba(29, 39, 51, 0.05);
  --paper: var(--m-bg); --card: var(--m-surface); --line: var(--m-line); --hair: var(--m-line-soft);
  --ink: var(--m-ink); --muted: var(--m-muted); --faint: var(--m-faint);
  --accent: var(--m-accent); --accent-ink: var(--m-accent-ink); --accent-soft: var(--m-accent-soft);
  --done: var(--m-pos); --done-soft: var(--m-pos-soft); --warn: var(--m-warn); --warn-soft: var(--m-warn-soft);
  --serif: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 56px);
  background: var(--m-bg); color: var(--m-ink); font-size: 13px; -webkit-font-smoothing: antialiased;
}
.money-app[data-theme="dark"] {
  --m-bg: #0d1117; --m-surface: #151b23; --m-surface-2: #1c232c; --m-line: #27303a; --m-line-soft: #1f2730;
  --m-ink: #e9edf2; --m-muted: #a3adb9; --m-faint: #6f7a86;
  --m-accent: var(--brand-dark, #6d92ba); --m-accent-ink: var(--brand-dark, #89a9cc); --m-accent-soft: #1d2733;
  --m-pos: #22c55e; --m-pos-soft: #12301f; --m-neg: #f43f5e; --m-neg-soft: #3a1520; --m-warn: #f59e0b; --m-warn-soft: #3a2a0c;
  --m-shadow: none; color-scheme: dark;
}
.money-app a { color: inherit; text-decoration: none; }
/* A long unbroken name or a trillion-dollar figure wraps where it must
   instead of pushing the page sideways; a select is never wider than its
   box (its width is its longest option). */
.money-app { overflow-wrap: anywhere; }
/* Table columns size to their words; "anywhere" would let a wide column
   squeeze "Lunch" into "Lunc h". */
.money-app td, .money-app th { overflow-wrap: break-word; }
.money-app td b, .money-app td small, .money-app td .ht-name { overflow-wrap: anywhere; }
.money-app select { max-width: 100%; }
.money-app .m-table select { max-width: 220px; }
.money-app *, .money-app *::before, .money-app *::after { box-sizing: border-box; }
.money-app svg.i { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* privacy: blur every money figure */
.money-app[data-private="1"] .m-money { filter: blur(6px); transition: filter .15s; }
.money-app[data-private="1"] .m-money:hover { filter: none; }

/* ---- sidebar ---- */
.m-side { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; background: var(--m-surface); border-right: 1px solid var(--m-line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.m-brand { display: flex; align-items: center; gap: 9px; padding: 2px 4px 12px; }
.m-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--m-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.m-brand-name { font-weight: 700; font-size: 16px; flex: 1; }
.m-iconbtn { width: 28px; height: 28px; border-radius: 7px; border: 0; background: transparent; color: var(--m-faint); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.m-iconbtn:hover { background: var(--m-surface-2); color: var(--m-ink); }
.m-search { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; border: 0; background: var(--m-surface-2); color: var(--m-faint); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left; }
.m-search span { flex: 1; }
.m-kbd { font-size: 10px; font-weight: 600; padding: 1px 5px; border: 1px solid var(--m-line); border-radius: 4px; color: var(--m-faint); }
.m-navlabel { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--m-faint); padding: 14px 8px 4px; }
.m-nav { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--m-muted); font-weight: 500; font-size: 13px; }
.m-nav svg.i { color: var(--m-faint); }
.m-nav:hover { background: var(--m-surface-2); color: var(--m-ink); }
.m-nav.active { background: var(--m-accent-soft); color: var(--m-accent); font-weight: 600; }
.m-nav.active svg.i { color: var(--m-accent); }
.m-nav .m-count { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--m-warn); }
.m-side-grow { flex: 1; min-height: 12px; }
.m-balances { border-top: 1px solid var(--m-line); padding-top: 10px; }
.m-bal-head { display: flex; justify-content: space-between; padding: 0 4px 6px; font-size: 10px; font-weight: 600; letter-spacing: .12em; color: var(--m-faint); }
.m-bal-head b { color: var(--m-ink); letter-spacing: 0; font-size: 11px; }
.m-bal-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 6px; }
.m-bal-row:hover { background: var(--m-surface-2); }
.m-bal-row .n { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-bal-row .k { font-size: 10.5px; color: var(--m-faint); }
.m-bal-row .v { font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ---- main ---- */
.m-main { padding: 26px clamp(18px, 3vw, 36px) 80px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.m-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.m-eyebrow { font-size: 12px; font-weight: 500; color: var(--m-faint); margin-bottom: 3px; }
.m-title { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 0; line-height: 1.15; }
.m-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.m-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--m-line); background: var(--m-surface); color: var(--m-ink); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.m-btn:hover { border-color: var(--m-faint); }
.m-btn.primary { background: var(--m-accent); border-color: var(--m-accent); color: #fff; font-weight: 600; }
.m-btn.primary:hover { background: var(--m-accent-ink); }
.m-btn.ghost { border-color: transparent; background: transparent; color: var(--m-muted); }
.m-btn.ghost:hover { background: var(--m-surface-2); color: var(--m-ink); }
.m-btn.danger { color: var(--m-neg); }
.m-btn.danger:hover { border-color: var(--m-neg); }
.m-btn.on { background: var(--m-accent-soft); border-color: transparent; color: var(--m-accent); font-weight: 600; }
.m-btn.sm { padding: 4px 9px; font-size: 11.5px; }
.m-btn.icon { padding: 7px; }
.m-btn[disabled] { opacity: .5; cursor: default; }
.m-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--m-surface-2); }
.m-seg .m-btn { border-color: transparent; background: transparent; color: var(--m-muted); }
.m-seg .m-btn.on { background: var(--m-surface); color: var(--m-ink); box-shadow: var(--m-shadow); border-color: var(--m-line); }

.m-card { background: var(--m-surface); border: 1px solid var(--m-line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--m-shadow); min-width: 0; }
.m-card.flush { padding: 0; overflow: hidden; }
.m-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.m-card.flush .m-card-head { padding: 14px 20px 0; }
.m-card-title { font-size: 14px; font-weight: 600; margin: 0; }
.m-card-sub { font-size: 11.5px; color: var(--m-faint); margin-top: 2px; }
.m-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.m-grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.m-grid-1-2 { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.m-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.m-tile { background: var(--m-surface); border: 1px solid var(--m-line); border-radius: 14px; padding: 14px 16px; }
.m-tile .lbl { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--m-faint); }
.m-tile .val { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; }
.m-tile .sub { font-size: 11.5px; color: var(--m-muted); margin-top: 4px; }
.m-tile .val.pos { color: var(--m-pos); } .m-tile .val.neg { color: var(--m-neg); } .m-tile .val.accent { color: var(--m-accent); }

/* tables */
.m-table-wrap { overflow-x: auto; }
.m-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.m-table th { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--m-faint); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--m-line); white-space: nowrap; background: var(--m-surface); }
.m-table td { padding: 9px 12px; border-bottom: 1px solid var(--m-line-soft); vertical-align: middle; }
.m-table tr:last-child td { border-bottom: 0; }
.m-table tbody tr:hover td { background: var(--m-surface-2); }
.m-table tr.sel td { background: color-mix(in srgb, var(--m-accent-soft) 70%, transparent); }
.m-table tr.dim td { opacity: .5; }
.m-table th:first-child, .m-table td:first-child { padding-left: 20px; }
.m-table th:last-child, .m-table td:last-child { padding-right: 20px; }
.m-table .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.m-table .muted { color: var(--m-muted); }
.m-table .faint { color: var(--m-faint); }
.m-table select, .m-table input[type=text], .m-table input[type=number] { font: inherit; font-size: 12px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--m-ink); max-width: 100%; }
.m-table select:hover, .m-table input:hover, .m-table select:focus, .m-table input:focus { border-color: var(--m-line); background: var(--m-surface); }
.m-table tfoot td { font-weight: 600; border-top: 1px solid var(--m-line); border-bottom: 0; }
.m-cellmain { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-cellmain .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-cellmain .s { font-size: 11px; color: var(--m-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-rowacts { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.m-table tr:hover .m-rowacts, .m-row:hover .m-rowacts { opacity: 1; }

/* icon tile, pills, amounts */
.m-ic { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; font-size: 12px; font-weight: 700; background: var(--m-faint); }
.m-ic svg.i { width: 16px; height: 16px; stroke: #fff; }
.m-ic.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 10.5px; } .m-ic.sm svg.i { width: 13px; height: 13px; }
.m-ic.lg { width: 40px; height: 40px; border-radius: 11px; } .m-ic.round { border-radius: 999px; }
.m-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--m-surface-2); color: var(--m-muted); white-space: nowrap; }
.m-pill.accent { background: var(--m-accent-soft); color: var(--m-accent); }
.m-pill.pos { background: var(--m-pos-soft); color: var(--m-pos); }
.m-pill.neg { background: var(--m-neg-soft); color: var(--m-neg); }
.m-pill.warn { background: var(--m-warn-soft); color: var(--m-warn); }
.m-pill.plain { text-transform: none; letter-spacing: 0; font-size: 11px; }
button.m-pill { border: 0; cursor: pointer; font-family: inherit; }
.m-amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.m-amt.pos { color: var(--m-pos); } .m-amt.neg { color: var(--m-neg); } .m-amt.zero { color: var(--m-muted); }
.m-progress { position: relative; height: 6px; border-radius: 3px; background: var(--m-surface-2); overflow: hidden; min-width: 60px; }
.m-progress > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--m-pos); }
.m-progress > i.accent { background: var(--m-accent); } .m-progress > i.warn { background: var(--m-warn); } .m-progress > i.neg { background: var(--m-neg); }
.m-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.m-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--m-surface-2); font-size: 11.5px; font-weight: 500; }
.m-chip b { font-weight: 600; }
.m-chip button { border: 0; background: transparent; color: var(--m-faint); cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1; }

/* forms */
.m-input, .m-select, .money-app .m-form input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .money-app .m-form select, .money-app .m-form textarea { width: 100%; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--m-line); border-radius: 8px; background: var(--m-surface); color: var(--m-ink); outline: none; }
.m-input:focus, .m-select:focus, .money-app .m-form input:focus, .money-app .m-form select:focus { border-color: var(--m-accent); box-shadow: 0 0 0 3px var(--m-accent-soft); }
.m-form { display: flex; flex-direction: column; gap: 12px; }
.m-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.m-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.m-field > label, .m-label { font-size: 11px; font-weight: 500; color: var(--m-muted); }
.m-field.wide { grid-column: 1 / -1; }
.m-check { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--m-muted); cursor: pointer; }
.m-check input { width: 15px; height: 15px; accent-color: var(--m-accent); }
.m-cb { width: 15px; height: 15px; accent-color: var(--m-accent); cursor: pointer; vertical-align: middle; }
.m-toggle { position: relative; width: 30px; height: 17px; border-radius: 999px; background: var(--m-line); border: 0; cursor: pointer; flex-shrink: 0; padding: 0; }
.m-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 999px; background: #fff; transition: left .12s; }
.m-toggle.on { background: var(--m-accent); } .m-toggle.on::after { left: 15px; }
.m-swatch { width: 22px; height: 22px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.m-swatch.on { border-color: var(--m-ink); }

/* notes, empty, callouts */
.m-note { font-size: 12px; color: var(--m-muted); }
.m-faint { color: var(--m-faint); }
.m-warn, .m-ok, .m-info { border-radius: 10px; padding: 10px 14px; font-size: 12.5px; }
.m-warn { background: var(--m-warn-soft); color: var(--m-ink); border: 1px solid color-mix(in srgb, var(--m-warn) 40%, transparent); }
.m-ok { background: var(--m-pos-soft); border: 1px solid color-mix(in srgb, var(--m-pos) 40%, transparent); }
.m-info { background: var(--m-accent-soft); border: 1px solid color-mix(in srgb, var(--m-accent) 30%, transparent); }
.m-empty { text-align: center; padding: 40px 20px; }
.m-empty .m-ic { margin-bottom: 12px; }
.m-empty h3 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.m-empty p { color: var(--m-muted); max-width: 440px; margin: 0 auto 14px; font-size: 12.5px; line-height: 1.5; }

/* lists of rows */
.m-list { display: flex; flex-direction: column; }
.m-row { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--m-line-soft); min-width: 0; }
.m-list > .m-row:first-child { border-top: 0; }
.m-row-main { flex: 1; min-width: 0; }
.m-row-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-row-sub { font-size: 11px; color: var(--m-faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-row-right { text-align: right; flex-shrink: 0; }
.m-row.link { cursor: pointer; } .m-row.link:hover { background: var(--m-surface-2); }
.m-sectionlabel { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--m-faint); }

/* tabs */
.m-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--m-line); overflow-x: auto; }
.m-tab { padding: 8px 12px 9px; font-size: 13px; font-weight: 500; color: var(--m-muted); border: 0; border-bottom: 2px solid transparent; background: transparent; font-family: inherit; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.m-tab:hover { color: var(--m-ink); }
.m-tab.active { color: var(--m-accent); border-bottom-color: var(--m-accent); font-weight: 600; }

/* bulk bar */
.m-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px 8px 16px; border-radius: 10px; background: var(--m-accent-soft); position: sticky; top: 64px; z-index: 5; }
.m-bulk .count { font-weight: 600; color: var(--m-accent); margin-right: auto; }
.m-bulk select { font: inherit; font-size: 12.5px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--m-line); background: var(--m-surface); color: var(--m-ink); }

/* calendar */
.m-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-cal-h { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; color: var(--m-faint); padding: 10px; }
.m-cal-d { min-height: 92px; padding: 7px 9px; border-top: 1px solid var(--m-line); border-left: 1px solid var(--m-line); display: flex; flex-direction: column; gap: 2px; cursor: pointer; background: transparent; text-align: left; font: inherit; color: inherit; border-right: 0; border-bottom: 0; min-width: 0; }
.m-cal-d:nth-child(7n + 8) { border-left: 0; }
.m-cal-d:hover { background: var(--m-surface-2); }
.m-cal-d.blank { background: color-mix(in srgb, var(--m-surface-2) 60%, transparent); cursor: default; }
.m-cal-d.sel { background: color-mix(in srgb, var(--m-accent-soft) 55%, transparent); }
.m-cal-d .num { width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 600; }
.m-cal-d.today .num { background: var(--m-accent); color: #fff; }
.m-cal-d .in { color: var(--m-pos); font-size: 11px; font-weight: 600; }
.m-cal-d .out { color: var(--m-neg); font-size: 11px; font-weight: 600; }
.m-cal-d .proj { color: var(--m-faint); font-size: 10.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* charts */
.m-chart { width: 100%; height: auto; display: block; overflow: visible; }
.m-chart .grid { stroke: var(--m-line); stroke-width: 1; }
.m-chart .axis { font-size: 10px; fill: var(--m-faint); font-family: inherit; }
.m-chart .lbl { font-size: 11px; fill: var(--m-ink); font-family: inherit; font-weight: 500; }
.m-chart .lbl.faint { fill: var(--m-faint); }
.m-chart .hit { fill: transparent; }
.m-chart .hit:hover { fill: var(--m-ink); fill-opacity: .04; }
.m-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11.5px; color: var(--m-muted); margin-top: 8px; }
.m-legend span { display: inline-flex; align-items: center; gap: 6px; }
.m-tip { position: fixed; z-index: 60; background: var(--m-ink, #1d2733); color: var(--m-bg, #fff); font-size: 12px; padding: 6px 9px; border-radius: 7px; pointer-events: none; white-space: nowrap; transform: translate(-50%, -125%); font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }

/* modal */
.m-modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(13, 14, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; }
.m-modal { width: 100%; max-width: 560px; background: var(--m-surface); color: var(--m-ink); border: 1px solid var(--m-line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.m-modal.wide { max-width: 760px; }
.m-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.m-modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.m-modal-body { padding: 14px 20px; }
.m-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; flex-wrap: wrap; }

/* search palette */
.m-palette { max-width: 620px; }
.m-palette input { width: 100%; border: 0; border-bottom: 1px solid var(--m-line); padding: 16px 20px; font: inherit; font-size: 15px; background: transparent; color: var(--m-ink); outline: none; border-radius: 16px 16px 0 0; }
.m-palette-list { max-height: 60vh; overflow-y: auto; padding: 6px 0 10px; }
.m-palette-sec { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--m-faint); padding: 10px 20px 4px; }
.m-palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 20px; cursor: pointer; }
.m-palette-item:hover, .m-palette-item.on { background: var(--m-surface-2); }

/* dashboard */
.m-kpi { display: grid; grid-template-columns: minmax(0, 1fr) 340px; padding: 0; }
.m-kpi-main { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.m-kpi-big { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.m-kpi-row { display: flex; gap: 36px; flex-wrap: wrap; }
.m-kpi-row .lbl { font-size: 11.5px; color: var(--m-faint); font-weight: 500; }
.m-kpi-row .v { font-size: 19px; font-weight: 700; margin-top: 3px; }
.m-kpi-side { border-left: 1px solid var(--m-line); padding: 22px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.m-kpi-badge { width: 52px; height: 52px; border-radius: 999px; background: var(--m-warn); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.m-kpi-badge.ok { background: var(--m-pos); }
.m-catrow { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 0; }
.m-catrow .top { display: flex; align-items: center; gap: 8px; }
.m-catrow .top .n { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-catrow .of { font-size: 10.5px; color: var(--m-faint); text-align: right; margin-top: 3px; }
.m-catrow .of.warn { color: var(--m-warn); } .m-catrow .of.neg { color: var(--m-neg); }
.m-scroll { max-height: 420px; overflow-y: auto; padding-right: 4px; }

/* the agent top bar reserves 56px; phones stack everything */
@media (max-width: 1100px) { .m-grid-2-1, .m-grid-1-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .money-app { grid-template-columns: 1fr; }
  .m-side { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--m-line); gap: 4px; }
  .m-side .m-navlabel, .m-side .m-balances, .m-side .m-side-grow, .m-side .m-search span, .m-side .m-kbd { display: none; }
  .m-side .m-brand { padding: 0 6px 0 0; }
  .m-side .m-brand-name { display: none; }
  .m-side .m-search { width: auto; margin: 0; }
  .m-nav { white-space: nowrap; flex-shrink: 0; }
  .m-grid2 { grid-template-columns: minmax(0, 1fr); }
  .m-kpi { grid-template-columns: 1fr; }
  .m-kpi-side { border-left: 0; border-top: 1px solid var(--m-line); }
  .m-main { padding: 18px 16px 70px; }
  .m-cal-d { min-height: 64px; padding: 5px; }
  .m-cal-d .in, .m-cal-d .out, .m-cal-d .proj { font-size: 9.5px; }
}

/* The shared fin.js screens (budget, accounts, goals, import) use the
   portal's .card, .form-row and .tp-btn, some with hard-coded light colours.
   Inside the app they follow the app's tokens, so dark mode stays readable. */
.money-app .card { background: var(--m-surface); border-color: var(--m-line); color: var(--m-ink); border-radius: 14px; margin-bottom: 0; }
.money-app .card + .card, .money-app .fin-tiles + .card, .money-app .card + .fin-warn { margin-top: 18px; }
.money-app .card-title { color: var(--m-ink); font-weight: 600; font-size: 14px; }
.money-app .card-sub, .money-app .form-row label, .money-app .empty-note { color: var(--m-faint); }
.money-app .form-row input, .money-app .form-row select, .money-app .form-row textarea, .money-app .fin-filters select, .money-app .fin-filters input { background: var(--m-surface); color: var(--m-ink); border-color: var(--m-line); }
.money-app .tp-btn { background: var(--m-surface); color: var(--m-ink); border-color: var(--m-line); }
.money-app .tp-btn.primary { background: var(--m-accent); border-color: var(--m-accent); color: #fff; }
.money-app .tp-btn.primary:hover { background: var(--m-accent-ink); border-color: var(--m-accent-ink); }
.money-app .tp-btn.quiet { background: transparent; border-color: transparent; color: var(--m-muted); }
.money-app .fin-tile { border-radius: 14px; }
.money-app .fin-tile .val, .money-app .fin-acct .bal, .money-app .fin-month .lbl, .money-app .fin-budget-group h3 { font-family: inherit; font-weight: 700; }
.money-app .fin-tip { background: var(--m-ink); color: var(--m-bg); }
.money-app .tp-link { color: var(--m-accent); }
