/* ============================================================
   HAVV.IN FINANCIAL CALCULATORS — GLOBAL STYLESHEET
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:        #0d0f14;
  --ink-soft:   #4a4f5e;
  --ink-muted:  #8b909f;
  --surface:    #f7f8fc;
  --card:       #ffffff;
  --border:     #e8eaf0;
  --accent:     #1a6bff;
  --accent-dim: #e8f0ff;
  --accent-dark:#1452cc;
  --green:      #00a76f;
  --green-dim:  #e6f7f2;
  --red:        #e53935;
  --red-dim:    #fdecea;
  --amber:      #ff8800;
  --amber-dim:  #fff4e6;
  --purple:     #7c3aed;
  --purple-dim: #f0eaff;
  --radius:     14px;
  --shadow:     0 2px 16px rgba(0,0,0,0.07);
  --shadow-lg:  0 8px 32px rgba(26,107,255,0.13);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Nav ─────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247,248,252,0.93);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.nav-inner {
  max-width: 1100px; margin: auto;
  display: flex; align-items: center;
  justify-content: space-between; height: 58px;
}
.nav-logo {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 1.15rem; color: var(--ink);
  text-decoration: none; letter-spacing: -0.5px;
}
.nav-logo span { color: var(--accent); }
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem; color: var(--ink-muted);
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--border); }

/* ── Page wrapper ────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 40px 24px 80px; }

/* ── Page header ─────────────────────────────────────────── */
.page-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-dim); color: var(--accent);
  font-size: 0.75rem; font-weight: 600;
  padding: 4px 12px; border-radius: 100px;
  margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.04em;
}
.page-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 800; letter-spacing: -1px;
  color: var(--ink); line-height: 1.2; margin-bottom: 12px;
}
.page-header p {
  font-size: 0.97rem; color: var(--ink-soft);
  max-width: 620px; font-weight: 300; line-height: 1.7;
  margin-bottom: 32px;
}

/* ── Two-column layout ───────────────────────────────────── */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px; align-items: start;
}
@media (max-width: 860px) { .calc-layout { grid-template-columns: 1fr; } }

/* ── Calculator card ─────────────────────────────────────── */
.calc-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow);
}
.calc-card-title {
  font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700;
  color: var(--ink); margin-bottom: 24px;
}

/* ── Input group ─────────────────────────────────────────── */
.input-group { margin-bottom: 22px; }
.input-label {
  display: flex; justify-content: space-between;
  align-items: baseline; margin-bottom: 9px;
}
.input-label label {
  font-size: 0.87rem; font-weight: 600;
  color: var(--ink-soft);
}
.input-value {
  font-family: 'Syne', sans-serif;
  font-size: 1rem; font-weight: 700;
  color: var(--accent); background: var(--accent-dim);
  padding: 3px 11px; border-radius: 8px;
  min-width: 100px; text-align: center;
  border: none; outline: none; cursor: text;
}
.input-value:focus { box-shadow: 0 0 0 2px var(--accent); }

input[type=range] {
  -webkit-appearance: none; width: 100%; height: 5px;
  background: var(--border); border-radius: 100px;
  outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim); cursor: pointer;
  transition: box-shadow 0.2s;
}
input[type=range]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 6px rgba(26,107,255,0.18);
}
.range-limits {
  display: flex; justify-content: space-between;
  margin-top: 5px; font-size: 0.71rem; color: var(--ink-muted);
}

/* Select input */
.calc-select {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  color: var(--ink); background: var(--card); outline: none;
  cursor: pointer; transition: border-color 0.2s;
}
.calc-select:focus { border-color: var(--accent); }

/* Text input */
.calc-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  color: var(--ink); background: var(--card); outline: none;
  transition: border-color 0.2s;
}
.calc-input:focus { border-color: var(--accent); }

/* ── Button ──────────────────────────────────────────────── */
.calc-btn {
  width: 100%; padding: 14px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 12px; font-family: 'Syne', sans-serif;
  font-size: 0.97rem; font-weight: 700; cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.1s; margin-top: 6px;
}
.calc-btn:hover { background: var(--accent-dark); }
.calc-btn:active { transform: scale(0.99); }

/* ── Results panel ───────────────────────────────────────── */
.results-panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.results-header {
  background: var(--ink); padding: 24px 26px;
}
.results-header-label {
  font-size: 0.72rem; font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px;
}
.results-main-value {
  font-family: 'Syne', sans-serif;
  font-size: 2.2rem; font-weight: 800;
  color: #fff; letter-spacing: -1px; line-height: 1.1;
}
.results-sub {
  font-size: 0.78rem; color: rgba(255,255,255,0.4); margin-top: 4px;
}
.results-body { padding: 20px 26px; }
.result-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-label { font-size: 0.84rem; color: var(--ink-soft); font-weight: 500; }
.result-val { font-family: 'Syne', sans-serif; font-size: 0.93rem; font-weight: 700; color: var(--ink); }
.result-val.green { color: var(--green); }
.result-val.red   { color: var(--red); }
.result-val.amber { color: var(--amber); }
.result-val.accent{ color: var(--accent); }

