:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --brand-blue: #2563eb;
  --brand-blue-hover: #1d4ed8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
}

/* Header */
.site-header {
  background: #1e293b;
  color: #ffffff;
  padding: 1rem 2rem;
  border-bottom: 3px solid var(--brand-blue);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.nav-links a:hover, .nav-links a.active {
  color: #ffffff;
}

/* Layout */
.app-container {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}

@media (max-width: 960px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Category Tabs */
.tool-switcher {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: var(--radius);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  white-space: nowrap;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--brand-blue);
  box-shadow: var(--shadow-sm);
}

/* Calculator Card */
.calc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.calc-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: #0f172a;
}

.calc-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

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

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

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #334155;
}

.input-with-affix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s;
}

.input-with-affix:focus-within {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.affix {
  background: #f1f5f9;
  padding: 0.6rem 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.input-with-affix input, .input-with-affix select {
  width: 100%;
  border: none;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  outline: none;
  color: #0f172a;
}

.btn-primary {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--brand-blue);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
  margin-top: 0.5rem;
}

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

/* Results Section */
.results-panel {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.result-badge {
  background: #dbeafe;
  color: var(--brand-blue);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.monthly-pay-hero {
  font-size: 2.25rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 1.25rem;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  margin-bottom: 1.5rem;
}

.breakdown-table td {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-color);
}

.breakdown-table tr:last-child td {
  border-bottom: none;
}

.breakdown-table .bold {
  font-weight: 700;
}

.text-right {
  text-align: right;
}

/* Visualization Donut */
.viz-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem 0;
  gap: 1.5rem;
}

.donut-svg {
  width: 140px;
  height: 140px;
}

.legend {
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Amortization Table */
.schedule-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.table-wrapper {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

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

.amort-table th {
  background: #f1f5f9;
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.amort-table td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.amort-table tr:hover {
  background-color: #f8fafc;
}

/* Sidebar & High-RPM Ad Slots */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-sticky {
  position: sticky;
  top: 1.5rem;
}

.ad-slot-container {
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.5rem;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mock-ad-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 1.25rem;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.mock-ad-banner.leaderboard {
  min-height: 90px;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.ad-badge {
  font-size: 0.65rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.ad-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.ad-icon {
  font-size: 2rem;
}

.ad-copy strong {
  font-size: 1rem;
  color: #1e3a8a;
  display: block;
  margin-bottom: 0.25rem;
}

.ad-copy p {
  font-size: 0.8rem;
  color: #475569;
}

.ad-btn {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  margin-top: 0.5rem;
}

.ad-disclaimer {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 0.75rem;
}

/* Footer */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 3rem 1rem 2rem;
  margin-top: 4rem;
  font-size: 0.875rem;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

.footer-inner h4 {
  color: #fff;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.footer-inner ul {
  list-style: none;
}

.footer-inner ul li {
  margin-bottom: 0.5rem;
}

.footer-inner a {
  color: #cbd5e1;
  text-decoration: none;
}

.footer-inner a:hover {
  color: #fff;
}

.copyright-bar {
  max-width: 1280px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid #334155;
  text-align: center;
  font-size: 0.8rem;
}
