:root {
  --bg: #f4f5f9;
  --bg-alt: #ffffff;
  --card-bg: #ffffff;
  --text: #1a1d29;
  --text-muted: #656a7d;
  --border: #e3e5ec;
  --accent: #4f46e5;
  --accent-strong: #3730a3;
  --accent-soft: #eef0fe;
  --positive: #16a34a;
  --negative: #dc2626;
  --shadow: 0 1px 2px rgba(20, 22, 40, 0.04), 0 8px 24px rgba(20, 22, 40, 0.06);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12131b;
  --bg-alt: #191b26;
  --card-bg: #1c1e2b;
  --text: #eceefb;
  --text-muted: #9498b0;
  --border: #2b2e40;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: #262a45;
  --positive: #4ade80;
  --negative: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12131b;
    --bg-alt: #191b26;
    --card-bg: #1c1e2b;
    --text: #eceefb;
    --text-muted: #9498b0;
    --border: #2b2e40;
    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --accent-soft: #262a45;
    --positive: #4ade80;
    --negative: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; }

/* ---------- Hero banner ---------- */

.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 26px 20px 76px;
  text-align: center;
  color: #ffffff;
  background:
    radial-gradient(circle at 18% 15%, rgba(255,255,255,0.22), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(255,255,255,0.16), transparent 40%),
    linear-gradient(135deg, #6d28d9 0%, #4f46e5 48%, #4338ca 100%);
}

.hero-orb {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.45;
}
.hero-orb-1 { width: 260px; height: 260px; background: #a855f7; top: -90px; left: 8%; }
.hero-orb-2 { width: 220px; height: 220px; background: #22d3ee; top: -40px; right: 10%; opacity: 0.3; }

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
  padding-top: 8px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border-radius: 999px;
}

.hero-title {
  margin: 16px 0 10px;
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero-plus {
  color: #fbbf24;
  margin-left: 0.05em;
}

.hero-tagline {
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 1rem;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

.icon-btn.glass {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6px);
}
.icon-btn.glass:hover { border-color: rgba(255, 255, 255, 0.7); }

/* ---------- Tabs bar (floats over hero) ---------- */

.tabs-bar {
  position: sticky;
  top: 14px;
  z-index: 10;
  display: flex;
  justify-content: center;
  margin: -56px 20px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }

.tabs-bar-inner {
  display: inline-flex;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px;
  box-shadow: 0 10px 30px rgba(20, 22, 40, 0.18), 0 2px 8px rgba(20, 22, 40, 0.08);
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

@media (max-width: 560px) {
  .tab { padding: 9px 13px; font-size: 0.8rem; }
}

/* ---------- Layout ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.panel { display: none; }
.panel.active { display: block; margin-bottom: 20px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

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

.col-inputs, .col-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}

.card-title {
  font-size: 0.95rem;
  margin-bottom: 12px;
}

/* ---------- Direction switch / segmented ---------- */

.direction-switch, .segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
  gap: 3px;
}

.dir-btn, .seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.dir-btn.active, .seg-btn.active {
  background: var(--accent);
  color: white;
}

/* ---------- Fields ---------- */

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field-label small { font-weight: 400; color: var(--text-muted); }

input[type="number"], input[type="text"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}
input[type="number"]:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.amount-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.amount-row input[type="number"] { flex: 1; min-width: 0; }
.amount-row .suffix { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.amount-row select { width: auto; min-width: 0; max-width: 100px; }

@media (max-width: 420px) {
  .amount-row { flex-wrap: wrap; }
  .amount-row select { max-width: none; flex: 1 1 100%; }
}

.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
  .amt-grid { grid-template-columns: 1fr 1fr; }
}

.amt-grid input[data-base="net"] {
  color: var(--accent);
  font-weight: 700;
}

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.slider-row output { font-weight: 600; font-size: 0.85rem; min-width: 46px; text-align: right; }

details.options {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}
details.options summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 12px;
  list-style: none;
}
details.options summary::-webkit-details-marker { display: none; }
details.options summary::before { content: "▸ "; color: var(--accent); }
details.options[open] summary::before { content: "▾ "; }

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 8px 0 0;
  line-height: 1.4;
}

.faq-answer {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
  line-height: 1.55;
}

