/* FinKit: the calculator forms and result panels, the invoice editor and
   the printed document. Everything else comes from the shared design
   system in styles.css. */

/* ---------- form controls the shared sheet does not cover ---------- */
input[type="email"], input[type="tel"], input[type="date"], input[type="url"], textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper-bright);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.45; }
.fin-form input[type="text"], .fin-form input[type="number"], .fin-form select { width: 100%; box-sizing: border-box; }
.fin-form .field { margin: 0.9rem 0; }
.fin-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
@media (max-width: 620px) { .fin-grid2 { grid-template-columns: 1fr; } }
.fin-sub { font-size: 1.05rem; margin: 1.4rem 0 0.2rem; color: var(--ink-soft); }
.fin-suffix { display: flex; align-items: center; gap: 0.5rem; }
.fin-suffix input { flex: 1; }
.fin-suffix span { font-family: var(--font-display); font-weight: 700; color: var(--ink-soft); }

/* ---------- calculator results ---------- */
.fin-result { margin-top: 1.4rem; }
.fin-error { color: var(--accent); font-weight: 600; margin: 0.8rem 0 0; }
.fin-headline { margin: 0 0 1rem; display: grid; gap: 0.15rem; }
.fin-headline .fin-value {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 2.9rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.fin-headline .fin-label { color: var(--ink-soft); font-size: 1rem; }
.fin-note { color: var(--ink-faint); font-size: 0.95rem; margin: 0.4rem 0 0; }

.fin-breakdown { margin: 1rem 0 0; display: grid; gap: 0.35rem; }
.fin-breakdown > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); }
.fin-breakdown dt { color: var(--ink-soft); }
.fin-breakdown dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.fin-breakdown .is-total { border-bottom: none; border-top: 2px solid var(--ink); margin-top: 0.3rem; padding-top: 0.6rem; }
.fin-breakdown .is-total dt, .fin-breakdown .is-total dd { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--ink); }

/* the split bar under the headline */
.fin-bar { display: flex; height: 0.9rem; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: var(--paper-bright); }
.fin-bar span { display: block; height: 100%; }
.fin-bar-principal { background: var(--sage); }
.fin-bar-interest { background: var(--accent); }
.fin-bar-growth { background: var(--gold); }

/* schedules */
.fin-table-wrap { overflow-x: auto; margin-top: 1.4rem; }
.fin-table { border-collapse: collapse; width: 100%; font-size: 0.95rem; min-width: 26rem; }
.fin-table caption { font-family: var(--font-display); font-weight: 700; text-align: left; margin-bottom: 0.5rem; color: var(--ink); }
.fin-table th, .fin-table td { padding: 0.45rem 0.6rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.fin-table thead th { border-bottom: 2px solid var(--ink); font-family: var(--font-display); }
.fin-table th[scope="row"] { text-align: left; font-weight: 600; }
/* the first column holds the row's name, so its heading is left aligned too */
.fin-table thead th:first-child { text-align: left; }
.fin-table tbody tr:nth-child(even) { background: rgba(217, 205, 178, 0.18); }

/* ---------- the invoice editor ---------- */
/* the preview column stretches so the sticky document can travel with the
   long form next to it */
.inv-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; align-items: stretch; margin: 2rem auto 3rem; }
@media (max-width: 1080px) { .inv-layout { grid-template-columns: minmax(0, 1fr); } }

.inv-items { display: grid; gap: 0.5rem; margin-top: 0.6rem; }
.inv-item { display: grid; gap: 0.5rem; align-items: center; }
.inv-item input { width: 100%; box-sizing: border-box; }
.inv-line-total { font-weight: 600; text-align: right; font-size: 0.95rem; white-space: nowrap; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.3rem; }
.inv-file { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.inv-logo-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
input[type="file"] { font-size: 0.95rem; max-width: 100%; }

/* The document itself (preview and print) lives in assets/doc.css, which is
   loaded on the invoice page only. */

/* a checkbox reads as one line, so the label wraps the control */
.field--check label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.field--check input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); flex: none; }
/* the source link under a country picker */
.small-note a { color: var(--accent-dark); }

/* a result that is waiting on a half-typed number: still readable, clearly
   not the answer to what is on screen right now */
.fin-result.is-stale { opacity: 0.45; transition: opacity 0.15s ease; }

/* the line editor grows a unit, an optional discount and an optional tax
   rate, so the row is described once per combination */
.inv-item { grid-template-columns: minmax(0, 1fr) 3.6rem 4rem 5.8rem auto auto; }
.inv-item--disc { grid-template-columns: minmax(0, 1fr) 3.2rem 3.6rem 5.2rem 4rem auto auto; }
.inv-item--tax { grid-template-columns: minmax(0, 1fr) 3.2rem 3.6rem 5.2rem 4rem auto auto; }
.inv-item--disc.inv-item--tax { grid-template-columns: minmax(0, 1fr) 3rem 3.2rem 4.8rem 3.6rem 3.6rem auto auto; }
.inv-row-actions { display: inline-flex; gap: 0.2rem; }
.inv-act {
  border: 2px solid var(--ink); background: var(--paper-bright); color: var(--ink);
  border-radius: 8px; width: 1.9rem; height: 1.9rem; cursor: pointer; font-size: 0.85rem;
  line-height: 1; padding: 0; flex: none;
}
.inv-act:hover { background: var(--ink); color: var(--paper-bright); }
.inv-del:hover { background: var(--accent); color: var(--paper-bright); border-color: var(--accent); }
@media (max-width: 760px) {
  .inv-item, .inv-item--disc, .inv-item--tax, .inv-item--disc.inv-item--tax {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas: "d d d d" "q u p e" "x x t t" "a a a a";
    row-gap: 0.4rem;
  }
  .inv-item input[data-f="desc"] { grid-area: d; }
  .inv-item input[data-f="qty"] { grid-area: q; }
  .inv-item input[data-f="unit"] { grid-area: u; }
  .inv-item input[data-f="price"] { grid-area: p; }
  .inv-item input[data-f="disc"] { grid-area: e; }
  .inv-item input[data-f="tax"] { grid-area: x; }
  .inv-line-total { grid-area: t; }
  .inv-row-actions { grid-area: a; justify-content: flex-end; }
}
