/* Shared look for the finance tools: same palette and type as the DCF Calculator. */
:root {
  --bg: #06272c; --fg: #f3efe4; --muted: #a8c3c0; --surface: #0d3a40; --surface2: #0a3136; --rule: #2a5b60;
  --accent: #e2b659; --eq: #ff6f5b; --ip: #3fd8c4; --on-acc: #06272c; --warn: #ffb36b;
  --display: "Fraunces", Georgia, serif; --body: "Archivo", "Helvetica Neue", Helvetica, sans-serif;
  --acc: var(--accent);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f8fc; --fg: #0a1b2e; --muted: #42566c; --surface: #ffffff; --surface2: #eef3f9; --rule: #c5d3e3;
    --eq: #c7321e; --ip: #00776d; --accent: #005bbb; --on-acc: #ffffff; --warn: #a14d00; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f5f8fc; --fg: #0a1b2e; --muted: #42566c; --surface: #ffffff; --surface2: #eef3f9; --rule: #c5d3e3;
  --eq: #c7321e; --ip: #00776d; --accent: #005bbb; --on-acc: #ffffff; --warn: #a14d00; color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--fg); font: 400 15px/1.45 var(--body); font-variant-numeric: tabular-nums; }
a { color: var(--acc); }
.wrap { max-width: 1360px; margin: 0 auto; padding: 24px 32px 64px; }
header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; margin-bottom: 20px; }
.crumb { font-size: 13px; margin-bottom: 6px; display: block; text-decoration: none; font-weight: 600; }
.crumb:hover { text-decoration: underline; }
h1 { font: 600 28px/1.15 var(--display); letter-spacing: -0.01em; }
h1 small { display: block; font: 400 14px/1.4 var(--body); color: var(--muted); margin-top: 4px; letter-spacing: 0; max-width: 720px; }
h2 { font: 600 19px/1.2 var(--display); }
.tools { display: flex; gap: 8px; align-items: center; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }

.grid { display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 24px; align-items: start; }
.grid > *, .stack > *, .two > *, .hero > * { min-width: 0; }
.card { background: var(--surface); border-radius: 12px; padding: 20px 22px; }
.stack { display: grid; gap: 20px; }
.btn { font: 600 14px/1.2 var(--body); color: var(--fg); background: var(--surface2); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 14px; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn:hover { border-color: var(--acc); }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: 13px; }
select.btn { appearance: auto; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.grp { border-top: 1px solid var(--rule); padding-top: 16px; margin-top: 16px; }
.grp h3 { font: 600 16px/1.2 var(--display); margin-bottom: 8px; }
.gnote { font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 6px; }
.f { display: grid; grid-template-columns: 1fr 132px; gap: 4px 12px; align-items: center; padding: 6px 0; }
.f label { font-weight: 500; }
.f .note { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.in { position: relative; }
.in input, .in select { width: 100%; font: 600 15px/1 var(--body); font-variant-numeric: tabular-nums; text-align: right; color: var(--fg); background: var(--bg); border: 1px solid var(--rule); border-radius: 7px; padding: 9px 30px 9px 8px; min-height: 44px; }
.in select { text-align: left; padding-right: 8px; }
.in input.nounit { padding-right: 10px; }
.in input[type="text"] { text-align: left; font-weight: 500; padding-right: 8px; }
.in span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.f.chg input, .f.chg select { border: 2px solid var(--acc); }

/* editable lists: expenses, debts, holdings, cash flows */
.list { display: grid; gap: 6px; }
.lrow { display: grid; gap: 6px; align-items: center; }
.lhead { font-size: 12px; color: var(--muted); font-weight: 600; }
.lrow .in input, .lrow .in select { min-height: 40px; font-size: 14px; padding: 7px 24px 7px 6px; }
.lrow .in input[type="text"], .lrow .in select { padding-right: 6px; }
.lrow .in span { right: 6px; font-size: 12px; }
.x { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface2); color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.x:hover { color: var(--eq); border-color: var(--eq); }

.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.stat { background: var(--surface2); border-radius: 10px; padding: 16px 18px; display: grid; gap: 6px; align-content: start; }
.stat .lb { font-size: 13px; color: var(--muted); }
.stat .v { font: 600 32px/1.05 var(--display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat .s { font-size: 13px; color: var(--muted); }
.stat.main { background: var(--acc); color: var(--on-acc); }
.stat.main .lb, .stat.main .s { color: inherit; }
.up { color: var(--ip); } .dn { color: var(--eq); }
.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); border: 1px solid var(--warn); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.warn:empty { display: none; }
.sub { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.rows { display: grid; font-size: 14.5px; }
.rows div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--rule); }
.rows div:first-child { border-top: 0; }
.rows span { color: var(--muted); }
.rows b { text-align: right; }
.rows .tot span, .rows .tot b { color: var(--fg); font-weight: 700; }

.tw { overflow-x: auto; max-height: 460px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 8px; text-align: right; white-space: nowrap; border-top: 1px solid var(--rule); }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; border-top: 0; position: sticky; top: 0; background: var(--surface); }
tr.em td { font-weight: 700; }
td.on { background: var(--acc); color: var(--on-acc); font-weight: 700; border-radius: 4px; }

/* horizontal bars */
.bars { display: grid; gap: 10px; }
.bars .b { display: grid; gap: 4px; }
.bars .t { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.bars .t span { color: var(--muted); }
.bars .track { height: 10px; background: var(--surface2); border-radius: 999px; position: relative; overflow: hidden; }
.bars .fill { position: absolute; inset: 0 auto 0 0; background: var(--acc); border-radius: 999px; }
.bars .fill.ip { background: var(--ip); } .bars .fill.eq { background: var(--eq); }
.bars .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg); opacity: .7; }

