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

:root {
  --bg-primary: #f4f5f8;
  --bg-card: #ffffff;
  --bg-input: #eef0f5;
  --accent: #c4384a;
  --accent-hover: #d94a5c;
  --text: #1a1d27;
  --text-muted: #5c6270;
  --border: #dde1ea;
  --success: #1f9d57;
  --error: #d64545;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(24, 28, 40, 0.08);
}

html { font-size: 16px; color-scheme: light; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* HEADER */
.site-header { text-align: center; padding: 3rem 1rem 2rem; }

.logo {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.logo-icon { color: var(--accent); }

.tagline {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
}

/* SEO */
.seo-intro, .seo-footer-blurb {
  max-width: 780px;
  width: 92%;
  margin: 0 auto 2rem;
  text-align: center;
}

.seo-intro h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.seo-intro p, .seo-footer-blurb p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.seo-intro a, .seo-footer-blurb a, .site-footer a {
  color: var(--accent);
  font-weight: 500;
}

.seo-intro a:hover, .seo-footer-blurb a:hover, .site-footer a:hover {
  text-decoration: underline;
}

.seo-footer-blurb { margin-top: 0.5rem; margin-bottom: 2.5rem; }

.seo-footer-blurb h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.05rem;
  margin-bottom: 0.6rem;
}

/* CALC CONTAINER */
.calc-container {
  max-width: 720px;
  width: 92%;
  margin: 0 auto 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* TABS */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

.tab {
  flex: 1;
  padding: 1rem;
  background: none;
  border: none;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.tab:hover { color: var(--text); background: rgba(196, 56, 74, 0.04); }

.tab.active {
  color: var(--accent);
  background: var(--bg-card);
  border-bottom: 2px solid var(--accent);
}

.tab i { font-size: 0.9rem; }

/* TAB PANELS */
.tab-panel { display: none; padding: 2rem; }
.tab-panel.active { display: block; }

.tab-panel h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
}

.panel-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* FORM */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent);
}

.term-row { display: flex; gap: 0.5rem; }
.term-row input { flex: 1; }
.term-row select { width: auto; min-width: 100px; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 8px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }

/* EXPORT */
.export-bar {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-export {
  flex: 1;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
}

.btn-export:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-export i { font-size: 0.9rem; }

/* RESULTS */
.results { margin-top: 1.5rem; display: none; }
.results.show { display: block; }

.result-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.result-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
}

.result-card.highlight {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.result-card .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.3rem;
  opacity: 0.8;
}

.result-card .value {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

/* CHART */
.chart-wrap {
  position: relative;
  width: 100%;
  max-height: 320px;
  margin-bottom: 1.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.chart-wrap canvas {
  width: 100% !important;
  max-height: 300px;
}

/* AMORTIZATION TABLE */
.amort-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-bottom: 1rem;
}

.amort-toggle:hover { border-color: var(--accent); color: var(--accent); }

.amort-table-wrap {
  max-height: 400px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
}

.amort-table-wrap.show { display: block; }

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.amort-table th {
  position: sticky;
  top: 0;
  background: var(--bg-input);
  padding: 0.6rem 0.8rem;
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.amort-table th:first-child { text-align: left; }

.amort-table td {
  padding: 0.5rem 0.8rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.amort-table td:first-child { text-align: left; font-weight: 500; }
.amort-table tr:last-child td { border-bottom: none; }
.amort-table tr:hover td { background: rgba(196, 56, 74, 0.03); }

/* FOOTER */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 300;
  margin-top: auto;
}

/* ADS */
.ad-region {
  width: min(960px, 94%);
  margin: 2rem auto 1.5rem;
  padding: 0.75rem 0.5rem 1rem;
  border-top: 1px solid var(--border);
}

.ad-label {
  display: block;
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: 0.45rem;
}

.ad-region .adsbygoogle {
  display: block;
  min-height: 90px;
  max-height: 280px;
  overflow: hidden;
  border-radius: 8px;
}

/* RESPONSIVE */
@media (max-width: 600px) {
  .logo { font-size: 1.8rem; }
  .form-grid { grid-template-columns: 1fr; }
  .result-cards { grid-template-columns: 1fr; }
  .tab { font-size: 0.68rem; padding: 0.8rem 0.3rem; gap: 0.25rem; }
  .tab i { font-size: 0.8rem; }
  .tab-panel { padding: 1.5rem 1.2rem; }
  .export-bar { flex-direction: column; }
}
