/* Finance Calculators — shared styles. Lightweight, no external fonts (CWV-friendly). */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --ink: #1a2231;
  --muted: #5c6878;
  --line: #e4e8ee;
  --brand: #1763d6;
  --brand-ink: #0f4aa3;
  --accent: #14b8a6;
  --pos: #16a34a;
  --principal: #94a3b8;
  --contrib: #1763d6;
  --interest: #14b8a6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  /* Sticky footer: fill the viewport and let <main> push the footer to the bottom. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* width:100% gives <main> a definite cross-size so it fills up to .container's
   max-width and stays centered — without it, auto margins shrink it to content. */
main { flex: 1 0 auto; width: 100%; }
.site-header, .site-footer { flex-shrink: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* Header / footer */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-weight: 800; font-size: 18px; color: var(--ink); letter-spacing: -.3px; }
.logo span { color: var(--brand); }
.nav a { color: var(--muted); font-weight: 600; font-size: 14px; margin-left: 18px; }
.site-footer {
  margin-top: 56px; padding: 28px 0; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; background: var(--card);
}
.site-footer a { color: var(--muted); }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Breadcrumbs */
.breadcrumbs {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 0; font-size: 13px; color: var(--muted);
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs .sep { margin: 0 6px; opacity: .5; }
.breadcrumbs .current { color: var(--ink); font-weight: 600; }

/* Hero / headings */
h1 { font-size: 30px; line-height: 1.25; letter-spacing: -.5px; margin: 28px 0 6px; }
.subtitle { color: var(--muted); font-size: 17px; margin: 0 0 24px; }
h2 { font-size: 22px; margin: 36px 0 12px; letter-spacing: -.3px; }
h3 { font-size: 17px; margin: 22px 0 8px; }
p { margin: 0 0 14px; }

/* Calculator card */
.calc {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-top: 8px;
}
@media (max-width: 720px) { .calc { grid-template-columns: 1fr; } }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .prefix, .input-wrap .suffix {
  position: absolute; color: var(--muted); font-size: 15px; pointer-events: none;
}
.input-wrap .prefix { left: 12px; }
.input-wrap .suffix { right: 12px; }
.field input[type="number"], .field select {
  width: 100%; padding: 11px 12px; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; transition: border-color .15s;
}
.field input.has-prefix { padding-left: 30px; }
.field input.has-suffix { padding-right: 36px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Result panel */
.result { background: linear-gradient(160deg, #f0f6ff, #f7fbfa); border-radius: 10px; padding: 20px; }
.result .big {
  font-size: 38px; font-weight: 800; letter-spacing: -1px; color: var(--brand-ink); line-height: 1.1;
}
.result .big-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.breakdown { margin-top: 18px; display: grid; gap: 10px; }
.breakdown .row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.breakdown .row .k { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.breakdown .row .v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Simple inline tool (e.g. percentage calculator) */
.pct-tool {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-top: 16px;
}
.pct-tool h2 { margin: 0 0 12px; font-size: 18px; }
.pct-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.pct-row .field { margin-bottom: 0; flex: 1 1 130px; }
.pct-result {
  margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: var(--bg);
  font-size: 20px; font-weight: 700; color: var(--brand-ink); font-variant-numeric: tabular-nums;
}

/* Chart */
.chart { margin-top: 18px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Table */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: #fafbfc; }

/* Article / content */
.article { margin-top: 8px; }
.article ul { padding-left: 20px; }
.faq dt { font-weight: 700; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--ink); }
.formula { background: #f1f3f7; border-radius: 8px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; overflow-x: auto; }

/* Calculator index cards (homepage) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.08); text-decoration: none; }
.card .t { font-weight: 700; color: var(--ink); font-size: 16px; }
.card .d { color: var(--muted); font-size: 13px; margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; color: var(--muted); background: #eef1f5; border-radius: 20px; padding: 2px 9px; margin-left: 6px; }
.badge.soon { color: #92760a; background: #fdf3d3; }

/* Presets */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.preset {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--brand-ink); background: #eef4fd; border: 1px solid #d6e4fb;
  border-radius: 20px; padding: 6px 13px; transition: background .12s;
}
.preset:hover { background: #e1ecfc; }

/* Share + buttons */
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  border-radius: 8px; padding: 9px 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }

/* Theme toggle */
.theme-toggle {
  font: inherit; cursor: pointer; background: transparent; border: 1px solid var(--line);
  border-radius: 8px; width: 36px; height: 34px; color: var(--muted); margin-left: 18px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Dark theme ---- */
:root[data-theme="dark"] {
  --bg: #0f141b;
  --card: #161d27;
  --ink: #e6ebf2;
  --muted: #93a1b3;
  --line: #2a3340;
  --brand: #4d94ff;
  --brand-ink: #7db1ff;
  --principal: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
:root[data-theme="dark"] .result { background: linear-gradient(160deg, #16202e, #14201f); }
:root[data-theme="dark"] .field input, :root[data-theme="dark"] .field select { background: #0f141b; color: var(--ink); }
:root[data-theme="dark"] .preset { background: #1a2737; border-color: #26384f; color: var(--brand-ink); }
:root[data-theme="dark"] .preset:hover { background: #21344a; }
:root[data-theme="dark"] .formula { background: #0f141b; }
:root[data-theme="dark"] .badge { background: #232d3a; }
:root[data-theme="dark"] tbody tr:hover { background: #1a222d; }
