/* ===========================================================
   BG COM WORKFORCE — Stylesheet v2 (refonte cockpit)
   Charte : Noir #0a0a0a · Rouge #E10600 · Blanc · Poppins
   Shell : rail latéral fixe + poste de commande.
   =========================================================== */

:root {
  --bg: #0a0a0a;
  --rail-bg: #0d0d0d;
  --surface: #141414;
  --surface-2: #0f0f0f;
  --line: #232323;
  --line-strong: #2f2f2f;
  --red: #E10600;
  --red-hover: #ff1a14;
  --red-tint: #1a0d0d;
  --ink: #f2f2f2;
  --muted: #a3a3a3;
  --faint: #8a8a8a;
  --ok: #4ade80;       /* validation UX uniquement */
  --ok-bg: #0d1f12;
  --warn: #f5b441;
  --warn-bg: #2a2010;
  --err: #ff5555;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 14px;
  /* Échelle d'élévation (dark) + easing unifié (polish v2) */
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 6px 20px rgba(0,0,0,.45);
  --shadow-3: 0 18px 48px rgba(0,0,0,.55);
  --shadow-red: 0 8px 24px rgba(225,6,0,.22);
  --edge-light: inset 0 1px 0 rgba(255,255,255,.05);
  --ease: cubic-bezier(.2,.6,.2,1);
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'SF Mono', 'Monaco', ui-monospace, monospace;
  --rail-w: 224px;
  --z-rail: 200;
  --z-sticky: 100;
  --z-modal: 1000;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 56px 56px;
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 2px;
}

.icon {
  width: 18px; height: 18px;
  stroke: currentColor; stroke-width: 2; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

/* Kicker maison : // SECTION */
.kicker {
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--red);
  margin: 0 0 10px;
}
.kicker::before { content: '// '; }

.tag-tech {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--faint);
  text-transform: uppercase;
  white-space: nowrap;
}
.tag-tech b { color: var(--ink); font-weight: 600; }

/* ===========================================================
   RAIL LATÉRAL
   =========================================================== */
.rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  background: var(--rail-bg);
  border-right: 1px solid #1c1c1c;
  display: flex;
  flex-direction: column;
  z-index: var(--z-rail);
  padding: 20px 14px 16px;
  gap: 4px;
  overflow-y: auto;
}
body.with-rail { padding-left: var(--rail-w); }

.rail-brand { display: block; margin: 0 6px 18px; }
.rail-brand img { width: 100%; max-width: 172px; height: auto; display: block; }

.rail-group { margin-top: 16px; }
.rail-group-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #5c5c5c;
  margin: 0 0 6px;
  padding: 0 10px;
}
.rail-group-title::before { content: '// '; color: var(--red); }

.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  letter-spacing: .3px;
}
.rail-nav a .icon { width: 15px; height: 15px; opacity: .8; }
.rail-nav a:hover { background: #161616; color: #fff; }
.rail-nav a[aria-current="page"] {
  background: var(--red-tint);
  color: #fff;
}
.rail-nav a[aria-current="page"] .icon { color: var(--red); opacity: 1; }
.rail-nav a .rail-soon {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 1px;
  color: #575757;
  text-transform: uppercase;
}

.rail-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1c1c1c;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail-logout {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transition: background .15s, color .15s, border-color .15s;
  width: 100%;
}
.rail-logout:hover { background: #1a1a1a; border-color: #444; color: #fff; }
.rail-meta {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #4a4a4a;
  text-transform: uppercase;
  padding: 0 2px;
  line-height: 1.8;
}

/* ===========================================================
   COCKPIT (accueil)
   =========================================================== */
.cockpit {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 36px 60px;
}
.cockpit-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 34px;
}
.cockpit-head h1 {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: -.035em;
  color: #fff;
  margin: 0 0 8px;
  line-height: 1.04;
  text-wrap: balance;
}
.cockpit-head h1 .accent { color: var(--red); }
.cockpit-sub { color: var(--muted); font-size: 14px; margin: 0; }
.cockpit-sub b { color: var(--ink); font-weight: 600; }

.cockpit section { margin-bottom: 44px; }
.cockpit .agents-section { margin-bottom: 64px; }
.cockpit h2 {
  font-size: 27px;
  font-weight: 800;
  margin: 0 0 4px;
  color: #fff;
  letter-spacing: -.02em;
}
.cockpit h2::before { content: '// '; color: var(--red); }
.section-sub { font-size: 13px; color: var(--faint); margin: 0 0 20px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.section-head .tag-tech { font-size: 9px; }

/* --- Barre de statut données (sous le titre) --- */
.data-strip {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 48px;
}
.data-strip a {
  display: flex;
  align-items: baseline;
  gap: 9px;
  text-decoration: none;
}
.data-strip b {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  transition: color .15s;
}
.data-strip span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--faint);
}
.data-strip a:hover b { color: var(--red); }

