/* ============================================================
   LINKFLOW v2 — Design tokens (Primelis editorial × dark UI)
   ============================================================ */

:root {
  /* Dark palette (default) */
  --bg: oklch(0.135 0.008 260);
  --bg-elev: oklch(0.175 0.01 260);
  --bg-card: oklch(0.19 0.011 260);
  --bg-hover: oklch(0.22 0.012 260);
  --border: oklch(0.26 0.011 260);
  --border-strong: oklch(0.34 0.012 260);
  --text: oklch(0.98 0.005 260);
  --text-muted: oklch(0.68 0.008 260);
  --text-subtle: oklch(0.5 0.008 260);

  /* Primelis lavande gradient */
  --accent-1: oklch(0.82 0.09 285); /* light lavender */
  --accent-2: oklch(0.68 0.13 275); /* mid violet */
  --accent-3: oklch(0.55 0.14 268); /* deep violet */
  --accent: var(--accent-2);
  --accent-soft: oklch(0.68 0.13 275 / 0.15);
  --accent-glow: oklch(0.72 0.13 278 / 0.35);
  --accent-fg: oklch(0.99 0.003 285);

  /* Semantic */
  --good: oklch(0.78 0.14 155);
  --warn: oklch(0.82 0.14 75);
  --bad: oklch(0.7 0.18 25);

  /* Fonts */
  --font-display: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Sizing */
  --row-h: 48px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.5);
  --shadow-md: 0 4px 20px oklch(0 0 0 / 0.4), 0 1px 3px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 24px 60px oklch(0 0 0 / 0.6), 0 8px 20px oklch(0 0 0 / 0.4);
  --shadow-glow: 0 0 60px oklch(0.72 0.13 278 / 0.15);
}

[data-density='compact'] {
  --row-h: 36px;
}
[data-theme='light'] {
  --bg: oklch(0.99 0.003 285);
  --bg-elev: oklch(1 0 0);
  --bg-card: oklch(0.98 0.005 285);
  --bg-hover: oklch(0.955 0.006 285);
  --border: oklch(0.91 0.008 285);
  --border-strong: oklch(0.83 0.01 285);
  --text: oklch(0.18 0.011 275);
  --text-muted: oklch(0.5 0.011 275);
  --text-subtle: oklch(0.68 0.009 275);
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 275 / 0.06);
  --shadow-md: 0 4px 16px oklch(0.2 0.01 275 / 0.08);
  --shadow-lg: 0 20px 40px oklch(0.2 0.01 275 / 0.15);
}

* {
  box-sizing: border-box;
}
html,
body,
#root {
  height: 100%;
  margin: 0;
}
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.serif {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ============================================================
   Editorial serif type scale
   ============================================================ */
.editorial-1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(56px, 8vw, 128px);
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.editorial-2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.editorial-3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.editorial-italic {
  font-style: italic;
}

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 216px 1fr;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Decorative lavender arrows (Primelis-style, subtle) */
.deco-shape {
  position: fixed;
  pointer-events: none;
  opacity: 0.55;
  filter: blur(0.5px);
  z-index: 0;
  transition: opacity 0.6s;
}
.deco-shape.tl {
  top: -80px;
  left: 180px;
  width: 280px;
  transform: rotate(-15deg);
}
.deco-shape.br {
  bottom: -120px;
  right: -60px;
  width: 380px;
  transform: rotate(200deg);
}
[data-theme='light'] .deco-shape {
  opacity: 0.35;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  gap: 2px;
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 28px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.brand-name em {
  color: var(--accent-1);
  font-style: italic;
  font-weight: 400;
}

.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 20px 8px 6px;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 450;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-elev);
  color: var(--text);
}
.nav-item.active {
  background: var(--bg-elev);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent-1), var(--accent-3));
  border-radius: 2px;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}
.nav-item.active .badge {
  background: var(--accent-soft);
  color: var(--accent-1);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.65 0.12 320), oklch(0.6 0.14 265));
  color: white;
  font-weight: 600;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-info .name {
  font-size: 13px;
  font-weight: 550;
}
.user-info .plan {
  font-size: 11px;
  color: var(--accent-1);
  font-family: var(--font-display);
  font-style: italic;
}

