/* =============================================================
   1. Tokens (reuses ToolSprout's own neutral green identity —
   this tool intentionally does NOT get its own accent palette)
   ============================================================= */
:root {
  --bg: #f5f9f8;
  --bg-alt: #e9f2ef;
  --card: #ffffff;
  --text: #142420;
  --text-soft: #56706a;
  --border: #dbe8e3;

  --accent: #0f6f5c;
  --accent-bright: #14b892;
  --accent-dark: #0b5347;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --sans: "Inter", system-ui, sans-serif;
  --display: "Sora", var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1613;
    --bg-alt: #131f1b;
    --card: #17231f;
    --text: #eaf5f1;
    --text-soft: #9fb6ae;
    --border: #223129;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; text-wrap: balance; line-height: 1.15; color: var(--text); }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--accent-bright); color: #06231c; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--card); color: var(--text);
  z-index: 9999; border-radius: 8px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: 1.25rem; }

/* =============================================================
   4. Header (ToolSprout site-wide)
   ============================================================= */
.site-header { position: sticky; top: 0; z-index: 50; padding: .85rem 0; border-bottom: 1px solid var(--border); background: var(--card); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.header-inner { gap: 1rem; flex-wrap: wrap; }
.header-left { display: flex; align-items: center; gap: 1.1rem; }
.logo { font-family: var(--display); font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .55rem; color: var(--text); }
.logo-mark {
  display: inline-grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr);
  gap: 3px; width: 26px; height: 26px; padding: 5px; border-radius: 8px;
  background: var(--accent-dark); flex-shrink: 0;
}
.logo-mark span { background: var(--accent-bright); border-radius: 2px; }

.header-nav { position: relative; }
.dropdown-toggle {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem .8rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem;
  color: var(--text); transition: background .15s var(--ease-out);
}
.dropdown-toggle:hover { background: var(--bg-alt); }
.dropdown-caret { transition: transform .18s var(--ease-out); }
.dropdown-toggle[aria-expanded="true"] .dropdown-caret { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; top: calc(100% + .5rem); left: 0; min-width: 190px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px -16px rgba(10, 30, 25, .25);
  padding: .4rem; opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .16s var(--ease-out), transform .16s var(--ease-out), visibility .16s;
}
.dropdown-menu.is-open { opacity: 1; visibility: visible; transform: none; }
.dropdown-menu li a { display: block; padding: .55rem .7rem; border-radius: 8px; font-size: .92rem; font-weight: 500; color: var(--text); }
.dropdown-menu li a:hover { background: var(--bg-alt); text-decoration: none; }

.header-search {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 999px;
  padding: .5rem .9rem; flex: 1; max-width: 260px; min-width: 140px;
}
.search-icon { color: var(--text-soft); flex-shrink: 0; }
.header-search input { border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: .92rem; width: 100%; }
.header-search input::placeholder { color: var(--text-soft); }
.search-kbd {
  font-family: var(--sans); font-size: .72rem; color: var(--text-soft);
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  padding: .1rem .4rem; flex-shrink: 0; display: none;
}
@media (min-width: 540px) { .search-kbd { display: inline-block; } }

.breadcrumb { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding-block: .9rem; font-size: .85rem; color: var(--text-soft); }
.breadcrumb a { color: var(--text-soft); font-weight: 600; }
.breadcrumb a:hover { color: var(--accent-dark); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding: 2rem 0 1rem; text-align: center; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.5rem); margin-bottom: .6rem; }
.hero .subtitle { color: var(--text-soft); max-width: 52ch; margin-inline: auto; font-size: 1.02rem; }

/* =============================================================
   6. Tool card / calculator form
   ============================================================= */
.tool-section { padding-block: 1.25rem 1rem; }
.tool-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: 0 12px 40px -20px rgba(15, 60, 50, .25);
}
@media (min-width: 720px) { .tool-card { padding: 2rem; } }

.form-row { margin-bottom: 1.1rem; }
.form-row label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: .4rem; }
.hint { color: var(--text-soft); font-size: .82rem; margin-top: .35rem; }

.select-inline {
  padding: .6rem .9rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--bg); font-size: .92rem; color: var(--text);
}
.select-full { width: 100%; }

.calc-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; margin-top: 1rem; }
@media (min-width: 720px) { .calc-grid { grid-template-columns: repeat(3, 1fr); } }

.input-with-prefix, .input-with-suffix {
  display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); overflow: hidden;
}
.input-with-prefix:focus-within, .input-with-suffix:focus-within { border-color: var(--accent); }
.input-prefix, .input-suffix { padding: 0 .8rem; color: var(--text-soft); font-weight: 700; flex-shrink: 0; }
.input-with-prefix input, .input-with-suffix input, .term-row input {
  border: 0; background: none; outline: none; padding: .8rem .9rem .8rem 0; font-size: 1rem; color: var(--text);
  width: 100%; font-family: var(--sans);
}
.input-with-suffix input { padding-left: .9rem; padding-right: 0; }

.term-row { display: flex; gap: .5rem; }
.term-row input {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); padding: .8rem .9rem; flex: 1;
}
.term-row input:focus { border-color: var(--accent); outline: none; }
.term-row .select-inline { flex-shrink: 0; }

.range-input {
  width: 100%; margin-top: .6rem; accent-color: var(--accent);
  height: 4px; border-radius: 999px; background: var(--border);
}

/* =============================================================
   7. Results
   ============================================================= */