/* --- Sections calmes (préparation, historique) --- */
.quiet-section { margin-bottom: 38px; }
.quiet-head {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #737373;
  margin: 0 0 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.quiet-head::before { content: '//'; color: #5a1512; }
.quiet-head span { font-size: 9px; color: #4d4d4d; letter-spacing: 1.5px; margin-left: auto; }

/* --- Missions (le geste du jour) --- */
.missions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}
.mission {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .15s;
}
.mission:hover { border-color: var(--red); background: var(--surface); transform: translateY(-1px); }
.mission-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--red-tint);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.mission-icon .icon { width: 18px; height: 18px; }
.mission-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: block;
  letter-spacing: -.01em;
  margin-bottom: 2px;
}
.mission-hint { font-size: 12px; color: var(--faint); display: block; line-height: 1.4; }
.mission-arrow { margin-left: auto; color: var(--faint); font-size: 16px; flex: none; transition: color .15s, transform .15s; }
.mission:hover .mission-arrow { color: var(--red); transform: translateX(2px); }

/* --- Intro d'agent (page outil) --- */
.agent-intro {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.agent-intro p { margin: 0 0 12px; font-size: 14px; color: #d4d4d4; line-height: 1.6; }
.agent-intro-meta { display: flex; gap: 18px; flex-wrap: wrap; }
.agent-intro-meta span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--faint);
}
.agent-intro-meta b { color: var(--ink); font-weight: 600; }

