/* ── Fonts ───────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e8e9ec;
  --text: #1a1d27;
  --text-muted: #6b7280;
  --accent: #5b6af0;
  --accent-hover: #4a59d6;
  --accent-subtle: #eef0fe;
  --accent-text: #4449c9;
  --success: #16a34a;
  --tag-bg: #f3f4f6;
  --tag-text: #4b5563;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10), 0 3px 10px rgba(0,0,0,0.06);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────────────────── */
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
h3 { font-size: 1rem; font-weight: 600; }
p { color: var(--text-muted); font-size: 0.9375rem; }

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

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

nav {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.logo span { color: var(--accent); }

.nav-links { display: flex; gap: 1.75rem; }
.nav-links a { color: var(--text-muted); font-weight: 500; font-size: 0.9rem; transition: color 0.15s; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }

/* ── Main ────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}

/* ── Category Tabs ──────────────────────────────────────────────────── */
.cat-tabs {
  display: flex;
  gap: 0.35rem;
  padding-bottom: 2rem;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: center;
  flex-wrap: wrap;
}

.cat-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  padding: 0.5rem 1.1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  box-shadow: var(--shadow);
}

.cat-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-md);
}

.cat-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 12px rgba(91,106,240,0.3);
}

/* ── Tools Grid ──────────────────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.5rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(91,106,240,0.35);
  text-decoration: none;
}

.tool-icon {
  width: 52px;
  height: 52px;
  background: var(--accent-subtle);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.tool-card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.tool-tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 4px;
  margin-top: auto;
  width: fit-content;
}

/* ── Why Section ─────────────────────────────────────────────────────── */
.why-section { margin: 3.5rem 0; }
.why-section h2 { text-align: center; margin-bottom: 1.75rem; }

.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.why-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.why-item h3 { font-size: 0.95rem; margin-bottom: 0.5rem; font-weight: 700; }
.why-item p { font-size: 0.875rem; line-height: 1.6; }

/* ── Affiliate ──────────────────────────────────────────────────────── */
.affiliate-section, .ad-section { margin: 2.5rem 0; }

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

.affiliate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.affiliate-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.affiliate-card h4 { font-size: 0.95rem; margin-bottom: 0.4rem; color: var(--text); font-weight: 600; }
.affiliate-card p { font-size: 0.82rem; }
.affiliate-tag { display: inline-block; margin-top: 0.6rem; font-size: 0.75rem; font-weight: 600; color: var(--accent); }

/* ── Calculator Pages ────────────────────────────────────────────────── */
.calc-page { max-width: 700px; margin: 0 auto; }

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

.calc-inputs { display: flex; flex-direction: column; gap: 1.25rem; }
.calc-output { display: flex; flex-direction: column; gap: 1.25rem; }

/* ── Inputs ─────────────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.01em; }

.input-row { display: flex; gap: 0.5rem; align-items: center; }
.input-row input { flex: 1; min-width: 0; }
.input-row select { width: 105px; flex-shrink: 0; }

.input-prefix {
  padding: 0.7rem 0.875rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.input-row:has(.input-prefix) input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: none;
}
.input-row:has(.input-prefix) input:focus { border-color: var(--accent); }

input[type="number"], select, textarea {
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input[type="number"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,106,240,0.1);
}

input[type="number"]::placeholder { color: #b0b4be; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  width: 100%;
}

.btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 3px 10px rgba(91,106,240,0.3);
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); box-shadow: none; }

/* ── Result Boxes ───────────────────────────────────────────────────── */
.result-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.result-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.5rem;
}

.result-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.result-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.55;
}

/* ── Workings ───────────────────────────────────────────────────────── */
.workings-box {
  background: var(--accent-subtle);
  border: 1px solid rgba(91,106,240,0.18);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1.75rem;
}

.workings-box h3 { color: var(--accent-text); margin-bottom: 0.75rem; font-size: 0.9rem; font-weight: 700; }
.workings-box pre {
  font-size: 0.82rem;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  color: var(--text);
  line-height: 1.9;
  white-space: pre-wrap;
}

/* ── Info Box ───────────────────────────────────────────────────────── */
.info-box {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  margin: 1.5rem 0;
}

.info-box strong { color: #713f12; }
.info-box p { color: #7c2d12; }

/* ── Table ──────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.875rem; }
th, td { padding: 0.65rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
tr:hover td { background: var(--bg); }

/* ── Ad Container ───────────────────────────────────────────────────── */
.ad-container {
  margin: 2rem 0;
  min-height: 90px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  margin-top: auto;
}

footer p { font-size: 0.85rem; color: var(--text-muted); }
footer a { color: var(--text-muted); transition: color 0.15s; }
footer a:hover { color: var(--accent); text-decoration: none; }
.disclaimer { font-size: 0.75rem !important; margin-top: 0.4rem; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  main { padding: 1.75rem 1rem 3rem; }
  .calc-layout { grid-template-columns: 1fr; gap: 1.25rem; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .tool-card { padding: 1.5rem 1.25rem 1.25rem; }
  .nav-links { gap: 1rem; }
  .result-value { font-size: 1.4rem; }
}

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

/* ── Utility ────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
