/* =========================================================
   Financial Calculator page. Load after tool.css, calculator.css, vintage.css.
   ========================================================= */

/* ---------- Modern ---------- */
.fin-modern { max-width: 760px; }
.fin-modern > [data-fin-pane] > .panel + .panel,
.fin-modern > [data-fin-pane] > section + section { margin-top: 16px; }
.fin-tabs { margin-bottom: 14px; flex-wrap: wrap; }
.fin-tabs button { padding: 8px 14px; font-size: 0.9rem; }

.solve-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.solve-chips button {
  font: inherit;
  font-size: 0.86rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
}
.solve-chips button:hover { border-color: var(--accent); }
.solve-chips button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.solve-chips button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.fin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.fin-grid > * { min-width: 0; }
@media (max-width: 560px) { .fin-grid { grid-template-columns: minmax(0, 1fr); } }
.fin-field label .hint { font-size: 0.8rem; }
.fin-field.is-solved .input-wrap { background: var(--accent-soft); border-color: var(--accent); }
.fin-field.is-solved input { font-weight: 700; color: var(--accent); cursor: default; }
.fin-field.is-solved label::after { content: " ← answer"; color: var(--accent); font-weight: 600; font-size: 0.8rem; }
.fin-field.is-solved .flip { visibility: hidden; }
.flip {
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 1rem;
  width: 38px;
  align-self: stretch;
  cursor: pointer;
}
.flip:hover { color: var(--text); }
.fin-timing { display: flex; width: 100%; }
.fin-timing button { flex: 1; padding: 9px 8px; }

.fin-sign-hint { font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }
.fin-sign-hint strong { color: var(--text); }
.fin-error { margin: 10px 0 0; color: #dc2626; font-size: 0.92rem; }
html[data-mode="dark"] .fin-error { color: #f87171; }
@media (prefers-color-scheme: dark) { html[data-mode="auto"] .fin-error { color: #f87171; } }
.fin-stats { margin-top: 16px; }
.fin-stats[hidden] { display: none; }
.result-big .value { overflow-wrap: anywhere; }

/* Cash flow rows */
.cf-head, .cf-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 96px 30px;
  gap: 8px;
  align-items: center;
}
.cf-head { font-size: 0.78rem; font-weight: 600; color: var(--muted); margin: 6px 0 6px; }
.cf-list { display: grid; gap: 8px; }
.cf-idx { color: var(--muted); font-size: 0.85rem; text-align: center; font-variant-numeric: tabular-nums; }
.cf-row .input-wrap input { height: 38px; }
.cf-times .affix { padding: 0 8px; }
.fn-remove {
  width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.fn-remove:hover { background: var(--surface-2); color: var(--text); }
.add-fn { margin-top: 10px; width: 100%; }

/* Examples */
.example-list { display: grid; gap: 8px; }
.example-list button {
  display: grid;
  gap: 2px;
  text-align: left;
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}
.example-list button:hover { border-color: var(--accent); background: var(--surface-2); }
.example-list strong { font-size: 0.92rem; }
.example-list span { font-size: 0.82rem; color: var(--muted); }

/* ---------- Classic RPN financial: same body as the scientific Classic RPN ---------- */
.fin-rpn .fin-regs div { display: grid; grid-template-columns: 14px minmax(0, 1fr) 30px minmax(0, 1fr); gap: 6px; }
.fin-rpn .fin-regs span { text-align: right; }
.fin-rpn .rpn-ann .ann-right { margin-left: auto; }
@media (max-width: 620px) {
  .fin-rpn .fin-regs div { grid-template-columns: 12px minmax(0, 1fr) 26px minmax(0, 1fr); gap: 4px; }
  .fin-rpn .vkey-shift { letter-spacing: -0.05em; font-size: 0.46rem; }
}

/* ---------- Classic algebraic financial: same body as the scientific Classic algebraic ---------- */
.fin-alg { max-width: 400px; }
.fin-alg .classic-row { justify-content: flex-start; min-width: 0; gap: 4px; }
.fin-alg .falg-label { font-size: 1.05rem; white-space: nowrap; }
.fin-alg .falg-flag { font-size: 1.05rem; width: 1ch; }
.fin-alg .classic-val { flex: 1; min-width: 0; text-align: right; }
.fin-alg .classic-ann { gap: 8px; font-size: 0.58rem; }
.fin-alg .classic-keys { gap: 5px 7px; }
.fin-alg .vkey { font-size: 0.74rem; white-space: nowrap; overflow: hidden; }
.fin-alg .vkey-shift { font-size: 0.58rem; }
.fin-alg .vkey-cell.tall { grid-row: span 2; display: flex; flex-direction: column; }
.fin-alg .vkey.eq { flex: 1; height: auto; }
@media (max-width: 400px) {
  .fin-alg .vkey { font-size: 0.66rem; }
  .fin-alg .vkey-shift { font-size: 0.5rem; }
}

/* ---------- Modern financial keypad ---------- */
.tvm-regs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: -4px 0 14px;
}
.tvm-regs button {
  font: inherit;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 8px;
  cursor: pointer;
  min-width: 0;
}
.tvm-regs button:hover { background: var(--surface-2); }
.tvm-regs .reg-k { display: block; font-size: 0.7rem; font-weight: 700; color: var(--accent); letter-spacing: 0.04em; }
.tvm-regs .reg-val { display: block; font-size: 0.92rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key.tvm { font-weight: 700; color: var(--accent); }
.key small { font-size: 0.72em; color: var(--muted); font-weight: 500; }
.amort-out {
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline;
  margin: -4px 0 14px; padding: 8px 12px; border-radius: 10px;
  background: var(--accent-soft); font-size: 0.85rem;
}
.amort-out b { font-variant-numeric: tabular-nums; }
.cf-panel-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 260px; overflow-y: auto; }
.cf-panel-list li { display: grid; grid-template-columns: 44px minmax(0, 1fr) 28px; align-items: center; gap: 6px; padding: 5px 0; }
.cf-panel-list li + li { border-top: 1px solid var(--border); }
.cf-k { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.cf-v { text-align: right; font-variant-numeric: tabular-nums; }
.cf-del { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; border-radius: 6px; }
.cf-del:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 640px) {
  .tvm-regs { gap: 4px; }
  .tvm-regs button { padding: 5px 6px; }
  .tvm-regs .reg-val { font-size: 0.8rem; }
}
.fin-stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fin-stats .stat .value { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .tvm-regs { gap: 3px; }
  .tvm-regs button { padding: 4px 3px; text-align: center; border-radius: 8px; }
  .tvm-regs .reg-val { font-size: 0.68rem; letter-spacing: -0.03em; text-overflow: clip; }
  .tvm-regs .reg-k { font-size: 0.62rem; }
}
