/* Flowjar web tools (/tools, /tools/loan-compare, /tools/savings). Loaded after site.css; uses its tokens. */

:root {
  --c1: #0A0A0A;
  --c2: #1E8E3E;
  --c3: #F05A1A;
  --c4: #2F6FEB;
  --c5: #8A3FFC;
  --warn: #B3261E;
  --warn-bg: #FDF1F0;
  --good-bg: #EEF7F0;
  --field-h: 48px;
}

.tool-head { padding-bottom: clamp(24px, 3vw, 40px); }
.tool-head .lead { max-width: 720px; }
.tool-note {
  margin-top: 18px; max-width: 720px;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: 16px;
  background: var(--surface); color: var(--body);
  font-size: 14px; line-height: 1.45;
}
.tool-note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tool-note b { color: var(--ink-2); font-weight: 600; }

.tool-section { margin-top: clamp(40px, 5vw, 64px); }
.tool-section > .sec-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.sec-title { font-size: clamp(24px, 2.4vw, 32px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.15; }
.sec-sub { margin-top: 6px; color: var(--body); font-size: 15px; max-width: 640px; }

/* ---------- Form ---------- */

.panel {
  border: 1px solid var(--line); border-radius: 24px;
  padding: clamp(18px, 2.4vw, 28px);
  background: var(--bg);
}
.panel.soft-panel { background: var(--surface); border-color: transparent; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px 20px; }
[data-tool] [hidden] { display: none !important; }
.field { display: grid; gap: 7px; min-width: 0; align-content: start; }
.field > .lbl { font-size: 13.5px; font-weight: 600; color: var(--ink-2); letter-spacing: -0.005em; }
.field > .hint { font-size: 12.5px; color: var(--body); line-height: 1.4; }
.field.wide { grid-column: 1 / -1; }

.inp {
  display: flex; align-items: center; min-width: 0;
  height: var(--field-h); padding-inline: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.inp:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(10,10,10,.08); }
.inp input, .inp select {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent; padding: 0;
  font: inherit; font-size: 16px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.inp select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-inline-end: 22px; }
.inp.sel { position: relative; }
.inp.sel::after {
  content: ""; position: absolute; inset-inline-end: 16px; top: 50%;
  width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--body); border-bottom: 2px solid var(--body);
  transform: rotate(45deg); pointer-events: none;
}
.inp .affix { flex: none; color: var(--body); font-size: 14px; font-weight: 600; }
.inp .affix:first-child { margin-inline-end: 8px; }
.inp .affix:last-child { margin-inline-start: 8px; }
.inp.sm { height: 42px; border-radius: 12px; padding-inline: 12px; }
.inp.sm input, .inp.sm select { font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 14.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { border-color: #cfcfcf; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip-inp { width: 104px; }

.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  border-radius: 999px; background: var(--surface);
}
.seg button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; font-size: 14px; font-weight: 600; color: var(--body); cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.block { display: flex; border-radius: 16px; }
.seg.block button { flex: 1 1 auto; border-radius: 12px; }

/* ---------- Offers ---------- */

.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.offer {
  position: relative; display: grid; gap: 12px;
  padding: 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg);
  border-top: 4px solid var(--oc, var(--ink));
}
.offer-top { display: flex; align-items: center; gap: 8px; }
.offer-top .inp { flex: 1; }
.offer-top input { font-weight: 700; }
.offer .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.offer .field > .lbl { font-size: 12.5px; }
.icon-btn {
  flex: none; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px; border: 0;
  background: var(--surface); color: var(--body); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.add-offer {
  display: grid; place-items: center; gap: 6px; min-height: 180px;
  border: 1.5px dashed #d6d6d6; border-radius: 20px; background: transparent;
  color: var(--body); font-size: 15px; font-weight: 600; cursor: pointer;
}
.add-offer:hover { border-color: var(--ink); color: var(--ink); }
.add-offer svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.add-offer[hidden] { display: none; }

/* ---------- Results ---------- */

.rank { display: grid; gap: 12px; }
.rank-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; align-items: start;
  padding: 18px 20px; border-radius: 22px; border: 1px solid var(--line);
}
.rank-card.is-best { border-color: var(--ink); box-shadow: 0 18px 40px -30px rgba(0,0,0,.45); }
.rank-no {
  grid-row: span 2; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  background: var(--surface); color: var(--ink); border-bottom: 3px solid var(--oc, var(--ink));
}
.rank-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0;
  background: var(--surface); color: var(--ink-2);
}
.badge.best { background: var(--ink); color: var(--on-ink); }
.badge.good { background: var(--good-bg); color: var(--green-text); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px 18px; margin-top: 8px; }
.stat .k { font-size: 12.5px; color: var(--body); font-weight: 500; }
.stat .v { font-size: 19px; font-weight: 700; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat .s { font-size: 12.5px; color: var(--body); font-variant-numeric: tabular-nums; }
.stat .v.big { font-size: 24px; }
.diff-more { color: var(--warn); }
.diff-less { color: var(--green-text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 20px; -webkit-overflow-scrolling: touch; }
.table-wrap.scroll-y { max-height: 540px; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 12px 16px; text-align: end; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: start; }
table.data thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--body); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td .sub { display: block; font-size: 12.5px; color: var(--body); font-weight: 500; }
table.data td.pick { background: var(--good-bg); }
table.data td.pick .main { color: var(--green-text); }
table.data .main { font-weight: 700; }
table.data th.cur { color: var(--ink); }
table.data .oname { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; white-space: normal; min-width: 140px; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--oc, var(--ink)); }
table.data tr.fixed-end td { box-shadow: inset 0 -2px 0 var(--c3); }