.results-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 1.5rem; }
@media (min-width: 720px) { .results-grid { grid-template-columns: repeat(3, 1fr); } }
.result-card {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem;
}
.result-card--primary { background: linear-gradient(135deg, var(--accent-bright), var(--accent)); border-color: transparent; }
.result-card--primary .result-label, .result-card--primary .result-value { color: #fff; }
.result-label { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.result-value { font-family: var(--display); font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 800; color: var(--text); }

/* =============================================================
   8. Amortization schedule
   ============================================================= */
.amortization { margin-top: 1.75rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }
.amortization summary { font-weight: 700; cursor: pointer; font-size: 1.02rem; }
.amortization-controls { display: flex; align-items: center; gap: .6rem; margin: 1rem 0 .75rem; }
.segmented { display: inline-flex; background: var(--bg-alt); border-radius: 999px; padding: .2rem; }
.segmented-btn { padding: .4rem .9rem; border-radius: 999px; font-size: .84rem; font-weight: 700; color: var(--text-soft); }
.segmented-btn.is-active { background: var(--card); color: var(--accent-dark); box-shadow: 0 2px 6px rgba(0,0,0,.08); }

.table-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.amortization-table { font-size: .86rem; }
.amortization-table th, .amortization-table td { padding: .55rem .8rem; text-align: right; white-space: nowrap; }
.amortization-table th:first-child, .amortization-table td:first-child { text-align: left; }
.amortization-table thead th {
  position: sticky; top: 0; background: var(--bg-alt); font-weight: 700; color: var(--text-soft);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border);
}
.amortization-table tbody tr:nth-child(even) { background: var(--bg-alt); }

/* =============================================================
   9. Disclaimer
   ============================================================= */
.disclaimer { color: var(--text-soft); font-size: .82rem; margin-top: 1rem; line-height: 1.5; }

/* =============================================================
   10. Ad slots (placeholders only)
   ============================================================= */
.ad-slot {
  border: 2px dashed #cfe3dc; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-weight: 700; letter-spacing: .06em; font-size: .85rem;
  background: repeating-linear-gradient(45deg, var(--bg-alt), var(--bg-alt) 10px, var(--bg) 10px, var(--bg) 20px);
}
.ad-slot--leaderboard { min-height: 90px; margin: 2rem auto; max-width: 960px; }
.ad-slot--incontent { min-height: 250px; margin: 2rem auto; max-width: 728px; }

.ad-popup { border: none; border-radius: var(--radius-lg); padding: 0; max-width: 380px; width: 90vw; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
.ad-popup::backdrop { background: rgba(10, 30, 25, .45); backdrop-filter: blur(2px); }
.ad-popup-inner { padding: 1.5rem; text-align: center; position: relative; }
.ad-popup-close { position: absolute; top: .6rem; right: .6rem; width: 32px; height: 32px; border-radius: 50%; background: var(--bg-alt); font-size: 1.1rem; line-height: 1; }
.ad-popup .ad-slot { min-height: 220px; margin: 1rem 0 0; }

.corner-ad {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 40;
  background: var(--card); border: 2px dashed #cfe3dc; border-radius: var(--radius);
  padding: .7rem 2.2rem .7rem 1rem; max-width: 240px; font-size: .8rem; color: var(--text-soft);
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.corner-ad.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.corner-ad strong { display: block; font-weight: 800; color: var(--text); margin-bottom: .15rem; }
.corner-ad-close { position: absolute; top: .4rem; right: .4rem; width: 22px; height: 22px; border-radius: 50%; background: var(--bg-alt); font-size: .85rem; line-height: 1; }

/* =============================================================
   11. Content sections
   ============================================================= */
.content-section { padding-block: 2rem; }
.content-section h2 { font-size: clamp(1.3rem, 3.5vw, 1.8rem); margin-bottom: 1rem; }
.content-section > p { color: var(--text-soft); max-width: 68ch; margin-bottom: 1rem; }
.content-section > p.center-text { max-width: none; margin-inline: 0; text-align: justify; text-align-last: left; }

.steps { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.step .step-num {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: #fff; font-weight: 800; margin-bottom: .75rem;
}
.step h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.step p { color: var(--text-soft); font-size: .92rem; }

.usecases { display: grid; gap: .8rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .usecases { grid-template-columns: repeat(5, 1fr); } }
.usecase { background: var(--bg-alt); border-radius: var(--radius); padding: 1rem .75rem; text-align: center; border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; }
.usecase-icon { display: block; margin-bottom: .4rem; color: var(--text); }
.usecase-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.usecase h3 { font-size: .88rem; margin-top: auto; }

.faq { max-width: 68ch; }
.faq details { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin-bottom: .6rem; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq p { color: var(--text-soft); margin-top: .6rem; font-size: .94rem; }

/* =============================================================
   12. Related tools (interlinking)
   ============================================================= */
.related-highlight { font-size: .95rem; margin-bottom: 1rem; }
.related-tools-title { font-size: 1rem; margin-bottom: .75rem; color: var(--text-soft); }
.related-tools-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.related-tools-list a {
  display: inline-flex; padding: .5rem 1rem; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text); font-weight: 600; font-size: .88rem;
}
.related-tools-list a:hover { border-color: var(--accent); color: var(--accent-dark); text-decoration: none; }

/* =============================================================
   13. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 0; margin-top: 1rem; color: var(--text-soft); font-size: .85rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; justify-content: space-between; align-items: center; }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* =============================================================
   13. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dropdown-menu, .dropdown-caret, .corner-ad { transition: none; }
}