/* ============================================================
   Main content area
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  z-index: 1;
}
.main-scroll {
  flex: 1;
  overflow: auto;
  scroll-behavior: smooth;
}

.topbar {
  height: 60px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.crumb {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.crumb .label {
  color: var(--text-subtle);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}
.crumb h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.crumb h1 em {
  color: var(--accent-1);
  font-weight: 400;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-elev);
  border-color: var(--border-strong);
}
.btn-primary {
  background: white;
  color: black;
  border-color: transparent;
}
[data-theme='light'] .btn-primary {
  background: oklch(0.18 0.011 275);
  color: white;
}
.btn-primary:hover {
  filter: brightness(0.94);
}
.btn-accent {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: oklch(0.15 0.01 275);
  border-color: transparent;
  font-weight: 550;
  box-shadow: 0 0 24px var(--accent-glow);
}
.btn-accent:hover {
  filter: brightness(1.05);
}
.btn-danger {
  background: var(--bad, #e5484d);
  color: #fff;
  border-color: transparent;
  font-weight: 550;
}
.btn-danger:hover {
  filter: brightness(1.08);
}
.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.confirm-backdrop {
  z-index: 1200;
}
/* Barre d'enregistrement des paramètres (T4) : collante, met en avant les modifications en attente */
.save-bar {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  z-index: 5;
}
.save-bar.dirty {
  border-color: var(--accent-1);
}
.save-bar.dirty #st-dirty {
  color: var(--accent-1);
  font-weight: 600;
}
.btn-ghost {
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-elev);
}
.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
}
.btn-icon {
  width: 36px;
  padding: 0;
  justify-content: center;
}
.btn-icon.btn-sm {
  width: 30px;
}

/* Search input */
.search-input {
  position: relative;
  min-width: 320px;
}
.search-input input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: all 0.15s;
  font-size: 13px;
  color: var(--text);
}
.search-input input::placeholder {
  color: var(--text-subtle);
}
.search-input input:focus {
  border-color: var(--accent-2);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
}
.search-input kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-subtle);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-elevated {
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.card-title em {
  color: var(--accent-1);
  font-weight: 400;
}
.card-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 500;
}
.card-body {
  padding: 22px;
}

/* ============================================================
   Badges & Pills
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-muted);
  white-space: nowrap;
  border: 1px solid var(--border);
}
.pill.accent {
  background: var(--accent-soft);
  color: var(--accent-1);
  border-color: transparent;
}
.pill.good {
  background: oklch(0.78 0.14 155 / 0.15);
  color: oklch(0.85 0.14 155);
  border-color: transparent;
}
.pill.warn {
  background: oklch(0.82 0.14 75 / 0.15);
  color: oklch(0.88 0.13 75);
  border-color: transparent;
}
/* Rapport client (C6) : impression / PDF */
@media print {
  .sidebar,
  .topbar,
  .pool-bar,
  .drawer-backdrop,
  .drawer,
  .no-print,
  #toast,
  .deco-shape {
    display: none !important;
  }
  body,
  .app,
  .main,
  #screen {
    background: #fff !important;
    color: #111 !important;
    margin: 0;
    padding: 0;
  }
  .report-page {
    padding: 0 !important;
    max-width: none;
  }
  .card {
    border: 1px solid #ddd;
    break-inside: avoid;
    box-shadow: none;
  }
  .metric,
  .pill,
  .tbl th,
  .tbl td {
    color: #111 !important;
    background: #fff !important;
    border-color: #ddd !important;
  }
  a {
    color: #111;
    text-decoration: none;
  }
}
.alerts-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-1);
  color: var(--bg, #111);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.select-chip {
  height: 30px;
  padding: 0 28px 0 12px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-subtle) 50%), linear-gradient(135deg, var(--text-subtle) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 12px,
    calc(100% - 10px) 12px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.select-chip:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
}
.pill.inferred {
  border-style: dashed;
  cursor: help;
}
.pill.bad {
  background: oklch(0.7 0.18 25 / 0.15);
  color: oklch(0.82 0.16 25);
  border-color: transparent;
}

