:root {
  --teal: #009AA2;
  --teal-strong: #007981;
  --navy: #242D36;
  --ink: #242D36;
  --ink-2: #4A5560;
  --ink-3: #66707C;
  --line: #E2E7EC;
  --line-2: #EEF1F4;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --tint: #ECF8F9;
  --good: #1F9D62;
  --bad: #D5443B;
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--surface-2); color: var(--ink);
  font: 400 14px/1.55 'Poppins', system-ui, sans-serif;
}
a { color: var(--teal-strong); }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ---------- en-tête ---------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 32px; padding: 0 24px; height: 60px;
  position: sticky; top: 0; z-index: 10;
}
.topbar img { height: 26px; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
  text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500;
}
.topbar nav a:hover { background: var(--surface-2); }
.topbar nav a.active { color: var(--teal-strong); background: var(--tint); }
.topbar .user { color: var(--ink-3); font-size: 13px; white-space: nowrap; }

main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 600; letter-spacing: 0.3em; text-transform: uppercase; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- filtres ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px;
}
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-3); gap: 4px; }
.filters select, .filters input, .login input {
  font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); min-height: 36px;
}
.filters .custom { display: none; gap: 12px; }
.filters .custom.show { display: flex; }
.btn {
  font: inherit; font-weight: 500; border: 0; border-radius: 8px; padding: 8px 16px; min-height: 36px;
  background: var(--teal); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.btn:hover { background: var(--teal-strong); }
.btn.ghost { background: transparent; color: var(--teal-strong); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--tint); }
.checkbox { flex-direction: row !important; align-items: center; min-height: 36px; }

/* ---------- cartes ---------- */
.grid { display: grid; gap: 20px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 20px; }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.kpi .value { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.kpi .value small { font-size: 16px; color: var(--ink-3); font-weight: 500; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* ---------- barres HTML (part de voix, concurrents) ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 56px; gap: 12px; align-items: center; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.bar-row .track { height: 12px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.bar-row.own .name { font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

/* ---------- graphique ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.small { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--teal-strong); }
th.sorted-asc::after { content: ' ▲'; font-size: 9px; }
th.sorted-desc::after { content: ' ▼'; font-size: 9px; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.tags { min-width: 230px; }
td.url { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; background: var(--tint); color: var(--teal-strong); border-radius: 999px; padding: 1px 8px; font-size: 11px; margin: 1px 2px 1px 0; white-space: nowrap; }
.tag-soft { background: transparent; border: 1px solid #A8E2E5; }
.tag-ads { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.leader-own { color: var(--teal-strong); font-weight: 600; }
.mix { display: flex; height: 10px; width: 140px; gap: 2px; }
.mix span { display: block; height: 100%; }
.mix span:first-child { border-radius: 3px 0 0 3px; }
.mix span:last-child { border-radius: 0 3px 3px 0; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--good); }
.status.partial, .status.running { color: #9A6B00; }
.status.error { color: var(--bad); }
.empty { padding: 32px; text-align: center; color: var(--ink-3); }
.note { background: var(--tint); border-radius: var(--radius); padding: 12px 16px; color: var(--ink-2); font-size: 13px; margin-bottom: 20px; }
.search { min-width: 220px; }

/* ---------- connexion ---------- */
.login { max-width: 380px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; }
.login img { height: 30px; margin-bottom: 24px; }
.login label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.login input { width: 100%; }
.login .btn { width: 100%; justify-content: center; margin-top: 20px; }
.error { color: var(--bad); font-size: 13px; margin-top: 12px; }

@media (max-width: 900px) {
  .two { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar .user { display: none; }
  main { padding: 16px; }
  .bar-row { grid-template-columns: 120px 1fr 50px; }
}

/* ---------- carte des thématiques ---------- */
.heatmap td.cell { text-align: center; min-width: 64px; border: 2px solid var(--surface); border-radius: 6px; font-variant-numeric: tabular-nums; }
.heatmap td.cell.lead { box-shadow: inset 0 0 0 2px var(--navy); font-weight: 600; }
.heatmap th .swatch { vertical-align: middle; }
.heatmap th.dom, .heatmap td.cell { width: 10%; }
.heatmap th.dom { white-space: normal; text-align: center; }

/* ---------- opportunités ---------- */
.ops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ops li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); align-items: baseline; }
.ops li:last-child { border-bottom: 0; }
.ops .pos { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.ops .gain { font-weight: 600; color: var(--teal-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- écarts, éléments de page, onglets internes ---------- */
.delta.flat { color: var(--ink-3); }
.kpi .delta { margin-left: 6px; }
.feat { display: inline-block; font-size: 10px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin: 1px 2px 1px 0; white-space: nowrap; }
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.subtabs a { text-decoration: none; color: var(--ink-2); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); font-weight: 500; }
.subtabs a.active { color: var(--teal-strong); background: var(--tint); border-color: transparent; }
.coltoggles { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.coltoggles label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
table.hide-comp .c-comp, table.hide-gsc .c-gsc, table.hide-feat .c-feat { display: none; }
td.pos small { color: var(--ink-3); margin-left: 3px; font-size: 10px; }
td.pos small.up { color: var(--good); }
td.pos small.down { color: var(--bad); }
.yoy-toggle { display: inline-flex; gap: 4px; }
.yoy-toggle button { font: inherit; font-size: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 2px 8px; cursor: pointer; color: var(--ink-2); }
.yoy-toggle button.active { background: var(--tint); color: var(--teal-strong); border-color: transparent; }
.print-btn { min-height: 30px; padding: 4px 12px; }

/* ---------- impression / PDF ---------- */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .filters, .btn, .print-btn, .coltoggles, .subtabs, #search { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { break-inside: avoid; border-color: #ccc; }
  .two { grid-template-columns: 1fr 1fr; }
  .table-wrap { overflow: visible; }
}
.suspect { display: inline-block; font-size: 10px; font-weight: 600; color: #8A5A00; background: #FFF4D6; border-radius: 4px; padding: 0 4px; margin-left: 4px; cursor: help; }
