@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300..800&family=Geist+Mono:wght@400;500;600&display=swap');

/* Thème sombre — palette ABV (cobalt + acide) adaptée au fond foncé */
:root {
  color-scheme: dark;
  --bg: #0e1015;          /* fond de page */
  --surface: #161920;     /* panneaux, cartes */
  --surface-2: #1d2129;   /* champs, survols */
  --surface-3: #262b35;   /* éléments actifs */
  --line: #2a2f3a;        /* séparations */
  --line-strong: #3b4251; /* en-têtes de tableau */
  --text: #e8eaef;
  --text-2: #b9bfca;
  --mute: #8b93a1;
  --accent: #7aa5ff;      /* cobalt éclairci, lisible sur fond sombre */
  --accent-strong: #2f63e0;
  --accent-soft: rgba(122, 165, 255, 0.12);
  --acid: #e2d704;
  --on-acid: #15171c;
  --up: #5bd68a; --up-soft: rgba(91, 214, 138, 0.13);
  --down: #ff7b72; --down-soft: rgba(255, 123, 114, 0.13);
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; background: var(--bg); }
body { font-family: 'Bricolage Grotesque', system-ui, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: 'Geist Mono', monospace; }
::selection { background: var(--acid); color: var(--on-acid); }

/* ─── Barre du haut ─── */
.top { background: #0a0c10; border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1180px; margin: 0 auto; padding: 0 28px; height: 58px; display: flex; align-items: center; gap: 28px; }
.logo { font-weight: 800; letter-spacing: -0.02em; font-size: 1.15rem; color: var(--text); }
.logo b { color: var(--acid); }
.top nav { display: flex; gap: 20px; flex: 1; }
.top nav a { color: var(--mute); font-weight: 500; }
.top nav a:hover, .top nav a.on { color: var(--text); text-decoration: none; }
.top .out { color: var(--mute); font-size: .9rem; }

main { max-width: 1180px; margin: 0 auto; padding: 32px 28px 80px; }
.eyebrow { font-family: 'Geist Mono', monospace; font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; color: var(--text); }
h1 em { font-style: normal; color: var(--acid); }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 12px; color: var(--text); }
.sub { color: var(--mute); margin-top: 6px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }

/* ─── Boutons ─── */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: .95rem; }
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: #2552c4; border-color: #2552c4; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn small { font-weight: 500; opacity: .8; }
.btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── Panneaux ─── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .g2, .g3 { grid-template-columns: 1fr; } }
section + section { margin-top: 22px; }

.kpi { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--line-strong); padding: 18px 20px; }
.kpi.main { border-top-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 85%); }
.kpi-label { font-family: 'Geist Mono', monospace; font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }
.kpi-value { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.045em; line-height: 1.05; margin-top: 8px; color: var(--text); }
.kpi.main .kpi-value { color: var(--accent); }
.kpi-detail { color: var(--mute); font-size: .88rem; margin-top: 4px; }

.trend { font-family: 'Geist Mono', monospace; font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; }
.trend.hausse { color: var(--up); background: var(--up-soft); }
.trend.baisse { color: var(--down); background: var(--down-soft); }
.trend.stable { color: var(--text-2); background: var(--surface-3); }