.mp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px 0 6px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 550;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.mp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  flex-shrink: 0;
}

/* ============================================================
   LS Score badge (Linkflow Score)
   ============================================================ */
.ls-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 4px;
  height: 26px;
  border-radius: 13px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.ls-score .ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.ls-score.hi {
  color: var(--accent-1);
  border-color: var(--accent-soft);
}
.ls-score.md {
  color: var(--warn);
}
.ls-score.lo {
  color: var(--text-muted);
}
.ls-score .ring {
  background: conic-gradient(currentColor calc(var(--v, 0) * 1%), var(--bg-elev) 0);
}
.ls-score .ring::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--bg);
}

/* ============================================================
   Table
   ============================================================ */
.tbl-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl th,
.tbl td {
  height: var(--row-h);
  padding: 0 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.tbl th {
  background: var(--bg);
  font-size: 10.5px;
  font-weight: 550;
  color: var(--text-subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
  height: 40px;
}
.tbl th.sortable {
  cursor: pointer;
}
.tbl th.sortable:hover {
  color: var(--text);
}
.tbl th .arr {
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}
.tbl th.sorted {
  color: var(--accent-1);
}
.tbl th.sorted .arr {
  opacity: 1;
}
.tbl tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}
.tbl tbody tr:hover {
  background: var(--bg-hover);
}
.tbl tbody tr.sel {
  background: var(--accent-soft);
}
.tbl tbody tr:last-child td {
  border-bottom: none;
}
.tbl td.right,
.tbl th.right {
  text-align: right;
}
.tbl td.center,
.tbl th.center {
  text-align: center;
}

/* Price cells */
.price {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.price.best {
  background: oklch(0.78 0.14 155 / 0.18);
  color: oklch(0.85 0.14 155);
}
.price.worst {
  color: var(--text-subtle);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.price.na {
  color: var(--text-subtle);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 400;
}

/* Domain cell */
.domain-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.domain-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ============================================================
   Editorial hero
   ============================================================ */
.hero {
  position: relative;
  padding: 60px 40px 40px;
  border-bottom: 1px solid var(--border);
}
.hero .eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-1);
  font-weight: 500;
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-size: clamp(48px, 6.5vw, 96px);
}
/* Pages outil (dans .p-8) : titre plus contenu que le hero du dashboard (m22) */
.p-8 .hero h1 {
  font-size: clamp(32px, 4.5vw, 56px);
}
.hero h1 em {
  font-style: italic;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .sub {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 640px;
  line-height: 1.55;
  margin-bottom: 28px;
}

/* ============================================================
   AI Search form
   ============================================================ */
.ai-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.ai-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-1), transparent);
  opacity: 0.6;
}
.ai-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.ai-field label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 550;
}
.ai-field input,
.ai-field textarea,
.ai-field select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  outline: none;
  transition: all 0.15s;
  font-size: 13.5px;
  color: var(--text);
  font-family: var(--font-sans);
  resize: none;
}
.ai-field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 34px;
  cursor: pointer;
}
.ai-field select option {
  background: var(--bg-elev);
  color: var(--text);
}
.ai-field input::placeholder,
.ai-field textarea::placeholder {
  color: var(--text-subtle);
}
.ai-field input:focus,
.ai-field textarea:focus,
.ai-field select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================================================
   Metrics
   ============================================================ */
.metric {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.metric-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 550;
  margin-bottom: 10px;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.metric-value .unit {
  font-family: var(--font-sans);
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
  letter-spacing: 0;
  white-space: nowrap;
}
.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 550;
  margin-top: 10px;
}
.metric-delta.up {
  color: var(--good);
}
.metric-delta.down {
  color: var(--bad);
}
.metric-spark {
  margin-top: 14px;
  height: 36px;
}

/* ============================================================
   Score bar (thin)
   ============================================================ */
