/* ==========================================================
   EVF — Feuille de style de l'application (charte EVF)
   Bleu nuit #0a1628 · Bleu #15639E · Orange #ED7D31
   Bebas Neue (titres) · Outfit (texte)
   ========================================================== */

@font-face { font-family: 'Bebas Neue'; src: url('/fonts/bebas-neue-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --navy: #0a1628;
  --navy-2: #12233d;
  --blue: #15639E;
  --blue-soft: #e6f0f8;
  --orange: #ED7D31;
  --orange-dark: #c9611b;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #0f1b2d;
  --muted: #5a6a7e;
  --border: #dde3ea;
  --ok: #1f8a4c;
  --kpi: #0a1628;
  --warn-bg: #fff4e8;
  --warn-text: #8a4300;
  --shadow: 0 1px 2px rgba(10, 22, 40, .06), 0 4px 14px rgba(10, 22, 40, .06);
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070f1c;
    --surface: #0f1d31;
    --surface-2: #13243c;
    --text: #e7edf5;
    --muted: #94a5ba;
    --border: #1f3350;
    --blue-soft: #10294a;
    --warn-bg: #3a2410;
    --kpi: #17375e;
    --warn-text: #ffc58f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070f1c; --surface: #0f1d31; --surface-2: #13243c; --text: #e7edf5; --muted: #94a5ba;
  --border: #1f3350; --blue-soft: #10294a; --warn-bg: #3a2410; --warn-text: #ffc58f; --kpi: #17375e; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: calc(56px + var(--safe-t));
  padding: var(--safe-t) 16px 0;
  background: var(--navy);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-logo { display: block; height: 38px; width: auto; }
@media (max-width: 340px) { .brand-logo { height: 32px; } }
.topbar-title { flex: 1; margin: 0; font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: 24px; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar.sub .brand { display: none; }
.topbar:not(.sub) .topbar-title { display: none; }
.topbar:not(.sub) .brand { flex: 1; }
.topbar-back { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -8px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
.topbar-back:active { background: rgba(255,255,255,.12); }
.net-badge { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(237,125,49,.2); color: var(--orange); }

/* ---------- Vue principale ---------- */
.view {
  max-width: 680px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  outline: none;
  min-height: 60vh;
}
.view.enter { animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view.enter { animation: none; } }

h2.section { font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: 22px; letter-spacing: .04em; margin: 26px 0 10px; color: var(--text); }
h2.section:first-child { margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.lead { font-size: 17px; color: var(--muted); margin: 0 0 8px; }

/* ---------- Héros accueil ---------- */
.hero {
  position: relative; overflow: hidden;
  margin: -16px -16px 0; padding: 22px 20px 28px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, #163a63 100%);
  color: #fff;
}
.hero h2 { font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: 34px; line-height: 1; letter-spacing: .02em; margin: 0 0 8px; max-width: 15ch; }
.hero h2 em { font-style: normal; color: var(--orange); }
.hero p { margin: 0; color: #c4d2e3; max-width: 34ch; }
.hero-fan { position: absolute; right: -40px; top: -30px; width: 190px; height: 190px; color: rgba(255,255,255,.06); stroke-width: 1.2; }
@media (prefers-reduced-motion: no-preference) { .hero-fan { animation: spin 30s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Grille d'actions rapides ---------- */
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: -14px; position: relative; }
.quick a {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font-weight: 600;
  min-height: 98px;
}
.quick a .ico { width: 28px; height: 28px; color: var(--blue); }
.quick a.accent { background: var(--orange); color: #fff; }
.quick a.accent .ico { color: #fff; }
.quick a small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }
.quick a.accent small { color: rgba(255,255,255,.85); }
.quick a:active { transform: scale(.98); }

/* ---------- Cartes & listes ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li + li { border-top: 1px solid var(--border); }
.list a, .list .row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px; color: var(--text); text-decoration: none; min-height: 56px;
}
.list a:active { background: var(--surface-2); }
.list .row-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); flex: none; }
.list .row-main { flex: 1; min-width: 0; }
.list .row-title { font-weight: 600; display: block; }
.list .row-sub { font-size: 14px; color: var(--muted); display: block; }
.list .chev { color: var(--muted); width: 20px; height: 20px; }

/* ---------- Actus ---------- */
.news-card { display: block; text-decoration: none; color: var(--text); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.news-card + .news-card { margin-top: 12px; }
.news-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }
.news-card .news-body { padding: 14px 16px 16px; }
.news-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 600; }
.tag.orange { background: rgba(237,125,49,.14); color: var(--orange-dark); }
.news-card h3 { margin: 0 0 4px; font-size: 18px; line-height: 1.25; }
.news-card p { margin: 0; color: var(--muted); font-size: 15px; }
.article h2 { font-size: 24px; line-height: 1.2; margin: 6px 0 12px; }
.article p { margin: 0 0 12px; }
.article img { border-radius: var(--radius); margin: 0 0 14px; }

/* ---------- Formulaires & calculateurs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 15px; }
.field .help { font-size: 13px; color: var(--muted); }
.input-wrap { display: flex; align-items: stretch; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,99,158,.18); }
.input-wrap input, .input-wrap select, .input-wrap textarea {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  padding: 12px 14px; font-size: 17px; min-height: 48px;
}
.input-wrap textarea { min-height: 110px; resize: vertical; font-size: 16px; }
.input-wrap select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.input-wrap .unit { display: grid; place-items: center; padding: 0 14px; background: var(--surface-2); color: var(--muted); font-size: 14px; border-left: 1px solid var(--border); white-space: nowrap; }
.field.invalid .input-wrap { border-color: #c0392b; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
details.adv { margin: 4px 0 14px; }
details.adv summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: 15px; padding: 6px 0; }
details.adv[open] summary { margin-bottom: 10px; }

.results { margin-top: 6px; }
.result-primary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--kpi); color: #fff; border-radius: var(--radius); padding: 14px; }
.kpi .kpi-label { font-size: 13px; color: #b9c7d8; }
.kpi .kpi-value { font-family: 'Bebas Neue', sans-serif; font-size: 34px; line-height: 1.05; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.kpi .kpi-unit { font-size: 15px; color: var(--orange); margin-left: 4px; font-family: 'Outfit', sans-serif; font-weight: 600; }
.result-table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.result-table td { padding: 11px 14px; border-top: 1px solid var(--border); font-size: 15px; }
.result-table tr:first-child td { border-top: 0; }
.result-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); font-size: 14px; display: flex; gap: 10px; }
.note.warn { background: var(--warn-bg); color: var(--warn-text); }
.note .ico { width: 20px; height: 20px; margin-top: 1px; }
.formula { margin-top: 18px; font-size: 14px; color: var(--muted); }
.formula code { display: block; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-top: 6px; overflow-x: auto; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--orange); color: #fff; font-weight: 600; font-size: 16px;
  text-decoration: none; cursor: pointer; width: 100%;
}
.btn:active { background: var(--orange-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn.navy { background: var(--navy); }
.btn .ico { width: 20px; height: 20px; }
.btn-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin-top: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Scanner ---------- */
.scanner { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18% 14%; border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.45); }
.scanner .frame::before, .scanner .frame::after { content: ''; position: absolute; inset: 0; border: 3px solid var(--orange); border-radius: 18px; clip-path: polygon(0 0, 22% 0, 22% 4px, 4px 4px, 4px 22%, 0 22%, 0 78%, 4px 78%, 4px calc(100% - 4px), 22% calc(100% - 4px), 22% 100%, 78% 100%, 78% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 78%, 100% 78%, 100% 22%, calc(100% - 4px) 22%, calc(100% - 4px) 4px, 78% 4px, 78% 0, 100% 0, 100% 100%, 0 100%); }
.scanner .frame::after { display: none; }
.scanner .scan-line { position: absolute; left: 16%; right: 16%; top: 20%; height: 2px; background: var(--orange); box-shadow: 0 0 12px var(--orange); }
@media (prefers-reduced-motion: no-preference) { .scanner .scan-line { animation: scanline 2.2s ease-in-out infinite alternate; } }
@keyframes scanline { to { top: 80%; } }
.scanner .scan-hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.scanner .torch { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; }
.scanner .torch.on { background: var(--orange); }
.scan-placeholder { display: grid; place-items: center; text-align: center; color: #c4d2e3; padding: 24px; height: 100%; }
.scan-placeholder .ico { width: 54px; height: 54px; color: var(--orange); margin: 0 auto 10px; }

/* ---------- Produit ---------- */
.product-head { background: var(--kpi); color: #fff; border-radius: var(--radius); padding: 18px; }
.product-head .ref { font-family: 'Bebas Neue', sans-serif; font-size: 32px; letter-spacing: .03em; line-height: 1; }
.product-head .sn { color: var(--orange); font-weight: 600; margin-top: 4px; }
.product-head p { color: #c4d2e3; margin: 8px 0 0; }
.spec { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 15px; }
.spec:first-child { border-top: 0; }
.spec span:last-child { font-weight: 600; text-align: right; }

/* ---------- Photos SAV ---------- */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Installation ---------- */
.install-banner { display: flex; gap: 12px; align-items: center; margin-top: 18px; padding: 14px; border-radius: var(--radius); background: var(--blue-soft); }
.install-banner .ico { color: var(--blue); width: 30px; height: 30px; }
.install-banner div { flex: 1; font-size: 14px; }
.install-banner strong { display: block; font-size: 15px; }
.install-banner .btn { width: auto; min-height: 40px; padding: 0 14px; font-size: 14px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 18px 46px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 32px; height: 32px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 700; display: grid; place-items: center; }
.steps .ios-ico { display: inline-grid; place-items: center; vertical-align: -6px; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--blue); }
.steps .ios-ico .ico { width: 18px; height: 18px; }

/* ---------- États ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ico { width: 44px; height: 44px; color: var(--muted); }
.skeleton { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton + .skeleton { margin-top: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.badge-ok { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ok); font-weight: 600; }
.badge-ok .ico { width: 16px; height: 16px; }

/* ---------- Mémo (page interne) ---------- */
.memo h3 { font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: 20px; letter-spacing: .04em; margin: 22px 0 8px; color: var(--blue); }
.memo .card h4 { margin: 0 0 6px; font-size: 16px; }
.memo code { display: block; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13.5px; padding: 3px 0; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 18px rgba(10,22,40,.06);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 500; }
.tabbar a .ico { width: 24px; height: 24px; }
.tabbar a.active { color: var(--blue); }
.tabbar a.active:not(.tab-scan) .ico { stroke-width: 2.2; }
.tab-scan { position: relative; }
.scan-bubble { display: grid; place-items: center; width: 54px; height: 54px; margin-top: -26px; border-radius: 50%; background: var(--orange); color: #fff; box-shadow: 0 4px 14px rgba(237,125,49,.45); border: 4px solid var(--surface); }
.tab-scan.active { color: var(--orange-dark); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--navy); color: #fff; font-size: 15px; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Grand écran ---------- */
@media (min-width: 720px) {
  .tabbar { left: 50%; right: auto; width: 680px; transform: translateX(-50%); border-radius: 18px 18px 0 0; border: 1px solid var(--border); border-bottom: 0; }
  .hero { margin: 0 0 0; border-radius: 0 0 22px 22px; }
  .quick { grid-template-columns: repeat(4, 1fr); }
}
