/* Finmatrix — Master Stylesheet */
:root {
  --bg: #080c10;
  --bg2: #0d1117;
  --bg3: #131a22;
  --bg4: #1a2433;
  --border: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 212, 170, 0.3);
  --accent: #00d4aa;
  --accent-hover: #00b894;
  --accent2: #0098ff;
  --accent3: #ff6b35;
  --text: #e8edf2;
  --text-muted: #8b9bb4;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-hover-bg: rgba(255, 255, 255, 0.05);
  --glow: 0 0 30px rgba(0, 212, 170, 0.15);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --radius-sm: 8px;
  --font-heading: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --bg2: #ffffff;
  --bg3: #edf2f7;
  --bg4: #e2e8f0;
  --border: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(0, 180, 140, 0.4);
  --accent: #00a884;
  --accent-hover: #008f70;
  --accent2: #0077cc;
  --accent3: #e65100;
  --text: #1a202c;
  --text-muted: #64748b;
  --card-bg: #ffffff;
  --card-hover-bg: #f8fafc;
  --glow: 0 4px 20px rgba(0, 168, 132, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 212, 170, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 170, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* Header & Nav */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 12, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
  transition: background-color 0.3s ease;
}

[data-theme="light"] nav {
  background: rgba(255, 255, 255, 0.88);
}

.nav-logo {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  text-decoration: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo-badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
}

.nav-cta {
  background: linear-gradient(135deg, var(--accent), var(--accent2)) !important;
  color: #000 !important;
  font-weight: 700 !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 16px !important;
}

.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

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

/* Mobile Menu Button */
.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .menu-btn { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 64px; left: 0; right: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px;
    gap: 8px;
    box-shadow: var(--shadow);
  }
  .nav-links.show { display: flex; }
}

/* Layout Containers */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
  position: relative;
  z-index: 1;
}

.calc-page {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(24px, 5vh, 48px) clamp(16px, 4vw, 36px);
  position: relative;
  z-index: 1;
}

/* Breadcrumbs */
.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.5; }

/* Hero Section */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(40px, 8vh, 90px) clamp(16px, 5vw, 60px);
  position: relative;
  z-index: 1;
}

.hero-glow {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(0,212,170,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 212, 170, 0.1);
  border: 1px solid rgba(0, 212, 170, 0.3);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -1.5px;
  margin-bottom: 24px;
}

.hero h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: clamp(0.98rem, 2vw, 1.15rem);
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.7;
  margin-bottom: 36px;
}

.hero-btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000;
  font-weight: 700;
  padding: 13px 26px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: var(--font-body);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0,212,170,0.3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,212,170,0.4);
}

