/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-light: #eff6ff;
  --success:     #16a34a;
  --surface:     #ffffff;
  --bg:          #f1f5f9;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --muted:       #64748b;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
  --transition:  .2s ease;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
header {
  background: var(--brand);
  color: #fff;
  padding: 0 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.header-inner {
  max-width: 900px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}
.logo:hover { text-decoration: none; opacity: .9; }

nav a {
  color: rgba(255,255,255,.85);
  font-size: .9rem;
  margin-left: 1.25rem;
  transition: color var(--transition);
}
nav a:hover { color: #fff; text-decoration: none; }

/* ── Main ── */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

/* ── Hero (homepage) ── */
.hero {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: .75rem;
}
.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 520px;
  margin: 0 auto 2rem;
}

/* ── Tool Cards (homepage grid) ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-top: .5rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  text-decoration: none;
}

.tool-card .icon {
  font-size: 2rem;
  margin-bottom: .25rem;
}
.tool-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
}
.tool-card p {
  font-size: .88rem;
  color: var(--muted);
  flex: 1;
}
.tool-card .cta {
  display: inline-block;
  margin-top: .75rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--brand);
}

/* ── Calculator Page ── */
.page-header {
  margin-bottom: 1.75rem;
}
.page-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.3px;
}
.page-header p {
  color: var(--muted);
  margin-top: .3rem;
}

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 680px) {
  .calc-layout { grid-template-columns: 1fr; }
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: .75rem;
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 1.1rem;
}
label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.input-wrap {
  position: relative;
}
.input-prefix, .input-suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .9rem;
  pointer-events: none;
}
.input-prefix { left: .75rem; }
.input-suffix { right: .75rem; }

input[type="number"], select {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.has-prefix input[type="number"] { padding-left: 1.75rem; }
.has-suffix input[type="number"] { padding-right: 2.25rem; }

input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Button ── */
.btn {
  display: block;
  width: 100%;
  padding: .7rem 1rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: background var(--transition), transform var(--transition);
}
.btn:hover { background: var(--brand-dark); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

/* ── Results ── */
.results-card {
  display: none;
}
.results-card.visible { display: block; }

.result-primary {
  background: var(--brand-light);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}
.result-primary .label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--brand);
}
.result-primary .value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -.5px;
  margin-top: .2rem;
}

.result-rows { list-style: none; }
.result-rows li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.result-rows li:last-child { border-bottom: none; }
.result-rows .row-label { color: var(--muted); }
.result-rows .row-value { font-weight: 700; }
.result-rows .row-value.positive { color: var(--success); }
.result-rows .row-value.accent   { color: var(--brand); }

/* ── Amortization / Schedule table ── */
.table-wrap {
  overflow-x: auto;
  margin-top: 1.5rem;
}
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.schedule-table th, .schedule-table td {
  padding: .5rem .75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.schedule-table th:first-child,
.schedule-table td:first-child { text-align: left; }
.schedule-table thead th {
  background: var(--bg);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
}
.schedule-table tbody tr:hover { background: var(--brand-light); }

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  transition: color var(--transition);
}
.back-link:hover { color: var(--brand); text-decoration: none; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
