:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --primary: #059669;
  --primary-dark: #047857;
  --primary-soft: #ecfdf5;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --warn: #d97706;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #059669, #0d9488);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.93rem;
  font-weight: 500;
}

.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* Hero */
.hero {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border);
  padding: 48px 0 40px;
}

.hero-compact {
  padding: 30px 0 26px;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary-dark); }

.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 3.6vw, 2.55rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 720px;
}

/* Search & Filter Bar */
.search-bar {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search-input {
  flex: 1 1 280px;
  padding: 13px 16px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover { border-color: #cbd5e1; color: var(--text); }
.filter-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* Sections & Cards */
main { padding: 34px 0 60px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 0 16px;
}

.section-title:first-child { margin-top: 0; }
.section-title h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.015em; }
.section-title span { color: var(--muted); font-size: 0.9rem; }

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

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: #a7f3d0;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.tool-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tool-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--muted);
}

.tool-card h3 {
  margin: 2px 0 0;
  font-size: 1.03rem;
  line-height: 1.35;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Calculator Layout */
.calc-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .calc-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.15rem;
}

.input-group {
  margin-bottom: 14px;
}

.input-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .input-row-2 { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix, .input-suffix {
  position: absolute;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
}

.input-prefix { left: 12px; }
.input-suffix { right: 12px; }

input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.has-prefix input[type="number"] { padding-left: 34px; }
.has-suffix input[type="number"] { padding-right: 34px; }

input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn:hover { background: var(--surface-alt); text-decoration: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
}

/* Result Cards */
.result-hero {
  background: var(--primary-soft);
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.result-hero.loss {
  background: var(--danger-soft);
  border-color: #fecaca;
}

.result-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
}

.result-hero.loss .result-label { color: var(--danger); }

.result-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.15;
  margin-top: 4px;
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 12px 14px;
}

.kpi-name { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 1.18rem; font-weight: 800; margin-top: 2px; }

/* Breakdown bar */
.bar-wrap { margin: 14px 0 18px; }
.bar-track {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--surface-alt);
}

.bar-cost { background: #64748b; }
.bar-fee { background: #f59e0b; }
.bar-profit { background: #10b981; }

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}

/* Breakdown Table */
.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-list li {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.summary-list li:last-child { border-bottom: 0; }

/* Monthly & Yearly Projection */
.projection-box {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.projection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.projection-head h3 {
  margin: 0;
  font-size: 0.96rem;
}

.projection-input {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.projection-input input {
  width: 82px;
  padding: 6px 8px;
  font-size: 0.9rem;
}

.proj-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

.proj-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.proj-item span { display: block; font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.proj-item strong { display: block; font-size: 1.05rem; margin-top: 2px; color: var(--text); }

/* Contextual CTA / Affiliate Box */
.cta-box {
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.cta-box strong { display: block; font-size: 0.98rem; color: var(--text); }
.cta-box p { margin: 3px 0 0; font-size: 0.86rem; color: var(--muted); }

/* Ad Placeholder (hidden until AdSense configured) */
.ad-slot {
  margin: 24px 0;
  text-align: center;
  min-height: 90px;
}

/* Content Sections */
.content-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
}

.content-box h2 { margin-top: 0; font-size: 1.25rem; }

.fee-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.fee-table th, .fee-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.fee-table th {
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--muted);
}

/* Comparison cards */
.compare-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

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

.compare-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: var(--surface);
}

.compare-card.winner {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.winner-tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  margin-bottom: 6px;
}

/* FAQ */
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.faq-item:last-child { border-bottom: 0; }
.faq-item h3 { margin: 0 0 6px; font-size: 1rem; }
.faq-item p { margin: 0; color: var(--muted); font-size: 0.93rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 32px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

.hidden { display: none !important; }