.chart-box { position: relative; }
.chart-box svg { width: 100%; height: auto; overflow: visible; }
.chart-box .grid line { stroke: var(--line); }
.chart-box .axis text { fill: var(--body); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-box .ln { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-box .xline { stroke: var(--ink); stroke-dasharray: 3 3; opacity: 0; }
.chart-box.is-active .xline { opacity: .5; }
.chart-box .tip {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; opacity: 0;
  min-width: 150px; padding: 10px 12px; border-radius: 12px;
  background: var(--ink); color: var(--on-ink); font-size: 12.5px; line-height: 1.5;
  font-variant-numeric: tabular-nums; transform: translate(-50%, 0);
  transition: opacity .12s ease;
}
.chart-box.is-active .tip { opacity: 1; }
.tip .t { color: var(--on-ink-muted); font-weight: 600; margin-bottom: 2px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 13.5px; font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 14px; height: 10px; border-radius: 3px; background: var(--oc, var(--ink)); }
.legend .sw.dash { height: 3px; border-radius: 0; background: repeating-linear-gradient(90deg, var(--oc, var(--ink)) 0 5px, transparent 5px 8px); }

/* Savings: one card per horizon (10 / 15 / 25 years) */
.horizons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.hz-card { display: grid; gap: 12px; align-content: start; padding: 20px; border-radius: 22px; border: 1px solid var(--line); }
.hz-card.is-cur { border-color: var(--ink); box-shadow: 0 18px 40px -30px rgba(0,0,0,.45); }
.hz-card .k { font-size: 13.5px; font-weight: 600; color: var(--body); }
.hz-card .v { font-size: clamp(26px, 2.8vw, 34px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hz-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface); }
.hz-bar i { display: block; height: 100%; }
.hz-bar i:first-child { background: #C9C9C9; }
.hz-bar i:last-child { background: var(--c2); }
.hz-rows { display: grid; gap: 6px; font-size: 14px; }
.hz-rows div { display: flex; justify-content: space-between; gap: 12px; }
.hz-rows dt { color: var(--body); }
.hz-rows dd { font-weight: 650; font-variant-numeric: tabular-nums; text-align: end; }
.cmp-name { display: grid; gap: 2px; white-space: normal; min-width: 170px; }
.cmp-name .sub { font-size: 12.5px; color: var(--body); font-weight: 500; }
table.data td .sub.diff-more { color: var(--warn); }
table.data td .sub.diff-less { color: var(--green-text); }

.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.insight { padding: 20px; border-radius: 22px; background: var(--surface); display: grid; gap: 8px; align-content: start; }
.insight .ih { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; line-height: 1.3; }
.insight .ic { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); }
.insight .ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.insight p { color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.insight p b { font-weight: 700; }
.insight.good .ic { color: var(--green-text); }
.insight.warn { background: var(--warn-bg); }
.insight.warn .ic { color: var(--warn); }

.sched-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ---------- Open in the app ---------- */

.app-cta {
  border-radius: var(--radius); background: var(--ink); color: var(--on-ink);
  padding: clamp(24px, 3.4vw, 44px);
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px 44px; align-items: center;
}
.app-cta h2 { font-size: clamp(26px, 2.8vw, 38px); font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; }
.app-cta p { margin-top: 12px; color: var(--on-ink-muted); font-size: 16px; }
.app-cta .acts { display: grid; gap: 10px; }
.app-cta .btn { width: 100%; }
.app-cta .btn-ghost { background: transparent; color: var(--on-ink); box-shadow: inset 0 0 0 1.5px var(--on-ink-line); }
.app-cta .btn-ghost:hover { background: #161616; }
.app-cta .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-cta .fine { color: var(--on-ink-muted); font-size: 13px; }
.app-cta .chips { margin-top: 18px; }
.app-cta .chip { background: transparent; color: var(--on-ink); border-color: #3a3a3a; cursor: default; }
.app-cta .chip:hover { border-color: #3a3a3a; }
.app-fallback { grid-column: 1 / -1; border-top: 1px solid var(--on-ink-line); padding-top: 22px; display: grid; gap: 14px; }
.app-fallback[hidden] { display: none; }
.app-fallback p { margin: 0; color: var(--on-ink); font-weight: 600; }
.app-fallback .store-row { justify-content: flex-start; }
.app-fallback .btn-soon { background: #161616; color: var(--on-ink-muted); min-height: 54px; }

/* app.html: the page behind /app/… links */
.applink { padding-block: clamp(40px, 8vw, 96px); max-width: 980px; }
.applink-icon { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 20px; }
.applink .app-cta h1 { font-size: clamp(30px, 3.6vw, 46px); font-weight: 700; letter-spacing: -0.04em; line-height: 1.08; }
.applink .btn[hidden] { display: none; }
.applink-more { margin-top: 24px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px);
  padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--on-ink);
  font-size: 14.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Hub ---------- */

.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.tool-card {
  display: grid; gap: 10px; align-content: start;
  padding: clamp(22px, 2.6vw, 32px); border-radius: var(--radius);
  border: 1px solid var(--line); text-decoration: none; color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--ink); box-shadow: 0 24px 50px -36px rgba(0,0,0,.4); transform: translateY(-2px); }
.tool-card .ti { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); }
.tool-card .ti svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-card h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; }
.tool-card p { color: var(--body); font-size: 15.5px; }
.tool-card .go { margin-top: 8px; font-weight: 700; font-size: 15px; }
.tool-card ul { display: grid; gap: 4px; font-size: 14.5px; color: var(--ink-2); }
.tool-card li::before { content: "·"; margin-inline-end: 8px; color: var(--body); font-weight: 800; }
.app-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.method-notes { max-width: 820px; }

@media (max-width: 860px) {
  .app-cta { grid-template-columns: 1fr; }
  .horizons { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .rank-card { grid-template-columns: minmax(0, 1fr); }
  .rank-no { grid-row: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .insights, .offers, .tool-cards { grid-template-columns: minmax(0, 1fr); }
  .chip { padding: 0 13px; }
  table.data th, table.data td { padding: 10px 12px; }
}
@media print {
  .nav, .footer, .app-cta, .add-offer, .icon-btn { display: none !important; }
}
