/* Studio créas — Pro Pure. Rôles de couleur définis une fois ici. */
:root {
  color-scheme: light;
  --bg: #f6f1ea;
  --surface: #ffffff;
  --surface-2: #fbf8f4;
  --line: #ebe3d7;
  --ink: #1f1d1a;
  --ink-2: #5b554c;
  --muted: #8a8378;
  --gold: #8c6b30;
  --gold-soft: #f3eadb;
  --data-1: #a8740f;      /* série principale (validée : bande, chroma, contraste) */
  --data-2: #2a78d6;      /* deuxième série (variante B des tests) */
  --good: #0ca30c;
  --warn: #c98500;
  --bad: #d03b3b;
  --wait: #8a8378;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 29, 26, .04), 0 4px 16px rgba(31, 29, 26, .05);
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --display: 'Playfair Display', Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.15rem; }
.inline { display: inline; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.empty { color: var(--muted); text-align: center; padding: 1.25rem 0; margin: 0; }
.tnum, .kpi-val, .metric b { font-variant-numeric: tabular-nums; }

/* Barre du haut */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(246, 241, 234, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.05rem; }
.brand img { height: 30px; width: auto; }
.demo-banner { max-width: 1120px; margin: 12px auto 0; padding: 10px 14px; background: #fff7e0; border: 1px solid #f0dca6; border-radius: 10px; font-size: .86rem; color: #6b5413; width: calc(100% - 32px); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* Boutons */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: .9rem; cursor: pointer; transition: background-color .15s, border-color .15s; min-height: 44px; }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--gold); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface); }
.btn-ok { background: #eaf6ea; color: #116b11; border-color: #cde9cd; }
.btn-ok:hover { background: #dbf0db; }
.btn-danger { background: #fbeaea; color: #a32929; border-color: #f1cfcf; }
.btn-danger:hover { background: #f6dcdc; }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .card-head select, .row-gap select { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 30px 8px 12px; min-height: 40px; font-size: .86rem; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 12px; font-size: .84rem; color: var(--ink-2); cursor: pointer; min-height: 34px; }
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.seg-sm button { padding: 5px 10px; font-size: .8rem; min-height: 30px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi-label { font-size: .78rem; color: var(--muted); }
.kpi-val { font-size: 1.35rem; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.kpi-sub { font-size: .76rem; color: var(--muted); }

/* Cartes */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.count { background: var(--gold-soft); color: var(--gold); border-radius: 999px; padding: 2px 10px; font-weight: 600; font-size: .82rem; }
.chart-box { position: relative; height: 230px; margin-top: 10px; }
.table-toggle { margin-top: 8px; font-size: .84rem; }
.table-toggle summary { cursor: pointer; color: var(--ink-2); }
.table-toggle table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.table-toggle th, .table-toggle td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table-toggle td.num, .table-toggle th.num { text-align: right; }
.table-wrap { max-height: 260px; overflow: auto; }

/* Vignettes */
.thumb { position: relative; border-radius: 10px; overflow: hidden; background: linear-gradient(160deg, #efe6d7, #e2d3bb); aspect-ratio: 9 / 16; flex: none; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb-ph { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 8px; font-size: .72rem; font-weight: 600; color: #6b5413; line-height: 1.2; }
.badge-ai { position: absolute; top: 6px; left: 6px; background: rgba(31, 29, 26, .72); color: #fff; font-size: .64rem; font-weight: 600; border-radius: 6px; padding: 2px 6px; letter-spacing: .02em; }

/* À valider */
.hscroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.pending { flex: none; width: 210px; scroll-snap-align: start; border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.pending .thumb { width: 100%; aspect-ratio: 4 / 5; cursor: pointer; }
.pending-title { font-weight: 600; font-size: .86rem; line-height: 1.3; }
.pending-meta { font-size: .76rem; color: var(--muted); }
.pending-actions { display: flex; gap: 6px; }
.pending-actions .btn { flex: 1; padding: 8px 6px; }

/* Verdict : icône + libellé, jamais la couleur seule */
.verdict { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.verdict svg { width: 12px; height: 12px; flex: none; }
.v-gagnante { color: #0b6e0b; background: #e9f6e9; }
.v-a_surveiller { color: #7a5600; background: #fdf3da; }
.v-a_couper { color: #a32929; background: #fbeaea; }
.v-en_attente { color: var(--ink-2); background: #f1ede6; }
.verdict-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.verdict-filter button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: .8rem; cursor: pointer; min-height: 32px; color: var(--ink-2); }
.verdict-filter button[aria-checked="true"] { border-color: var(--ink); color: var(--ink); font-weight: 600; }

/* Classement */
.list { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 22px 58px 1fr; gap: 10px; padding: 10px 2px; border-top: 1px solid var(--line); cursor: pointer; align-items: start; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row .rank { font-weight: 600; color: var(--muted); font-size: .84rem; padding-top: 2px; font-variant-numeric: tabular-nums; }
.row .thumb { width: 58px; }
.row-title { font-weight: 600; font-size: .9rem; line-height: 1.3; }
.row-meta { font-size: .76rem; color: var(--muted); margin: 2px 0 6px; }
.row-why { font-size: .8rem; color: var(--ink-2); margin-top: 6px; }
.metrics { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--ink-2); }
.metric b { color: var(--ink); font-weight: 600; }

/* Tests A/B */
.ab { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.ab h3 { font-family: var(--font); font-size: .9rem; font-weight: 600; margin-bottom: 8px; }
.ab-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ab-col { border-radius: 10px; padding: 8px; background: var(--surface-2); position: relative; }
.ab-col.win { outline: 2px solid var(--good); }
.ab-tag { font-size: .72rem; font-weight: 600; color: var(--muted); }
.ab-win { position: absolute; top: 8px; right: 8px; font-size: .7rem; font-weight: 600; color: #0b6e0b; }
.ab-bar { height: 6px; border-radius: 3px; background: #f0ebe3; margin: 4px 0 2px; overflow: hidden; }
.ab-bar span { display: block; height: 100%; border-radius: 3px; }
.ab-line { display: flex; justify-content: space-between; font-size: .78rem; font-variant-numeric: tabular-nums; }

/* Idées */
.idea { border-top: 1px solid var(--line); padding: 10px 0; }
.idea:first-child { border-top: 0; padding-top: 0; }
.idea-title { font-weight: 600; font-size: .9rem; }
.idea-desc { font-size: .84rem; color: var(--ink-2); margin: 3px 0 8px; }
.idea-actions { display: flex; gap: 6px; align-items: center; }
.idea-state { font-size: .76rem; color: var(--muted); }

/* Réglages */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
#settingsBox > summary::after { content: '＋'; float: right; color: var(--muted); }
#settingsBox[open] > summary::after { content: '－'; }
.settings { display: grid; gap: 10px; margin-top: 10px; }
@media (min-width: 700px) { .settings { grid-template-columns: 1fr 1fr; } }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: .84rem; color: var(--ink-2); }
.settings input { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-height: 42px; background: var(--surface-2); }
.foot { text-align: center; }

/* Fiche */
dialog { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
dialog::backdrop { background: rgba(31, 29, 26, .45); }
#sheet { width: min(720px, 100vw); margin: auto auto 0; }
@media (min-width: 760px) { #sheet { margin: auto; } }
.sheet-in { background: var(--surface); border-radius: 18px 18px 0 0; padding: 16px; max-height: 92vh; overflow: auto; position: relative; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { .sheet-in { border-radius: 18px; } }
.sheet-close { position: sticky; top: 0; float: right; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem; cursor: pointer; z-index: 2; }
.sheet-top { display: grid; grid-template-columns: 120px 1fr; gap: 14px; }
@media (min-width: 600px) { .sheet-top { grid-template-columns: 180px 1fr; } }
.sheet-title { font-size: 1.2rem; margin: 2px 0 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: .82rem; margin-top: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
@media (min-width: 600px) { .mgrid { grid-template-columns: repeat(4, 1fr); } }
.mcell { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.mcell span { display: block; font-size: .72rem; color: var(--muted); }
.mcell b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.why-box { background: var(--surface-2); border-left: 3px solid var(--gold); border-radius: 8px; padding: 10px 12px; font-size: .88rem; margin: 10px 0; }
.history { font-size: .82rem; color: var(--ink-2); }
.history li { margin-bottom: 4px; }
.sheet-actions { display: flex; gap: 8px; margin: 12px 0; }
.sheet-actions .btn { flex: 1; }
.review-form { background: var(--surface); border-radius: 16px; padding: 16px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 8px; }
.review-form textarea { border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }

/* Infobulle des graphiques : la valeur d'abord, le libellé ensuite */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 10px; font-size: .8rem; box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 240px; }
.tip b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.tip span { color: #d9d3c8; }

/* Connexion */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 28px 22px; width: min(380px, 100%); text-align: center; }
.login-logo { height: 52px; width: auto; margin: 0 auto 10px; }
.login-card h1 { font-size: 1.5rem; }
.login-card form { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; text-align: left; }
.login-card label { font-size: .84rem; color: var(--ink-2); }
.login-card input { border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-height: 46px; background: var(--surface-2); }
.login-error { color: var(--bad); font-size: .84rem; margin: 0; }

/* ── v2 : inspirée des tableaux créas (Motion, Triple Whale, Stripe) ─────── */
.period-note { margin-left: auto; }
@media (max-width: 640px) { .period-note { margin-left: 0; width: 100%; } }
@media (min-width: 900px) { .grid-wide { grid-template-columns: 3fr 2fr; } }

/* Tuiles KPI : valeur, écart vs période précédente, mini-courbe */
.kpi { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 0; cursor: default; font: inherit; color: inherit; }
button.kpi { cursor: pointer; transition: box-shadow .15s, transform .15s; }
button.kpi:hover { box-shadow: 0 2px 4px rgba(31,29,26,.06), 0 8px 24px rgba(31,29,26,.08); }
button.kpi[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: -2px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.delta { font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 1px 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta-up { color: #0b6e0b; background: #e9f6e9; }
.delta-down { color: #a32929; background: #fbeaea; }
.delta-flat, .delta-new { color: var(--ink-2); background: #f1ede6; }
.spark { width: 100%; height: 30px; margin-top: 6px; display: block; overflow: visible; }
.spark path.line { fill: none; stroke: var(--data-1); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark path.area { fill: rgba(168,116,15,.08); stroke: none; }
.spark-empty { height: 30px; margin-top: 6px; }

/* Parcours (entonnoir) */
.funnel { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.fstep-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .84rem; gap: 8px; }
.fstep-top b { font-variant-numeric: tabular-nums; font-size: .95rem; }
.fbar { height: 12px; background: #f3eee6; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.fbar span { display: block; height: 100%; background: var(--data-1); border-radius: 4px; min-width: 2px; }
.fconv { font-size: .74rem; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.fconv.leak { color: #a32929; font-weight: 600; }

/* Galerie façon « card view » */
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .gallery { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.gcard { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); text-align: left; padding: 0; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.gcard:hover { box-shadow: 0 8px 24px rgba(31,29,26,.10); transform: translateY(-1px); }
.gcard .thumb { width: 100%; border-radius: 0; }
.gcard .g-rank { position: absolute; bottom: 8px; left: 8px; background: rgba(255,255,255,.92); color: var(--ink); font-weight: 700; font-size: .75rem; border-radius: 999px; min-width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; padding: 0 7px; font-variant-numeric: tabular-nums; }
.gcard .g-verdict { position: absolute; top: 8px; right: 8px; }
.gcard .g-verdict .verdict { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.g-hook { position: absolute; bottom: 8px; right: 8px; background: rgba(31,29,26,.78); color: #fff; border-radius: 10px; padding: 4px 8px; text-align: right; line-height: 1.1; }
.g-hook b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.g-hook span { font-size: .62rem; opacity: .85; }
.g-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.g-title { font-weight: 600; font-size: .84rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.g-meta { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 4px; }
.g-stats div { background: var(--surface-2); border-radius: 8px; padding: 4px 6px; }
.g-stats span { display: block; font-size: .62rem; color: var(--muted); }
.g-stats b { font-size: .84rem; font-variant-numeric: tabular-nums; }
.vf-n { color: var(--muted); font-weight: 500; margin-left: 2px; font-variant-numeric: tabular-nums; }
.vf-n:empty { display: none; }
.gcard .thumb { aspect-ratio: 4 / 5; }
.row .thumb { aspect-ratio: 4 / 5; }
.thumb img { background: #efe6d7; }
.card-head { flex-wrap: wrap; }
.kpi-top { align-items: baseline; flex-wrap: wrap; }
.kpi-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