.btn-ghost {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 26px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: var(--font-body);
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 40px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 32px clamp(16px, 5vw, 60px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: relative;
  z-index: 1;
}

.stat { text-align: center; }
.stat-val {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
}
.stat-lbl {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Section Formatting */
section {
  padding: clamp(48px, 8vh, 88px) clamp(16px, 5vw, 60px);
  position: relative;
  z-index: 1;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.section-label::before {
  content: '';
  width: 18px;
  height: 1px;
  background: var(--accent);
}

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
}

.section-sub {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 540px;
  line-height: 1.6;
  margin-bottom: 40px;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: var(--glow);
  background: var(--card-hover-bg);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 212, 170, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex-grow: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chip {
  display: inline-block;
  background: rgba(0, 152, 255, 0.1);
  border: 1px solid rgba(0, 152, 255, 0.3);
  border-radius: 100px;
  padding: 3px 9px;
  font-size: 0.7rem;
  color: var(--accent2);
  font-weight: 600;
}

.chip.orange {
  background: rgba(255, 107, 53, 0.1);
  border-color: rgba(255, 107, 53, 0.3);
  color: var(--accent3);
}

/* Calculator Grid & Elements */
.calc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

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

.calc-inputs, .calc-outputs {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}

.calc-inputs h3, .calc-outputs h3 {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field { margin-bottom: 18px; }
.field label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.field input, .field select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

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

.field select option { background: var(--bg2); color: var(--text); }

.calc-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: #000;
  font-weight: 700;
  padding: 13px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: var(--font-body);
  margin-top: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.calc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,212,170,0.3);
}

/* Results Display */
.result-item { margin-bottom: 18px; }
.result-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.result-val {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.result-val.big { font-size: 2.1rem; }
.result-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.result-divider { height: 1px; background: var(--border); margin: 16px 0; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* SVG Chart Box */
.chart-container {
  margin-top: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.chart-title {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* AI Advisor Section */
.ai-advisor {
  margin-top: 28px;
  background: var(--bg2);
  border: 1px solid rgba(0, 212, 170, 0.25);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,212,170,0.05);
}

.ai-advisor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  background: rgba(0, 212, 170, 0.06);
  border-bottom: 1px solid rgba(0, 212, 170, 0.12);
}

.ai-dot {
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.ai-advisor-header span { font-weight: 700; font-size: 0.95rem; }
.ai-advisor-header small { color: var(--text-muted); font-size: 0.78rem; margin-left: auto; }

.ai-body { padding: 22px 24px; }
.ai-tip {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.6;
}

.ai-tip:last-child { border-bottom: none; }
.ai-tip-icon { color: var(--accent); flex-shrink: 0; margin-top: 2px; }

/* Monetization & Affiliate Cards */
.affiliate-section {
  margin-top: 36px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.affiliate-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.affiliate-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ftc-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg3);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.affiliate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.affiliate-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s;
}

.affiliate-card:hover {
  border-color: var(--accent);
}

.affiliate-brand {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.affiliate-rate {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 700;
  margin: 6px 0;
}

.affiliate-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.affiliate-btn {
  background: var(--accent);
  color: #000;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  padding: 9px;
  border-radius: 6px;
  display: block;
  transition: opacity 0.2s;
}

.affiliate-btn:hover { opacity: 0.9; }

/* Display Ad Slot Container */
.ad-slot {
  margin: 32px 0;
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

/* Articles Grid */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.article-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  border-color: rgba(0, 152, 255, 0.4);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.article-img {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.article-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.article-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent2);
  margin-bottom: 8px;
}

.article-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
}

.article-body p {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
  flex-grow: 1;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* Article Detail Page */
.article-detail {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 60px) clamp(16px, 4vw, 36px);
}

.article-detail h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
}

.article-byline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 32px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.article-content {
  font-size: 1rem;
  line-height: 1.85;
}

.article-content h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  margin: 36px 0 14px;
}

.article-content p { margin-bottom: 20px; color: var(--text); opacity: 0.9; }
.article-content ul, .article-content ol { margin: 0 0 20px 24px; color: var(--text); opacity: 0.9; }
.article-content li { margin-bottom: 8px; }

.highlight {
  background: rgba(0, 212, 170, 0.08);
  border-left: 4px solid var(--accent);
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  margin: 24px 0;
  font-size: 0.95rem;
}

/* Expandable Amortization Schedule Table */
.schedule-container {
  margin-top: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.schedule-header {
  padding: 16px 20px;
  background: var(--bg3);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.table-wrapper {
  overflow-x: auto;
  max-height: 350px;
}

table.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

table.schedule-table th, table.schedule-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

table.schedule-table th {
  background: var(--bg3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}

/* Footer */
footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 48px clamp(16px, 5vw, 60px);
  margin-top: 60px;
  position: relative;
  z-index: 1;
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 36px;
  margin-bottom: 36px;
}

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

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

.footer-brand p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 280px;
  margin-top: 10px;
}

.footer-col h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.footer-col a {
  display: block;
  color: var(--text-muted);
  font-size: 0.86rem;
  text-decoration: none;
  margin-bottom: 9px;
  transition: color 0.2s;
}

.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
}

.disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.7;
  line-height: 1.5;
  max-width: 720px;
  margin-top: 12px;
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