.score-bar {
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-1));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================
   Drawer
   ============================================================ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.08 0.005 260 / 0.6);
  backdrop-filter: blur(4px);
  z-index: 40;
  animation: fade-in 0.2s ease;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 620px;
  max-width: 94vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 41;
  display: flex;
  flex-direction: column;
  animation: slide-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slide-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.drawer-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 24px 32px;
}
.drawer-footer {
  padding: 18px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   Chips (filter chips)
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s;
}
.chip:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.chip.active {
  background: var(--accent-soft);
  color: var(--accent-1);
  border-color: transparent;
}
.chip.active .x {
  opacity: 0.7;
}

/* ============================================================
   Rule line — for editorial separators
   ============================================================ */
.rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  margin: 40px 0;
}

/* ============================================================
   Utilities
   ============================================================ */
.p-8 {
  padding: 32px;
}
.p-6 {
  padding: 24px;
}
.px-8 {
  padding-left: 32px;
  padding-right: 32px;
}
.py-6 {
  padding-top: 24px;
  padding-bottom: 24px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 12px;
}
.mt-4 {
  margin-top: 16px;
}
.mt-6 {
  margin-top: 24px;
}
.mt-8 {
  margin-top: 32px;
}
.mb-2 {
  margin-bottom: 8px;
}
.mb-3 {
  margin-bottom: 12px;
}
.mb-4 {
  margin-bottom: 16px;
}
.mb-6 {
  margin-bottom: 24px;
}
.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 12px;
}
.gap-4 {
  gap: 16px;
}
.gap-6 {
  gap: 24px;
}
.row {
  display: flex;
  align-items: center;
}
.col {
  display: flex;
  flex-direction: column;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.text-muted {
  color: var(--text-muted);
}
.text-subtle {
  color: var(--text-subtle);
}
.text-accent {
  color: var(--accent-1);
}
.text-sm {
  font-size: 12.5px;
}
.text-xs {
  font-size: 11.5px;
}
.text-lg {
  font-size: 16px;
}
.italic {
  font-style: italic;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* Entry animations */
.fade-up {
  animation: fade-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fade-up-2 {
  animation: fade-up 0.6s 0.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fade-up-3 {
  animation: fade-up 0.6s 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fade-up-4 {
  animation: fade-up 0.6s 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ============================================================
   Workspace switcher (top of sidebar)
   ============================================================ */
.ws-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0 -4px 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.ws-switcher:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.ws-avatar {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 500;
  color: white;
  flex-shrink: 0;
  font-size: 14px;
}
.ws-info {
  flex: 1;
  min-width: 0;
}
.ws-info .name {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-info .url {
  font-size: 10.5px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

/* ============================================================
   Compare mode bar (persistent bottom bar)
   ============================================================ */
.pool-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 640px;
  max-width: 900px;
  background: oklch(0.15 0.008 260);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 30;
  box-shadow:
    0 20px 60px oklch(0 0 0 / 0.6),
    0 0 40px oklch(0.72 0.13 278 / 0.15);
  animation: fade-up 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
[data-theme='light'] .pool-bar {
  background: white;
  border-color: var(--border);
}
.pool-bar-count {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.pool-bar-count .n {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  color: var(--accent-1);
}
.pool-bar-count .label {
  font-size: 12px;
  color: var(--text-muted);
}
.pool-bar-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}
.pool-bar-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pool-bar-stat .lbl {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 550;
}
.pool-bar-stat .val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}
.pool-bar-stat .val.good {
  color: var(--good);
}
.pool-bar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ============================================================
   Data cell viz (mini bars in table)
   ============================================================ */
.mini-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mini-bar-track {
  width: 34px;
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.mini-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-1));
  border-radius: 2px;
}
.mini-bar-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 20px;
}

/* ============================================================
   Row selection checkbox
   ============================================================ */
.row-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  display: grid;
  place-items: center;
  transition: all 0.12s;
  flex-shrink: 0;
}
.row-check.on {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.row-check svg {
  color: white;
  opacity: 0;
  transition: opacity 0.1s;
}
.row-check.on svg {
  opacity: 1;
}

/* ============================================================
   Modal / dialog
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.08 0.005 260 / 0.7);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 40px;
  animation: fade-in 0.2s ease;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modal-in {
  from {
    transform: scale(0.96) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}
.modal-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-body {
  flex: 1;
  overflow: auto;
  padding: 28px 32px;
}
.modal-footer {
  padding: 18px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Peec AI badge */
.peec-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px 0 4px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 550;
  background: linear-gradient(135deg, oklch(0.55 0.19 320), oklch(0.6 0.16 280));
  color: white;
  border: 0;
}
.peec-badge::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  color: oklch(0.55 0.19 320);
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 9px;
}

/* Compare panel */
.cmp-col {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-right: 1px solid var(--border);
  min-height: 400px;
}
.cmp-col:last-child {
  border-right: none;
}
.cmp-col h4 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 4px;
}
.cmp-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.cmp-row .lbl {
  color: var(--text-subtle);
}
.cmp-row .val {
  font-family: var(--font-mono);
  font-weight: 550;
}
.cmp-row .val.best {
  color: var(--good);
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s;
}
.segmented button:hover {
  color: var(--text);
}
.segmented button.on {
  background: var(--bg-hover);
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: oklch(0.2 0.008 260);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fade-up 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Indice de confiance des métriques (A4) */
.trust-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  min-width: 34px;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 650;
  border: 1px solid transparent;
}
.trust-badge small {
  font-size: 9.5px;
  font-weight: 500;
  opacity: 0.8;
}
.trust-A {
  background: color-mix(in oklch, var(--good) 18%, transparent);
  color: var(--good);
}
.trust-B {
  background: color-mix(in oklch, var(--accent-2) 16%, transparent);
  color: var(--accent-1);
}
.trust-C {
  background: color-mix(in oklch, var(--warn) 18%, transparent);
  color: var(--warn);
}
.trust-D {
  background: color-mix(in oklch, var(--bad) 18%, transparent);
  color: var(--bad);
}
.trust-none {
  color: var(--text-subtle);
  border-color: var(--border);
}

/* Onglets d'entrée (R3) : Comparateur / Bonnes affaires, AI Link Finder / Par concurrents, Pools / Rapport */
.screen-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 32px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 3;
}
.screen-tabs button {
  padding: 8px 14px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition:
    color 0.12s,
    border-color 0.12s;
}
.screen-tabs button:hover {
  color: var(--text);
}
.screen-tabs button.on {
  color: var(--text);
  border-bottom-color: var(--accent-1);
}
@media (max-width: 960px) {
  .screen-tabs {
    padding: 8px 12px 0;
    overflow-x: auto;
  }
}
@media print {
  .screen-tabs {
    display: none !important;
  }
}