/* --- Tuiles données vivantes --- */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  text-decoration: none;
  display: block;
  transition: border-color .15s, transform .15s;
}
.stat-tile:hover { border-color: var(--red); transform: translateY(-2px); }
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.stat-label .icon { width: 14px; height: 14px; color: var(--red); }
.stat-value {
  font-size: 42px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-hint { font-size: 11.5px; color: var(--faint); margin-top: 10px; }
.stat-tile:hover .stat-hint { color: var(--muted); }

/* --- Deck des agents de service --- */
.agents-deck {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.agent-tile {
  grid-column: span 3;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  position: relative;
}
.agent-tile.featured { grid-column: span 3; background: linear-gradient(150deg, #181212 0%, var(--surface) 55%); }
.agent-tile:hover {
  border-color: var(--red);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(225,6,0,.10);
}
.agent-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.agent-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  background: var(--red-tint);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
}
.agent-icon .icon { width: 20px; height: 20px; }
.agent-ref {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: #575757;
}
.agent-name {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 6px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.agent-tile.featured .agent-name { font-size: 19px; }
.agent-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 16px;
  flex: 1;
}
.agent-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 10px; }
.agent-tag {
  white-space: nowrap;
  font-size: 9.5px;
  background: #1f1f1f;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.agent-tag .icon { width: 11px; height: 11px; }
.agent-tag.cron { background: var(--warn-bg); color: var(--warn); }
.agent-tag.live { background: var(--ok-bg); color: var(--ok); }
.btn-run {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-run:hover { background: var(--red-hover); }
.btn-run:active { transform: scale(.97); }

/* --- Registre (en préparation) --- */
.registry { border-top: 1px solid var(--line); }
.registry-row {
  display: grid;
  grid-template-columns: 74px 200px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.registry-row .agent-ref { font-size: 10px; }
.registry-name {
  font-size: 12px;
  font-weight: 700;
  color: #b8b8b8;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.registry-desc { font-size: 12.5px; color: var(--faint); line-height: 1.45; }
.registry-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #575757;
  border: 1px solid var(--line-strong);
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* --- Historique --- */
.runs-list { display: grid; gap: 8px; }
.run-item {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.run-item .run-status { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.run-item .run-status.error { background: #ef4444; }
.run-item .run-status.running { background: var(--warn); animation: pulse 1s infinite; }
.run-item .run-name { font-weight: 700; color: #fff; }
.run-item .run-meta { color: var(--faint); font-size: 12px; }
.run-item .run-when { color: var(--faint); font-size: 11px; }
.run-empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--faint);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
@keyframes pulse { 50% { opacity: .4; } }

/* ===========================================================
   LOGIN
   =========================================================== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(225,6,0,.16) 0, transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(225,6,0,.09) 0, transparent 35%);
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 44px 40px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  position: relative;
  z-index: 1;
}
.login-tag { position: absolute; top: 16px; right: 18px; }
.login-header { text-align: center; margin-bottom: 30px; }
.login-lockup { height: 72px; width: auto; display: block; margin: 0 auto 16px; }
.login-header .agency {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
  text-transform: uppercase;
}
.login-header .agency::before { content: '// '; color: var(--red); }
#login-form label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}
#login-form input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 16px;
  outline: none;
  font-family: inherit;
  background: var(--bg);
  color: #fff;
  margin-bottom: 16px;
  transition: border-color .15s;
}
#login-form input:focus { border-color: var(--red); }
#login-form button {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: inherit;
  transition: background .15s, transform .1s;
}
#login-form button:hover { background: var(--red-hover); }
#login-form button:active { transform: scale(.98); }
#login-form button:disabled { background: #444; cursor: not-allowed; }
.error { color: var(--err); font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.login-footer {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.login-footer p { font-size: 11px; color: var(--faint); margin: 0; line-height: 1.6; }

/* ===========================================================
   HEADER HÉRITÉ (pages satellites) — devient toolbar sous rail
   =========================================================== */
.app-header {
  background: rgba(10,10,10,.92);
  border-bottom: 1px solid #1f1f1f;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(8px);
}
.header-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.header-lockup { height: 38px; width: auto; display: block; }
.header-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  white-space: nowrap;
}
body.with-rail .header-lockup { display: none; }
body.with-rail .header-title {
  font-size: 13px;
  color: #fff;
  font-weight: 800;
  border-left: none;
  padding-left: 0;
}
body.with-rail .header-title::before { content: '// '; color: var(--red); }
/* les liens de nav du header doublonnent le rail : on les masque */
body.with-rail .app-header .link-secondary { display: none; }
.header-nav, .header-user { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.link-secondary {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color .15s, background .15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.link-secondary:hover { background: #1a1a1a; color: #fff; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-ghost:hover { background: #1a1a1a; border-color: #444; color: #fff; }

/* ===========================================================
   PAGE AGENT
   =========================================================== */
.agent-page { max-width: 920px; margin: 0 auto; padding: 40px 36px 60px; }
.agent-header-page { margin-bottom: 26px; }
.agent-breadcrumb {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 12px;
}
.agent-breadcrumb a { color: var(--faint); text-decoration: none; }
.agent-breadcrumb a:hover { color: #fff; }
.agent-title-page {
  font-size: 32px;
  font-weight: 900;
  margin: 0;
  letter-spacing: -.03em;
  color: #fff;
  text-wrap: balance;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 24px;
}
.form-row { display: grid; gap: 8px; margin-bottom: 18px; }
.form-row label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.form-row input, .form-row select, .form-row textarea {
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  color: #fff;
  transition: border-color .15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--red); }
.form-row .help { font-size: 11px; color: var(--faint); }
.form-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn-primary, .btn-secondary {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  font-family: inherit;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { background: #2a2a2a; color: #555; cursor: not-allowed; }
.btn-secondary { background: #1f1f1f; color: #fff; border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: #2a2a2a; border-color: #444; }
.results-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
}
.results-card[hidden] { display: none; }

/* Lead cards (résultats veille) */
.lead-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color .15s, background .15s;
}
.lead-card:hover { border-color: var(--line-strong); }
.lead-card.score-high { border-color: #3d1512; background: var(--red-tint); }
.lead-card .lead-name {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 6px;
  color: #fff;
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lead-card .lead-score {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 3px;
  background: #1f1f1f;
  color: var(--muted);
  text-transform: uppercase;
}
.lead-card.score-high .lead-score { background: var(--red); color: #fff; }
.lead-card.score-mid .lead-score { background: var(--warn-bg); color: var(--warn); }
.lead-card .lead-meta { font-size: 12px; color: var(--muted); line-height: 1.55; }
.lead-card .lead-meta b { color: #fff; }
.lead-card .lead-meta code {
  background: #1a1a1a; color: #ccc;
  padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-family: var(--mono);
}
.lead-card .lead-action {
  font-size: 12.5px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: #ddd;
}
.lead-grid { display: grid; gap: 10px; }
.lead-buttons { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-handoff {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-decoration: none;
  display: inline-block;
  transition: background .15s, transform .1s;
}
.btn-handoff:hover { background: var(--red-hover); }
.btn-handoff:active { transform: scale(.97); }
.btn-handoff.secondary { background: #1f1f1f; border: 1px solid var(--line-strong); color: #ccc; }
.btn-handoff.secondary:hover { background: #2a2a2a; color: #fff; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-strong);
}
.pagination button {
  background: #1f1f1f;
  border: 1px solid var(--line-strong);
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background .15s, border-color .15s;
}
.pagination button:hover:not(:disabled) { background: #2a2a2a; border-color: #444; }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }
.pagination .page-info { color: var(--faint); font-size: 12px; font-weight: 600; letter-spacing: .5px; }

.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: #444; background: var(--surface); }
.dropzone.dz-over { border-color: var(--red); background: var(--red-tint); }
.dropzone .dz-prompt { color: var(--faint); font-size: 14px; line-height: 1.5; }
.dropzone .dz-selected { color: var(--ok); font-size: 13px; line-height: 1.5; }

.fiche-section { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid #1f1f1f; }
.fiche-section:last-child { border-bottom: none; }
.fiche-section h3 {
  font-size: 11px;
  font-weight: 800;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 10px;
}
.fiche-section h3::before { content: '// '; color: var(--red); }
.fiche-section p { color: #ccc; font-size: 13.5px; line-height: 1.65; margin: 0; }
.fiche-section b { color: #fff; }
.fiche-section code {
  background: #1a1a1a; color: #ccc;
  padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-family: var(--mono);
}
.script-block {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: #ddd;
}

/* ===========================================================
   MODAL
   =========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 14px; font-weight: 800; color: #fff; text-transform: uppercase; letter-spacing: 1px; }
.modal-close { background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--faint); padding: 0 8px; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  color: #ccc;
  border-radius: var(--radius);
  padding: 14px;
  max-height: 400px;
  overflow-y: auto;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line-strong);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.loader { text-align: center; padding: 30px; }
.loader p { color: var(--faint); font-size: 13px; margin: 14px 0 0; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--red);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Entrée en scène discrète des tuiles */
@media (prefers-reduced-motion: no-preference) {
  .stat-tile, .agent-tile { animation: rise .35s cubic-bezier(.16,1,.3,1) backwards; }
  .agents-deck .agent-tile:nth-child(2) { animation-delay: .04s; }
  .agents-deck .agent-tile:nth-child(3) { animation-delay: .08s; }
  .agents-deck .agent-tile:nth-child(4) { animation-delay: .12s; }
  .agents-deck .agent-tile:nth-child(5) { animation-delay: .16s; }
  .stat-tiles .stat-tile:nth-child(2) { animation-delay: .04s; }
  .stat-tiles .stat-tile:nth-child(3) { animation-delay: .08s; }
  .stat-tiles .stat-tile:nth-child(4) { animation-delay: .12s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ===========================================================
   REDUCED MOTION / RESPONSIVE
   =========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 1100px) {
  .agents-deck { grid-template-columns: repeat(2, 1fr); }
  .agent-tile, .agent-tile.featured { grid-column: span 1; }
}

/* barre mobile + backdrop : masqués en desktop, activés dans le média mobile ci-dessous */
.rail-mobilebar, .rail-backdrop { display: none; }

@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  body.with-rail { padding-left: 0; padding-top: 54px; }
  body.rail-open { overflow: hidden; }

  /* barre mobile fixe (hamburger + logo) */
  .rail-mobilebar { display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; height: 54px; z-index: 71; background: var(--rail-bg); border-bottom: 1px solid #1c1c1c; padding: 0 12px; }
  .rail-burger { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border-radius: 9px; background: #141414; border: 1px solid #262626; color: #fff; cursor: pointer; flex: none; }
  .rail-burger svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
  .rail-mobilebar a { display: inline-flex; align-items: center; }
  .rail-mobilebar img { height: 26px; width: auto; display: block; }

  /* le rail devient un tiroir hors-écran qui glisse */
  .rail { transform: translateX(-100%); transition: transform .22s ease; width: 272px; z-index: 73; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  body.rail-open .rail { transform: none; }
  .rail-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 72; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.rail-open .rail-backdrop { opacity: 1; pointer-events: auto; }

  /* garde-fou anti-débordement horizontal sur mobile */
  html, body { max-width: 100%; overflow-x: hidden; }

  /* contenu (règles existantes conservées) */
  .cockpit { padding: 24px 16px 40px; }
  .cockpit-head h1 { font-size: 30px; }
  .data-strip { gap: 22px; margin-bottom: 32px; }
  .data-strip b { font-size: 18px; }
  .agents-deck { grid-template-columns: 1fr; }
  .registry-row { grid-template-columns: 56px 1fr auto; }
  .registry-desc { display: none; }
  .agent-page { padding: 24px 16px 40px; }
  .form-cols-2 { grid-template-columns: 1fr; }
  .agent-title-page { font-size: 22px; }
}

/* En-tête cockpit : s'empile sur mobile (sinon titre + tag-tech se chevauchent) — systémique */
@media (max-width: 640px) {
  .cockpit-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cockpit-head .tag-tech { align-self: flex-start; }
  /* champs ≥16px sur mobile : empêche le zoom auto d'iOS au focus (ui-ux-pro-max: readable-font-size) */
  input, select, textarea { font-size: 16px !important; }
}

/* Doublons masqués quand le rail est présent */
body.with-rail .app-header #logout-btn { display: none; }

/* ===========================================================
   POLISH LAYER v2 (ui-ux-pro-max) — raffinements globaux additifs.
   Aucune modif de layout : profondeur, motion, lisibilité, ambiance.
   =========================================================== */

/* Rendu de texte plus net + chiffres alignés (data app) */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  /* Ambiance : halo rouge très subtil en haut + fond grillagé conservé */
  background-image:
    radial-gradient(1100px 460px at 78% -8%, rgba(225,6,0,.07), transparent 68%),
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-attachment: fixed, scroll, scroll;
}

/* Sélection de texte aux couleurs de la marque */
::selection { background: rgba(225,6,0,.32); color: #fff; }

/* Scrollbars fines et sombres (gros gain de qualité perçue) */
* { scrollbar-width: thin; scrollbar-color: #2c2c2c transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2c2c2c;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #3d3d3d; background-clip: content-box; }

/* CTA rouges : léger reflet haut + ombre de marque + easing unifié */
.btn-primary, .btn-run, .btn-handoff:not(.secondary), .btn-load, .btn-red {
  box-shadow: var(--edge-light), var(--shadow-red);
  transition: background .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease);
}
.btn-primary:hover:not(:disabled), .btn-run:hover, .btn-handoff:not(.secondary):hover, .btn-load:hover:not(:disabled), .btn-red:hover {
  box-shadow: var(--edge-light), 0 10px 30px rgba(225,6,0,.34);
}
.btn-primary:disabled, .btn-load:disabled { box-shadow: none; }

/* Boutons secondaires / fantômes : easing cohérent */
.btn-secondary, .btn-ghost, .btn-handoff.secondary { transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease); }

/* Rail : lien actif souligné d'un liseré rouge + transition douce */
.rail a, .rail-link, .nav-link { transition: background .18s var(--ease), color .18s var(--ease); }

/* Respect de prefers-reduced-motion (accessibilité) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
