:root {
  color-scheme: light;
  --surface-1:      #ffffff;
  --surface-2:      #f9f9f7;
  --surface-3:      #f1f0ec;
  --border:         rgba(11,11,11,0.10);
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --accent:         #0a3970;
  --accent-2:       #b28c49;
  --good:           #006300;
  --warning:        #eda100;
  --critical:       #d03b3b;
  --gridline:       #e1e0d9;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #17171a;
    --surface-2:      #1a1a19;
    --surface-3:      #222220;
    --border:         rgba(255,255,255,0.10);
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --accent:         #4d84c4;
    --accent-2:       #cda35f;
    --good:           #0ca30c;
    --warning:        #c98500;
    --critical:       #e66767;
    --gridline:       #2c2c2a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #17171a;
  --surface-2:      #1a1a19;
  --surface-3:      #222220;
  --border:         rgba(255,255,255,0.10);
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --accent:         #4d84c4;
  --accent-2:       #cda35f;
  --good:           #0ca30c;
  --warning:        #c98500;
  --critical:       #e66767;
  --gridline:       #2c2c2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-2);
  color: var(--text-primary);
  line-height: 1.45;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--text-primary);
}

.topbar .brand img {
  height: 38px;
  width: auto;
  border-radius: 6px;
  display: block;
}

.topbar .brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.topbar .brand .brand-text .name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.topbar .brand .brand-text .sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.topbar nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.topbar nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
}

.topbar nav a:hover { background: var(--surface-3); }
.topbar nav a.active { background: var(--accent); color: #fff; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
}

.subtitle {
  color: var(--text-secondary);
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
}

/* Hub / index page */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.1rem;
  margin-top: 1.5rem;
}

.hub-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.hub-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.hub-card .tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 18%, transparent);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  width: fit-content;
}

.hub-card h2 { margin: 0; font-size: 1.15rem; }
.hub-card p { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }

/* Layout: form + results */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(360px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

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

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.4rem 1.5rem;
}

.panel + .panel { margin-top: 1.25rem; }

.panel h3 {
  margin: 0 0 0.9rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--gridline);
  padding-bottom: 0.6rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
}

.field-row label {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.field-row .hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.field-row input[type="number"],
.field-row input[type="text"],
.field-row select {
  width: 140px;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 0.9rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.field-row select { text-align: left; width: 190px; }

.field-row input:focus, .field-row select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-row.checkbox {
  grid-template-columns: auto 1fr;
  justify-content: start;
}
.field-row.checkbox input { width: auto; }

.radio-group {
  display: flex;
  gap: 1.2rem;
  padding: 0.3rem 0 0.6rem;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

/* KPI tiles */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.kpi-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.kpi-tile .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.kpi-tile .value {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-tile .value.good { color: var(--good); }
.kpi-tile .value.critical { color: var(--critical); }

.kpi-tile.accent { border-color: var(--accent-2); border-width: 1.5px; }

/* Breakdown table */
table.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.breakdown th, table.breakdown td {
  text-align: left;
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid var(--gridline);
}

table.breakdown td.num, table.breakdown th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.breakdown tr.total td {
  font-weight: 700;
  border-top: 2px solid var(--gridline);
  border-bottom: none;
}

table.breakdown tr.section td {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-top: 1rem;
}

.note {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface-3);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.75rem;
}

.note.warn {
  color: var(--warning);
}

footer.page-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 2rem 1rem 1rem;
}

footer.page-footer a {
  color: var(--text-muted);
  text-decoration: underline;
}

/* Lead capture panel */
.lead-panel { border-color: var(--accent-2); border-width: 1.5px; }
.lead-panel h3 { color: var(--text-primary); border-bottom-color: var(--accent-2); }

.lead-form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.2rem; }

.lead-form label {
  font-size: 0.82rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.3rem;
}

.lead-form input[type="text"],
.lead-form input[type="email"],
.lead-form input[type="tel"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.lead-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.lead-form .consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.lead-form .consent input { margin-top: 0.2rem; }
.lead-form .consent a { color: var(--accent); }

.lead-form .hp { position: absolute; left: -9999px; top: -9999px; }

.btn-primary {
  align-self: flex-start;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { background: var(--accent-2); }

/* --- Verrou d'accès (coordonnées obligatoires) --- */
html.gate-locked .topbar,
html.gate-locked main,
html.gate-locked .page-footer {
  display: none;
}

.gate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--surface-2);
  overflow-y: auto;
}

html.gate-locked .gate-overlay { display: flex; }

.gate-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.6rem 1.8rem 1.8rem;
  max-width: 420px;
  width: 100%;
}

.gate-card .brand-mini {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.gate-card .brand-mini img { height: 28px; }

.gate-card h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }

.gate-card .gate-intro {
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.gate-error {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--critical);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.3rem;
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
  align-self: flex-start;
}

.btn-link:disabled { opacity: 0.5; cursor: default; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-secondary);
  margin-left: 0.4rem;
}