/* ============================================================
   Responsive (R2) : sous 960 px la barre latérale devient un volet
   (bouton ☰ du bandeau), les grilles passent sur une colonne, les
   titres se resserrent ; les tableaux défilent dans .tbl-wrap.
   ============================================================ */
.sidebar-toggle {
  display: none;
}
@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 0 100vw transparent;
    overflow-y: auto;
    z-index: 40;
  }
  .app.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw oklch(0 0 0 / 0.45);
  }
  .sidebar-toggle {
    display: inline-flex;
  }
  .topbar {
    padding: 0 14px;
    gap: 10px;
  }
  .topbar .crumb .label {
    display: none;
  }
  .topbar .search-input {
    min-width: 0;
    flex: 1;
  }
  .topbar .search-input kbd {
    display: none;
  }
  .p-8 {
    padding: 16px;
  }
  .hero {
    padding: 28px 16px 24px;
  }
  .hero h1,
  .p-8 .hero h1 {
    font-size: clamp(28px, 8vw, 40px);
  }
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .metric-value {
    font-size: 34px;
  }
  .metric-value .unit {
    font-size: 14px;
  }
  .grid-3 > .card[style*='span 2'] {
    grid-column: auto !important;
  }
  .pool-bar {
    min-width: 0;
    width: calc(100vw - 20px);
    left: 10px;
    transform: none;
  }
  .drawer {
    width: 100vw;
    max-width: 100vw;
  }
  .deco-shape {
    display: none;
  }
}