.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--body); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* simple / advanced */
.seg { display: inline-flex; background: var(--surface2); border: 1px solid var(--rule); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { font: 600 14px/1.2 var(--body); color: var(--muted); background: transparent; border: 0; border-radius: 6px; padding: 8px 12px; min-height: 36px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--acc); color: var(--on-acc); }
body.simple #out .card:not([data-simple]), body.simple .stat[data-adv] { display: none; }
body:not(.simple) [data-only-simple] { display: none; }
ul.say { list-style: none; display: grid; gap: 10px; font-size: 16px; line-height: 1.5; }
ul.say li { padding-left: 22px; position: relative; }
ul.say li::before { content: ""; position: absolute; left: 4px; top: .6em; width: 8px; height: 8px; border-radius: 50%; background: var(--acc); }
ul.say b { color: var(--acc); }
.btn:disabled { opacity: .6; cursor: progress; }
.tools { flex-wrap: wrap; }

/* presets, wide layout */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font: 600 14px/1.2 var(--body); color: var(--fg); background: var(--surface2); border: 1px solid var(--rule); border-radius: 999px; padding: 9px 14px; min-height: 38px; cursor: pointer; }
.chip:hover { border-color: var(--acc); }
.grid.wide { grid-template-columns: minmax(0, 1fr); }
.grid.wide main { order: -1; }
.grid.wide .hero { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid.wide .stat .v { font-size: 28px; overflow-wrap: normal; }
.in input[type="date"] { text-align: left; font-weight: 500; padding-right: 6px; }
label.btn { cursor: pointer; }
td.pos { color: var(--ip); } td.neg { color: var(--eq); }

/* formula reference tables */
table.fx td { white-space: normal; vertical-align: top; }
table.fx td:nth-child(2) { white-space: nowrap; font-weight: 600; }
table.fx code { font: 500 12.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface2); border: 1px solid var(--rule); border-radius: 5px; padding: 2px 6px; color: var(--fg); white-space: nowrap; }
table.fx td.fxn { color: var(--muted); font-size: 12.5px; text-align: left; min-width: 180px; }
table.fx th:nth-child(3), table.fx td:nth-child(3), table.fx th:nth-child(4) { text-align: left; }

/* find what it takes */
details.seek summary { cursor: pointer; font: 600 16px/1.2 var(--display); list-style: revert; }
.seekgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.seekgrid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.seekgrid label:last-child { grid-column: 1 / -1; }
.seekgrid select, .seekgrid input { font: 500 14px/1.2 var(--body); color: var(--fg); background: var(--bg); border: 1px solid var(--rule); border-radius: 7px; padding: 9px 8px; min-height: 42px; width: 100%; }
.seekgrid .in input { padding-right: 26px; text-align: right; }
#seek-res b { color: var(--acc); }
.credit { text-align: center; margin-top: 28px; }

/* hub */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border-radius: 12px; padding: 20px 22px; text-decoration: none; color: var(--fg); display: grid; gap: 8px; border: 1px solid transparent; }
.tile:hover { border-color: var(--acc); }
.tile .k { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--acc); }
.tile h2 { font-size: 21px; }
.tile p { font-size: 14px; color: var(--muted); }
.foot { margin-top: 32px; font-size: 13px; color: var(--muted); }

@media (max-width: 980px) { .grid, .two { grid-template-columns: 1fr; } }
body.simple .two:not(:has([data-simple])) { display: none; }
body.simple .two:has(.card:not([data-simple])) { grid-template-columns: 1fr; }
.cell { min-width: 0; }
.cap { display: none; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
@media (max-width: 560px) {
  .wrap { padding: 16px 16px 48px; }
  .lhead { display: none; }
  .lrow { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; padding: 10px 0; border-top: 1px solid var(--rule); }
  .lrow:nth-child(2) { border-top: 0; }
  .lrow > .cell:first-child { grid-column: 1 / -1; }
  .cap { display: block; }
  .lrow .x { align-self: end; justify-self: end; width: auto; height: 40px; padding: 0 12px; font-size: 13px; }
  .lrow .x:nth-child(even) { grid-column: 1 / -1; height: 32px; }
  .lrow .x::after { content: " Remove"; }
  .f { grid-template-columns: 1fr 120px; }
  .stat .v { font-size: 26px; }
}
