/* AmortWise — the site's only stylesheet.
   Design tokens (only these values are allowed):
   primary #1a5276, accent #2e86c1, background #f8f9fa, card #ffffff,
   text #212529, muted #6c757d, success #28a745, error #c0392b,
   border #dee2e6. */

:root {
  --primary: #1a5276;
  --accent: #2e86c1;
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --success: #28a745;
  --error: #c0392b;
  --border: #dee2e6;
  --radius: 8px;
  --content-width: 960px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.wrap {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 16px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 28px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  flex-direction: column;
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.brand:hover,
.brand:focus {
  text-decoration: none;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-left: auto;
}

.site-nav a {
  color: var(--text);
  font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a:focus {
  color: var(--accent);
}

/* Main content */

main {
  flex: 1;
  padding: 32px 0 48px;
}

h1,
h2,
h3 {
  color: var(--primary);
  line-height: 1.25;
}

h1 {
  margin: 0 0 16px;
  font-size: 1.75rem;
}

h2 {
  margin: 40px 0 12px;
  font-size: 1.35rem;
}

h3 {
  margin: 24px 0 8px;
  font-size: 1.05rem;
}

p {
  margin: 0 0 16px;
}

.lead {
  font-size: 1.05rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

ul.content-list {
  margin: 0 0 16px;
  padding-left: 22px;
}

ul.content-list li {
  margin-bottom: 8px;
}

/* Cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.tool-grid {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.tool-card h2 {
  margin-top: 0;
}

.open-link {
  font-weight: 600;
}

.why {
  margin-top: 40px;
}

.why ul,
.guides ul {
  margin: 0;
  padding-left: 22px;
}

.why li,
.guides li {
  margin-bottom: 8px;
}

/* Calculator */

.calc-grid {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.calc-error {
  margin: 0 0 14px;
  color: var(--error);
  font-weight: 600;
}

.calc-error[hidden] {
  display: none;
}

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.result-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: none;
}

.result-name {
  color: var(--text);
}

.result-value {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.result-value.saved {
  color: var(--success);
  font-size: 1.1rem;
}

.table-scroll {
  overflow-x: auto;
}

table.amort {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

table.amort caption {
  caption-side: top;
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: left;
}

table.amort th,
table.amort td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  text-align: right;
}

table.amort thead th {
  color: var(--primary);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

table.amort tbody th {
  color: var(--text);
  font-weight: 600;
  text-align: left;
}

table.amort tbody tr:last-child th,
table.amort tbody tr:last-child td {
  border-bottom: none;
}

.noscript-card {
  margin-top: 24px;
}

.formula {
  font-family: inherit;
  font-weight: 600;
}

/* FAQ */

.faq-item h3 {
  margin-bottom: 6px;
}

.faq-item p {
  margin-bottom: 0;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 24px 0 32px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0 0 8px;
}

.footer-links a {
  margin-right: 2px;
}

.disclaimer {
  max-width: 720px;
}

/* Layout: two calculator columns from 768px up (inputs left, results right) */

@media (min-width: 768px) {
  .tool-grid {
    grid-template-columns: 1fr 1fr;
  }

  .calc-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  h1 {
    font-size: 2rem;
  }
}