.actions-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Results ---------- */

.result-hero {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  text-align: center;
  padding: 26px 20px;
}
.result-hero-label { display: block; font-size: 0.82rem; opacity: 0.85; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.result-hero-value { display: block; font-size: 2.6rem; font-weight: 800; margin: 6px 0 4px; letter-spacing: -0.02em; }
.result-hero-sub { font-size: 0.82rem; opacity: 0.9; }

.breakdown { display: grid; gap: 10px; margin: 0; }
.breakdown > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
  font-size: 0.88rem;
}
.breakdown > div:last-child { border-bottom: none; padding-bottom: 0; }
.breakdown dt { color: var(--text-muted); }
.breakdown dd { margin: 0; font-weight: 600; text-align: right; }
.breakdown dd.negative { color: var(--negative); }
.breakdown dd.total { font-size: 1.05rem; color: var(--accent); }

.table-scroll { overflow-x: auto; }
table.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}
table.compare-table th, table.compare-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
table.compare-table th:first-child, table.compare-table td:first-child { text-align: left; }
table.compare-table thead th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
table.compare-table tbody tr:hover { background: var(--accent-soft); }
table.compare-table td.highlight { color: var(--accent); font-weight: 700; }
table.compare-table td.positive { color: var(--positive); font-weight: 600; }

.disclaimer {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 4px 4px 0;
}

.argumentaire {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.site-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.footer-links {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.76rem;
}
.footer-links a { color: var(--text-muted); text-decoration: underline; }
.footer-links a:hover { color: var(--accent); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent); }

.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- Bandeau cookies (CMP) ---------- */

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.cookie-banner[hidden] { display: none; }

.cookie-banner-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}
.cookie-banner-text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  flex: 1 1 320px;
  line-height: 1.5;
}
.cookie-banner-text a { color: var(--accent); }
.cookie-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cookie-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cookie-modal[hidden] { display: none; }

.cookie-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.55);
}

.cookie-modal-panel {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}
.cookie-modal-panel h2 { font-size: 1.1rem; margin-bottom: 8px; }

.cookie-category { border-top: 1px solid var(--border); padding: 14px 0; }
.cookie-category:first-of-type { margin-top: 14px; }
.cookie-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  font-size: 0.9rem;
}
.cookie-category-desc { margin: 6px 0 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:disabled + .switch-track { opacity: 0.6; cursor: not-allowed; }

.cookie-modal-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.cookie-modal-actions .btn-secondary, .cookie-modal-actions .btn-primary { flex: 1; }

/* ---------- Pages légales ---------- */

.legal-topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.legal-topbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}
.brand-link .hero-plus { color: var(--accent); }

.legal-page {
  max-width: 780px;
}

.legal-card { line-height: 1.65; }
.legal-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.legal-card .legal-updated { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 20px; }
.legal-card h2 { font-size: 1.05rem; margin: 26px 0 10px; }
.legal-card h2:first-of-type { margin-top: 6px; }
.legal-card p { margin: 0 0 12px; color: var(--text); }
.legal-card ul { margin: 0 0 12px; padding-left: 20px; }
.legal-card li { margin-bottom: 6px; }
.legal-card a { color: var(--accent); }

.legal-notice {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.82rem;
  margin-bottom: 22px;
}

.legal-todo {
  background: rgba(220, 38, 38, 0.12);
  border: 1px dashed var(--negative);
  color: var(--negative);
  border-radius: 5px;
  padding: 1px 6px;
  font-weight: 600;
  font-size: 0.92em;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin: 10px 0 16px;
}
.legal-table th, .legal-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.legal-table th { background: var(--accent-soft); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.02em; }

/* ---------- Emplacements publicitaires ---------- */

.ad-slot {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding: 16px 14px 12px;
}
.ad-slot[hidden] { display: none; }

.ad-label {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  opacity: 0.75;
}

.ad-slot .adsbygoogle { width: 100%; }

.ad-slot-fallback {
  margin: 16px 0 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
}
.ad-slot-fallback .link-btn { font-size: inherit; }

.ad-slot--banner {
  max-width: 1180px;
  margin: 0 auto 20px;
  min-height: 100px;
}

.ad-slot--rectangle { min-height: 250px; }