/* ─── Tableau de bord ─── */
.clients { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; transition: border-color .15s, background .15s; color: var(--text); }
.card:hover { border-color: var(--accent); background: #191d25; text-decoration: none; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-name { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.card-sector { color: var(--mute); font-size: .88rem; }
.badge { font-family: 'Geist Mono', monospace; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.badge.on { background: var(--acid); color: var(--on-acid); }
.badge.off { background: var(--surface-3); color: var(--mute); }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-v { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.04em; color: var(--text); }
.stat-l { font-size: .78rem; color: var(--mute); }
.card-foot { font-size: .82rem; color: var(--mute); border-top: 1px dotted var(--line); padding-top: 10px; display: flex; justify-content: space-between; gap: 8px; }
.empty { color: var(--mute); font-size: .9rem; }

/* ─── Tableaux ─── */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { font-family: 'Geist Mono', monospace; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); font-weight: 500; text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line-strong); }
td { padding: 8px 8px; border-bottom: 1px dotted var(--line); vertical-align: top; color: var(--text-2); }
td.n, th.n { text-align: right; font-family: 'Geist Mono', monospace; font-size: .85rem; white-space: nowrap; }
tr.client td { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pos { color: var(--up) !important; } .neg { color: var(--down) !important; }

.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 8px; }
.legend { font-size: .82rem; color: var(--mute); margin: 4px 0 0 6px; }
.legend span { display: inline-block; width: 22px; height: 2px; vertical-align: middle; margin: 0 6px 0 14px; }
.legend span:first-child { margin-left: 0; }
.findings { background: var(--acid); color: var(--on-acid); border-radius: var(--radius); padding: 18px 22px; }
.findings .eyebrow { color: var(--on-acid); }
.findings a { color: var(--on-acid); font-weight: 700; }
.findings ul { list-style: none; }
.findings li { padding-left: 18px; text-indent: -18px; margin-bottom: 6px; }
.findings li::before { content: "→ "; font-weight: 700; }

/* ─── Alertes ─── */
.alert { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid transparent; }
.alert a { color: inherit; font-weight: 700; text-decoration: underline; }
.alert.info { background: var(--accent-soft); color: var(--accent); border-color: rgba(122,165,255,.25); }
.alert.ok { background: var(--up-soft); color: var(--up); border-color: rgba(91,214,138,.25); }
.alert.err { background: var(--down-soft); color: var(--down); border-color: rgba(255,123,114,.25); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ─── Formulaires ─── */
form.stack { display: grid; gap: 16px; max-width: 760px; }
label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: 5px; color: var(--text); }
label small { font-weight: 400; color: var(--mute); }
input[type=text], input[type=password], textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--mute); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--acid); width: 16px; height: 16px; }
textarea { min-height: 84px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }

/* ─── Réponses ─── */
.filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filters a { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: .88rem; }
.filters a:hover { text-decoration: none; background: var(--surface-2); }
.filters a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.q > summary { list-style: none; cursor: pointer; padding: 16px 20px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.q > summary:hover { background: var(--surface-2); border-radius: var(--radius); }
.q > summary::-webkit-details-marker { display: none; }
.q-title { font-weight: 700; color: var(--text); }
.q-meta { font-size: .8rem; color: var(--mute); margin-top: 2px; }
.q-body { border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.ans { padding: 18px 20px; border-right: 1px solid var(--line); }
.ans:last-child { border-right: none; }
.ans-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.ans-llm { font-weight: 700; color: var(--text); }
.yes { background: var(--accent-strong); color: #fff; }
.no { background: var(--surface-3); color: var(--mute); }
.ans-text { font-size: .9rem; max-height: 420px; overflow: auto; padding-right: 6px; color: var(--text-2); }
.ans-text strong { color: var(--text); }
.ans-text p, .ans-text ul { margin-bottom: 8px; }
.ans-text ul { padding-left: 18px; }
.ans-text h4 { font-size: .95rem; margin: 10px 0 4px; color: var(--text); }
.ans-text table.md { font-size: .82rem; margin: 6px 0 10px; }
.ans-text table.md th { font-family: inherit; font-size: .78rem; letter-spacing: 0; text-transform: none; color: var(--text); font-weight: 700; }
.ans-text table.md td, .ans-text table.md th { padding: 5px 6px; }
.ans-src { margin-top: 12px; font-size: .8rem; color: var(--mute); border-top: 1px dotted var(--line); padding-top: 8px; }
.ans-src a { word-break: break-all; }
pre.log { background: #0a0c10; color: var(--text-2); border: 1px solid var(--line); padding: 18px; border-radius: var(--radius); font-size: .8rem; overflow: auto; white-space: pre-wrap; }

/* ─── Barres de défilement ─── */
* { scrollbar-color: var(--line-strong) transparent; }

/* ─── Connexion ─── */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 36px; width: 360px; }
.login-box .logo { font-size: 1.4rem; margin-bottom: 6px; display: block; }
.login-box p { color: var(--mute); margin-bottom: 22px; font-size: .92rem; }

/* ─── Assistant de création de marque ─── */
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.wiz-steps { list-style: none; display: flex; gap: 6px; margin-bottom: 30px; flex-wrap: wrap; counter-reset: none; }
.wiz-steps li { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 20px; border: 1px solid var(--line); color: var(--mute); font-size: .88rem; font-weight: 600; }
.wiz-steps li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-family: 'Geist Mono', monospace; font-size: .72rem; }
.wiz-steps li.on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.wiz-steps li.on span { background: var(--accent-strong); color: #fff; }
.wiz-steps li.done { color: var(--text-2); }
.wiz-steps li.done span { background: var(--acid); color: var(--on-acid); }
.wiz-start { max-width: 640px; }
.wiz-start .sub { max-width: 56ch; margin-bottom: 26px; }
.wiz-form { display: grid; gap: 18px; }
.wiz-form input[type=text] { font-size: 1.05rem; padding: 12px 14px; }
.wiz-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wiz-wait { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 8px; background: var(--accent-soft); color: var(--text-2); }
.wiz-wait[hidden] { display: none; }
.wiz-wait .spinner { color: var(--accent); margin-top: 4px; }
.wiz-wait strong { color: var(--text); }
.wiz-wait small { color: var(--mute); }
.wiz-wait-steps { margin: 2px 0; }

.ai-note { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 20px; border-radius: var(--radius); border: 1px solid rgba(226,215,4,.22); background: rgba(226,215,4,.06); color: var(--text-2); max-width: 760px; }
.ai-note strong { color: var(--text); }
.ai-tag { font-family: 'Geist Mono', monospace; font-size: .62rem; font-weight: 600; letter-spacing: .1em; padding: 1px 6px; border-radius: 4px; background: var(--acid); color: var(--on-acid); vertical-align: 2px; margin-left: 4px; }
.ai-warn { margin-top: 6px; color: var(--acid); font-size: .9rem; }
.ai-sources { font-size: .85rem; }
.ai-sources summary { cursor: pointer; color: var(--accent); }
.ai-sources ul { margin-top: 8px; padding-left: 18px; max-height: 220px; overflow: auto; max-width: 360px; }
.ai-sources li { margin-bottom: 3px; word-break: break-word; }

form.wiz { display: grid; gap: 18px; max-width: 760px; }
.wiz-pane { border: 0; display: grid; gap: 16px; min-width: 0; }
.wiz-pane[hidden] { display: none; }
.wiz-pane legend { font-size: 1.15rem; font-weight: 700; margin-bottom: 14px; color: var(--text); }
form.wiz:not(.js) .wiz-pane + .wiz-pane { border-top: 1px solid var(--line); padding-top: 18px; }
input:disabled { opacity: .6; }
.wiz-nav { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding-top: 18px; }
.wiz-nav .wiz-err { flex: 1; color: var(--down); font-size: .9rem; }
.wiz-nav [hidden] { display: none; }

.list-ed ul { list-style: none; display: grid; gap: 6px; margin-bottom: 8px; }
.list-ed li { display: flex; align-items: baseline; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.list-ed .li-name { font-weight: 600; color: var(--text); }
.list-ed .li-note { flex: 1; color: var(--mute); font-size: .85rem; }
.list-ed .li-x { margin-left: auto; background: none; border: 0; color: var(--mute); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 6px; border-radius: 4px; }
.list-ed .li-x:hover { color: var(--down); background: var(--down-soft); }
.list-ed .li-x:focus-visible { outline: 2px solid var(--acid); }
.list-add { display: flex; gap: 8px; }
.list-add input { flex: 1; }
.wiz-recap { display: grid; gap: 8px; padding: 14px 16px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.wiz-recap[hidden] { display: none; }
.wiz-recap div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; font-size: .92rem; }
.wiz-recap span { color: var(--mute); }
.wiz-recap strong { font-weight: 600; color: var(--text); }
@media (max-width: 640px) { .row2 { grid-template-columns: 1fr; } }

/* ─── Fenêtre de confirmation ─── */
dialog.modal { margin: auto; width: min(480px, calc(100vw - 32px)); padding: 26px 28px 22px; border-radius: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 24px 60px rgba(0,0,0,.55); }
dialog.modal::backdrop { background: rgba(6, 8, 11, .72); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { dialog.modal[open] { animation: none; } }
dialog.modal h2 { font-size: 1.3rem; letter-spacing: -0.02em; margin-bottom: 16px; }
.modal-facts { display: grid; gap: 0; border-top: 1px solid var(--line); margin-bottom: 14px; }
.modal-facts div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.modal-facts dt { color: var(--mute); }
.modal-facts dd { color: var(--text); }
.modal-facts dd small { color: var(--mute); }
.modal-facts dd strong { color: var(--acid); }
.modal-note { color: var(--text-2); font-size: .9rem; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.q-hint { color: var(--mute); font-size: .86rem; margin: -4px 0 10px; }
tr.q-out td:first-child { color: var(--mute); }
.cell-sub { font-size: .8rem; color: var(--mute); }

/* ─── Onglets client ─── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -8px 0 24px; }
.tabs a { padding: 10px 16px; color: var(--mute); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--acid); }
.h2-link { float: right; font-size: .85rem; font-weight: 600; }
tr.untracked td { color: var(--text-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Concurrents ─── */
.comp-intro { color: var(--text-2); max-width: 80ch; margin-bottom: 22px; }
.comp-kpis { margin-bottom: 22px; }
.comp-kpis .kpi-value { font-size: 2rem; }
.hl { color: var(--acid); font-weight: 600; }
.comp-grid { align-items: start; }
.panel h2 .count { font-family: 'Geist Mono', monospace; font-size: .8rem; color: var(--mute); font-weight: 500; margin-left: 6px; }
.comp-table td { vertical-align: top; }
.comp-table td strong { color: var(--text); font-weight: 600; }
.comp-table tr.leader td { background: rgba(226,215,4,.05); }
.comp-table .badge { margin-left: 4px; vertical-align: 1px; }
.btn.small { padding: 5px 10px; font-size: .82rem; border-radius: 6px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.inline-edit { margin-top: 4px; font-size: .85rem; display: inline-block; margin-right: 14px; vertical-align: top; }
.inline-edit[open] { display: block; margin-right: 0; }
.inline-edit summary { cursor: pointer; color: var(--mute); font-size: .8rem; list-style: none; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit summary:hover { color: var(--accent); }
.inline-edit[open] summary { color: var(--accent); margin-bottom: 6px; }
.inline-edit textarea { min-height: 54px; margin-bottom: 6px; font-size: .88rem; }
.inline-row, .inline-row label { display: flex; gap: 6px; align-items: center; }
select { font: inherit; font-size: .88rem; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-2); color: var(--text); max-width: 220px; }
.comp-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.comp-add input { padding: 8px 10px; }
.more { margin-top: 12px; }
.more > summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.ignored-list { list-style: none; margin-top: 10px; display: grid; gap: 6px; }
.ignored-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--mute); padding: 6px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .comp-add { grid-template-columns: 1fr; } }
.comp-table .btn { font-family: 'Bricolage Grotesque', system-ui, sans-serif; letter-spacing: 0; }
.lead-tag { color: var(--acid); font-size: .8rem; font-weight: 600; margin-top: 2px; }

/* ─── Portée des marques ─── */
.scope { display: inline-block; font-family: 'Geist Mono', monospace; font-size: .72rem; font-weight: 500; letter-spacing: .02em; padding: 1px 7px; border-radius: 10px; vertical-align: 1px; margin-left: 4px; white-space: nowrap; }
.scope.nationale { background: var(--accent-soft); color: var(--accent); }
.scope.locale { background: var(--surface-3); color: var(--text-2); }
.scope.inconnue { color: var(--mute); border: 1px dashed var(--line-strong); }
.scope-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.scope-form input[type=text] { width: 160px; padding: 5px 8px; font-size: .85rem; }
.scope-filters { margin-bottom: 14px; }
tr[hidden] { display: none; }
.zone-table td { vertical-align: top; }
.zone-brand { display: inline-block; margin: 0 14px 4px 0; white-space: nowrap; }
.zone-brand.tracked { color: var(--text); font-weight: 500; }