/* ── Chart area ──────────────────────────────────────────── */
.chart-wrap {
  padding: 18px 26px; border-top: 1px solid var(--border);
}
.chart-title {
  font-size: 0.75rem; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px;
}
.chart-container { position: relative; width: 100%; max-width: 200px; margin: auto; }
.chart-bar-container { position: relative; width: 100%; height: 200px; }
.legend {
  display: flex; gap: 14px; justify-content: center;
  margin-top: 12px; flex-wrap: wrap;
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.77rem; color: var(--ink-soft); font-weight: 500;
}
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── Formula box ─────────────────────────────────────────── */
.formula-box {
  margin-top: 28px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 28px;
}
.formula-box h2 {
  font-family: 'Syne', sans-serif; font-size: 1.05rem;
  font-weight: 700; margin-bottom: 12px; color: var(--ink);
}
.formula {
  background: var(--surface); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 13px 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem; color: var(--ink-soft);
  line-height: 1.9; margin-bottom: 12px;
}
.formula strong { color: var(--accent); }
.formula-box p { font-size: 0.86rem; color: var(--ink-soft); line-height: 1.75; }

/* ── Content section ─────────────────────────────────────── */
.content-section {
  margin-top: 28px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px;
}
.content-section h2 {
  font-family: 'Syne', sans-serif; font-size: 1.08rem;
  font-weight: 700; color: var(--ink); margin-bottom: 10px;
}
.content-section h2:not(:first-child) { margin-top: 20px; }
.content-section p {
  font-size: 0.87rem; color: var(--ink-soft); line-height: 1.8; margin-bottom: 12px;
}
.content-section ul { list-style: none; padding: 0; margin-bottom: 12px; }
.content-section ul li {
  font-size: 0.86rem; color: var(--ink-soft);
  padding: 4px 0 4px 18px; position: relative; line-height: 1.6;
}
.content-section ul li::before {
  content: '→'; position: absolute; left: 0;
  color: var(--accent); font-weight: 700;
}

/* ── FAQ ─────────────────────────────────────────────────── */
.faq-section { margin-top: 28px; }
.faq-section h2 {
  font-family: 'Syne', sans-serif; font-size: 1.15rem;
  font-weight: 700; margin-bottom: 14px; color: var(--ink);
}
.faq-item {
  border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 8px; overflow: hidden; background: var(--card);
}
.faq-q {
  width: 100%; background: none; border: none; padding: 15px 18px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; text-align: left;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem; font-weight: 600; color: var(--ink);
  transition: background 0.2s;
}
.faq-q:hover { background: var(--surface); }
.faq-chevron { transition: transform 0.3s; color: var(--ink-muted); flex-shrink: 0; margin-left: 10px; }
.faq-item.open .faq-chevron { transform: rotate(180deg); }
.faq-a {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease, padding 0.2s;
  font-size: 0.85rem; color: var(--ink-soft); line-height: 1.75; padding: 0 18px;
}
.faq-item.open .faq-a { max-height: 400px; padding: 0 18px 14px; }

/* ── Related calculators ─────────────────────────────────── */
.related-section { margin-top: 36px; }
.related-section h2 {
  font-family: 'Syne', sans-serif; font-size: 1.1rem;
  font-weight: 700; margin-bottom: 14px; color: var(--ink);
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.related-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
  text-decoration: none; color: inherit;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(26,107,255,0.1);
  border-color: rgba(26,107,255,0.3);
}
.related-icon { font-size: 1.3rem; margin-bottom: 7px; }
.related-card h4 {
  font-family: 'Syne', sans-serif; font-size: 0.85rem;
  font-weight: 700; color: var(--ink); margin-bottom: 3px;
}
.related-card p { font-size: 0.76rem; color: var(--ink-muted); }

/* ── Amortization table ──────────────────────────────────── */
.table-section { margin-top: 28px; }
.table-section h2 {
  font-family: 'Syne', sans-serif; font-size: 1.1rem;
  font-weight: 700; margin-bottom: 14px; color: var(--ink);
}
.table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th {
  background: var(--ink); color: rgba(255,255,255,0.85);
  padding: 11px 14px; text-align: right;
  font-weight: 600; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
thead th:first-child { text-align: left; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
tbody td { padding: 10px 14px; text-align: right; color: var(--ink-soft); }
tbody td:first-child { text-align: left; color: var(--ink-muted); font-weight: 600; }
tbody td.c-blue  { color: var(--accent); font-weight: 600; }
tbody td.c-red   { color: var(--red); }
tbody td.c-green { color: var(--green); font-weight: 600; }
tbody td.c-dark  { color: var(--ink); font-weight: 500; }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  margin-top: 60px; border-top: 1px solid var(--border);
  padding: 28px 24px; text-align: center;
}
footer p { font-size: 0.81rem; color: var(--ink-muted); margin-bottom: 4px; }
footer a { color: var(--accent); text-decoration: none; }

/* ── Utility ─────────────────────────────────────────────── */
.mt-0 { margin-top: 0 !important; }
.info-box {
  background: var(--accent-dim); border: 1px solid rgba(26,107,255,0.2);
  border-radius: 10px; padding: 14px 18px; margin-top: 14px;
  font-size: 0.84rem; color: var(--ink-soft); line-height: 1.65;
}
.info-box strong { color: var(--accent); }
.warn-box {
  background: var(--amber-dim); border: 1px solid rgba(255,136,0,0.2);
  border-radius: 10px; padding: 14px 18px; margin-top: 14px;
  font-size: 0.84rem; color: var(--ink-soft); line-height: 1.65;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .calc-card { padding: 20px 16px; }
  .results-header { padding: 20px 18px; }
  .results-body { padding: 16px 18px; }
  .chart-wrap { padding: 14px 18px; }
  .results-main-value { font-size: 1.85rem; }
  .page { padding: 28px 16px 60px; }
}
