:root { --bg:#f5f6f8; --card:#fff; --text:#1c2230; --muted:#667085; --line:#e3e6ec; --accent:#2457d6; --pos:#12805c; --neg:#c0392b; --warn:#b7791f; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#12151c; --card:#1b2029; --text:#e6e9f0; --muted:#98a2b3; --line:#2b3240; --accent:#6c93ff; --pos:#3ecf9a; --neg:#ff7b6b; --warn:#e5b45a; }
}
* { box-sizing: border-box; }
body { margin:0; font:15px/1.45 system-ui, sans-serif; background:var(--bg); color:var(--text); }
header { display:flex; align-items:center; gap:14px; padding:10px 16px; background:var(--card); border-bottom:1px solid var(--line); flex-wrap:wrap; }
nav { display:flex; gap:4px; flex-wrap:wrap; }
nav a { padding:6px 10px; border-radius:6px; color:var(--muted); text-decoration:none; }
nav a.on { background:var(--accent); color:#fff; }
.spacer { flex:1; }
main { max-width:1500px; margin:0 auto; padding:16px; }
h2 { margin:0 0 10px; font-size:18px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px; margin-bottom:14px; }
.narrow { max-width:340px; margin:12vh auto; display:grid; gap:10px; }
.grid { display:grid; gap:14px; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); }
.stat { font-size:24px; font-weight:600; }
.muted { color:var(--muted); font-size:13px; }
.pos { color:var(--pos); } .neg { color:var(--neg); } .warn { color:var(--warn); }
.err { color:var(--neg); min-height:1.2em; margin:0; }
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--line); vertical-align:middle; }
th { color:var(--muted); font-weight:500; font-size:13px; }
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
input, select, button { font:inherit; color:inherit; background:var(--card); border:1px solid var(--line); border-radius:6px; padding:6px 9px; }
button { background:var(--accent); color:#fff; border-color:var(--accent); cursor:pointer; }
button.ghost { background:transparent; color:var(--text); border-color:var(--line); }
button.danger { background:transparent; color:var(--neg); border-color:var(--neg); }
button.small { padding:2px 8px; font-size:13px; }
label { display:grid; gap:3px; font-size:13px; color:var(--muted); }
.row { display:flex; gap:10px; flex-wrap:wrap; align-items:end; margin-bottom:10px; }
.badge { display:inline-block; padding:1px 8px; border-radius:99px; font-size:12px; border:1px solid var(--line); }
.badge.ok { color:var(--pos); border-color:var(--pos); } .badge.bad { color:var(--neg); border-color:var(--neg); }
.bar { height:8px; background:var(--line); border-radius:4px; overflow:hidden; } .bar > i { display:block; height:100%; background:var(--accent); }
.scroll { overflow-x:auto; }
#toast { position:fixed; bottom:16px; left:50%; transform:translateX(-50%); background:var(--text); color:var(--bg); padding:8px 14px; border-radius:8px; opacity:0; transition:opacity .2s; pointer-events:none; }
#toast.show { opacity:1; }

/* ---- no clipped content: shrinkable form controls, wide-table fallback, stacked cards on small screens ---- */
[hidden] { display:none !important; }
input, select { max-width:100%; min-width:0; }
.row > *, label { min-width:0; max-width:100%; }
.card { overflow-wrap:anywhere; }
.scroll { max-width:100%; }
td input, td select { width:100%; min-width:70px; }
td.num input { text-align:right; }
@media (max-width: 1100px) {
  table.stack, table.stack tbody { display:block; }
  table.stack thead { display:none; }
  table.stack tr { display:block; border:1px solid var(--line); border-radius:8px; margin:0 0 10px; padding:6px 8px; }
  table.stack td { display:flex; justify-content:space-between; align-items:center; gap:12px; border:0; padding:3px 0; text-align:right; white-space:normal; }
  table.stack td::before { content:attr(data-label); color:var(--muted); font-size:12px; text-align:left; flex:0 0 38%; }
  table.stack td:empty { display:none; }
  table.stack td input, table.stack td select { flex:1; width:auto; min-width:0; }
  table.stack td[colspan] { display:block; text-align:left; }
  table.stack td[colspan]::before { content:none; }
}

/* growing text areas (insurance, asset notes) and the small asset-notes font */
textarea { font:inherit; color:inherit; background:var(--card); border:1px solid var(--line); border-radius:6px; padding:6px 9px; width:100%; min-width:120px; resize:vertical; overflow:hidden; line-height:1.35; }
textarea.note8 { font-size:8pt; min-width:180px; }

/* transactions: fixed column widths so dates never wrap, roomy rows, wrapping descriptions */
table.txns { table-layout:fixed; }
table.txns th, table.txns td { padding:10px 12px; line-height:1.4; }
table.txns td:nth-child(1) { white-space:nowrap; color:var(--muted); }
table.txns td:nth-child(2) { overflow-wrap:anywhere; font-weight:500; }
table.txns td:nth-child(3) { color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
table.txns td select { min-width:0; }
table.txns tbody tr:nth-child(even) { background:rgba(127,127,127,.07); }
#tf { padding-bottom:4px; }
@media (max-width: 1100px) { table.txns { table-layout:auto; } table.txns td:nth-child(2) { font-weight:600; } }

/* insurance: the stacked cells share width so the table fits without a sideways scroll */
.card table td textarea { min-width:90px; }

/* money inputs: fixed R prefix */
.rin { position:relative; display:inline-block; max-width:100%; }
.rin > span { position:absolute; left:9px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
.rin > input { padding-left:24px; width:100%; }
table.stack td .rin { flex:1; }

/* overview dashboard */
.grid2 { display:grid; gap:14px; grid-template-columns:repeat(auto-fit, minmax(420px, 1fr)); }
.tile .stat { font-size:22px; }
.legend { display:flex; gap:14px; flex-wrap:wrap; margin-top:6px; font-size:13px; color:var(--muted); }
.legend span { display:inline-flex; align-items:center; gap:6px; }
.legend i { width:11px; height:11px; border-radius:3px; display:inline-block; }
.legend.v { flex-direction:column; align-items:flex-start; gap:6px; margin:0; }
.donutwrap { display:flex; gap:18px; align-items:center; flex-wrap:wrap; }
.hb { margin:8px 0; } .hbl { display:flex; justify-content:space-between; gap:10px; font-size:14px; margin-bottom:3px; }
@media (max-width: 520px) { .grid2 { grid-template-columns:1fr; } }
