/* ===== CSS Custom Properties (Theming) ===== */
:root {
  --bg: #f7f8fb;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --border: #e3e6ee;
  --text: #171923;
  --text-muted: #5c6272;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef0ff;
  --accent: #06b6d4;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 4px 20px rgba(23, 25, 35, 0.06);
  --shadow-lg: 0 12px 40px rgba(23, 25, 35, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --font-heading: 'Outfit', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --header-h: 64px;
}

[data-theme="dark"] {
  --bg: #0b0f19;
  --bg-alt: #10141f;
  --surface: #131826;
  --border: #232a3d;
  --text: #eef1f8;
  --text-muted: #97a0b5;
  --primary: #6366f1;
  --primary-hover: #7c7ff0;
  --primary-light: #1a1f36;
  --accent: #22d3ee;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .25s ease, color .25s ease;
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; margin: 0 0 .5em; }
p { margin: 0 0 1em; color: var(--text-muted); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; width: 100%; }
img { max-width: 100%; height: auto; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-weight: 600; font-size: .95rem;
  padding: 12px 22px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: all .18s ease; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline-light { background: transparent; border: 1px solid rgba(255,255,255,.6); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.btn-ghost { background: var(--primary-light); color: var(--primary); }
.btn-ghost:hover { background: var(--border); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .85rem; }

/* ===== Cookie Banner ===== */
.cookie-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 16px 20px;
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  transform: translateY(100%); transition: transform .3s ease;
}
.cookie-banner.show { transform: translateY(0); }
.cookie-banner p { margin: 0; font-size: .88rem; color: var(--text-muted); }
.cookie-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 500;
  background: var(--surface); border-bottom: 1px solid var(--border);
  height: var(--header-h);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.logo { font-family: var(--font-heading); font-weight: 800; font-size: 1.25rem; color: var(--text); }
.logo span { color: var(--primary); }
.main-nav ul { display: flex; list-style: none; margin: 0; padding: 0; gap: 6px; align-items: center; }
.main-nav > ul > li > a,
.nav-toggle {
  display: block; padding: 10px 14px; color: var(--text); font-weight: 500; font-size: .95rem;
  background: none; border: none; cursor: pointer; font-family: var(--font-body); border-radius: var(--radius-sm);
}
.nav-toggle:hover, .main-nav a:hover { background: var(--primary-light); text-decoration: none; }
.has-mega { position: relative; }
.mega-menu {
  position: absolute; top: 100%; left: 0; min-width: 480px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 18px; display: none; grid-template-columns: 1fr 1fr; gap: 6px 24px;
}
.has-mega:hover .mega-menu, .has-mega.open .mega-menu { display: grid; }
.mega-col { display: flex; flex-direction: column; gap: 2px; }
.mega-col a { padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: .9rem; }
.mega-col a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.mega-col a.active { color: var(--primary); font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-alt); cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center;
}
.mobile-menu-btn { display: none; width: 38px; height: 38px; border: none; background: none; cursor: pointer; flex-direction: column; justify-content: center; gap: 5px; }
.mobile-menu-btn span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-drawer {
  display: none; flex-direction: column; background: var(--surface);
  border-bottom: 1px solid var(--border); max-height: 0; overflow: hidden; transition: max-height .3s ease;
}
.mobile-drawer.open { max-height: 80vh; overflow-y: auto; }
.mobile-drawer a { padding: 12px 20px; border-bottom: 1px solid var(--border); color: var(--text); font-size: .95rem; }
.mobile-group-title { padding: 10px 20px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }

/* ===== Breadcrumb ===== */
.breadcrumb { padding: 14px 0; font-size: .85rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; color: var(--text-muted); }
.breadcrumb li:not(:last-child)::after { content: '/'; margin-left: 6px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb li[aria-current] { color: var(--text); font-weight: 600; }

/* ===== Hero ===== */
.hero { text-align: center; padding: 40px 0 20px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.hero-sub { max-width: 640px; margin: 0 auto; font-size: 1.05rem; }

/* ===== Calculator ===== */
.calculator-section { padding: 20px 0 60px; }
.calc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; max-width: 720px; margin: 0 auto;
}
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  flex: 1; min-width: 140px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-alt); color: var(--text-muted); font-weight: 600; font-size: .88rem; cursor: pointer; transition: all .15s ease;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.form-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; }
.form-group-wide { flex: 1 1 100%; }
label { font-size: .85rem; font-weight: 600; color: var(--text); }
input, select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-alt); color: var(--text); font-family: var(--font-body); font-size: .95rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
input.invalid, select.invalid { border-color: var(--danger); }
.error-msg { font-size: .78rem; color: var(--danger); min-height: 1em; }
select { top: 100%; }

/* ===== Result ===== */
.result-card {
  max-width: 720px; margin: 24px auto 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; animation: fadeIn .3s ease;
}
.result-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result-header h2 { margin: 0; font-size: 1.2rem; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-body { font-size: .95rem; }
.result-body table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.result-body td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.result-body td:first-child { color: var(--text-muted); }
.result-body td:last-child { text-align: right; font-weight: 600; font-family: var(--font-heading); }
.result-highlight { font-size: 1.4rem; font-weight: 800; color: var(--primary); font-family: var(--font-heading); margin: 6px 0 14px; }
.feedback-row { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--text-muted); }

/* ===== Reference Links ===== */
.reference-section { padding: 40px 0; background: var(--bg-alt); }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.ref-grid a { padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .85rem; color: var(--text); }
.ref-grid a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }

/* ===== Features ===== */
.features-section { padding: 60px 0; }
.features-section h2, .how-section h2, .seo-content-section h2, .faq-section h2 { text-align: center; margin-bottom: 30px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feature-card h3 { font-size: 1.05rem; margin-bottom: 8px; }
.feature-card p { margin: 0; font-size: .9rem; }

/* ===== How It Works ===== */
.how-section { padding: 40px 0; background: var(--bg-alt); }
.steps { max-width: 640px; margin: 0 auto; padding-left: 20px; }
.steps li { margin-bottom: 12px; }

/* ===== SEO Content ===== */
.seo-content-section { padding: 60px 0; max-width: 860px; margin: 0 auto; }
.seo-content-section p { font-size: .96rem; }

/* ===== FAQ ===== */
.faq-section { padding: 40px 0 60px; }
.faq-list { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: .96rem; }
.faq-item p { margin: 10px 0 0; }

/* ===== CTA ===== */
.cta-section { background: linear-gradient(135deg, var(--primary), var(--accent)); padding: 50px 0; text-align: center; color: #fff; }
.cta-section h2 { color: #fff; }
.cta-section p { color: rgba(255,255,255,.9); }
.cta-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.cta-buttons .btn-primary { background: #fff; color: var(--primary); }

/* ===== Footer ===== */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--border); padding: 50px 0 0; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 26px; padding-bottom: 30px; }
.footer-col h4 { font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
.footer-col a { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: 8px; }
.footer-col a:hover { color: var(--primary); text-decoration: none; }
.disclaimer { font-size: .75rem; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }
.footer-bottom { border-top: 1px solid var(--border); padding: 16px 0; text-align: center; font-size: .82rem; color: var(--text-muted); }

/* ===== Mobile ===== */
@media (max-width: 860px) {
  .main-nav { display: none; }
  .mobile-menu-btn { display: flex; }
  .mobile-drawer { display: flex; }
}
@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  .tabs { flex-direction: column; }
  .cookie-banner { flex-direction: column; align-items: flex-start; }
}
body, .container { max-width: 100vw; }