/* Tableau de bord Ship It Green — prospection.
   Interface d'outil : scannée et opérée, pas lue. La hiérarchie sert la lecture
   rapide (ce qui demande une action ressort), pas la décoration. */

:root {
  --pine: #1E4B37;
  --pine-deep: #123626;
  --pine-light: #2E6B4F;
  --mint: #6FC7A0;
  --mint-soft: #E4F3EA;
  --cream: #F6F2E9;
  --cream-2: #EFE9DA;
  --paper: #FFFFFF;
  --ink: #1A2820;
  --ink-soft: #4A574F;
  --ink-faint: #7C8880;
  --line: #DCD4C1;
  --line-soft: #EAE4D6;

  /* Couleurs sémantiques — distinctes de l'accent, jamais décoratives */
  --ok: #2E7D52;
  --ok-soft: #E3F2E9;
  --warn: #B9803F;
  --warn-soft: #FAF0DF;
  --crit: #A63D2E;
  --crit-soft: #FBE9E5;
  --info: #2F6690;
  --info-soft: #E6EFF6;

  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(18, 54, 38, .08);
  --sidebar-w: 270px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pine: #8FD8B4; --pine-deep: #C8ECD6; --pine-light: #6FC7A0;
    --mint: #6FC7A0; --mint-soft: #1F3529;
    --cream: #141A16; --cream-2: #1B231E; --paper: #1E2822;
    --ink: #ECEFE9; --ink-soft: #B4BEB6; --ink-faint: #8A948C;
    --line: #2E3A32; --line-soft: #273129;
    --ok: #6FC7A0; --ok-soft: #1F3529;
    --warn: #DFA867; --warn-soft: #33281A;
    --crit: #E8927F; --crit-soft: #3A211B;
    --info: #7FB2D8; --info-soft: #1C2A36;
  }
}

* { box-sizing: border-box; }

/* L'attribut `hidden` doit gagner sur nos règles de classe.
   La règle par défaut du navigateur ([hidden] { display: none }) est écrasée par
   toute règle de classe qui pose un display — `.app { display: flex }` par
   exemple. Sans ce !important, masquer un élément par JS n'a aucun effet visible :
   le code s'exécute correctement, mais l'écran ne change pas. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Connexion ─────────────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-box h1 { font-size: 19px; margin: 0 0 6px; color: var(--pine-deep); }
.login-box .sub { color: var(--ink-faint); font-size: 13px; margin: 0 0 24px; }

/* ── Ossature ──────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--cream-2);
  border-right: 1px solid var(--line);
  padding: 20px 18px 40px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}
.main { flex: 1; padding: 22px 28px 60px; min-width: 0; max-width: 1500px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 21px; margin: 0; color: var(--pine-deep); font-weight: 650; }
.topbar .date { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--ink-soft);
}

/* Onglets */
.tabs {
  display: flex; gap: 2px; margin: 18px 0 22px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  padding: 9px 16px;
  border: none;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--pine); font-weight: 600; border-bottom-color: var(--pine);
}
.tab .badge { margin-left: 6px; }

/* ── Bandeau KPI ───────────────────────────────────────────────────── */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label {
  font-size: 11.5px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px;
}
.kpi .value {
  font-size: 24px; font-weight: 600; color: var(--pine-deep);
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi .hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }
.kpi.crit .value { color: var(--crit); }
.kpi.warn .value { color: var(--warn); }

/* Accès rapides */
.quick-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.quick {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  background: var(--paper);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
  display: flex; align-items: center; gap: 9px;
  transition: border-color .12s, transform .06s;
}
.quick:hover { border-color: var(--pine); }
.quick:active { transform: translateY(1px); }
.quick .n { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.quick.curieux { background: #FDF6E3; }
.quick.interesse { background: #FBEDDD; }
.quick.chaud { background: #FBE9E5; }
.quick.muet { background: var(--cream-2); }
@media (prefers-color-scheme: dark) {
  .quick.curieux { background: #33301A; }
  .quick.interesse { background: #33281A; }
  .quick.chaud { background: #3A211B; }
}

/* ── Cartes & sections ─────────────────────────────────────────────── */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card > h2 {
  font-size: 15px; margin: 0 0 14px; color: var(--pine-deep);
  display: flex; align-items: center; gap: 8px;
}
.card > h2 .sub { font-weight: 400; color: var(--ink-faint); font-size: 12.5px; }

details.section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
details.section > summary {
  padding: 13px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--pine-deep);
  list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before {
  content: "▸"; color: var(--ink-faint); transition: transform .15s;
}
details.section[open] > summary::before { transform: rotate(90deg); }
details.section > .body { padding: 0 18px 18px; }

/* ── Formulaires ───────────────────────────────────────────────────── */

label.field { display: block; margin-bottom: 13px; }
label.field > span {
  display: block; font-size: 12px; color: var(--ink-soft);
  margin-bottom: 4px; font-weight: 500;
}
input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 1px;
}
select[multiple] { min-height: 84px; padding: 4px; }
input[type=range] { width: 100%; accent-color: var(--pine); }

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn:hover:not(:disabled) { border-color: var(--pine); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--pine); color: #fff; border-color: var(--pine); font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--pine-light); }
@media (prefers-color-scheme: dark) { .btn-primary { color: var(--pine-deep); } }
.btn-danger { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Tableau ───────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--paper); }
thead th {
  background: var(--cream-2);
  text-align: left;
  padding: 9px 12px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
  position: sticky; top: 0;
}
tbody td { padding: 9px 12px; border-top: 1px solid var(--line-soft); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--cream-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.truncate { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Pastilles d'état ──────────────────────────────────────────────── */

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: var(--cream-2); color: var(--ink-faint); }

.score {
  font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 1px 7px; border-radius: 4px;
}
.score.high { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.low { background: var(--cream-2); color: var(--ink-faint); }

/* ── Bandeaux d'alerte ─────────────────────────────────────────────── */

.banner {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  border-left: 4px solid;
  font-size: 13.5px;
}
.banner h3 { margin: 0 0 5px; font-size: 14px; }
.banner p { margin: 0; }
.banner.crit { background: var(--crit-soft); border-color: var(--crit); color: var(--crit); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.banner.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.banner.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.banner.crit h3, .banner.warn h3, .banner.ok h3, .banner.info h3 { color: inherit; }

/* ── Fiche prospect (panneau latéral) ──────────────────────────────── */

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(18, 40, 32, .42);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(680px, 96vw);
  background: var(--cream);
  border-left: 1px solid var(--line);
  z-index: 41;
  overflow-y: auto;
  padding: 22px 24px 60px;
  box-shadow: -4px 0 24px rgba(18, 54, 38, .12);
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 4px;
}
.drawer-head h2 { margin: 0; font-size: 18px; color: var(--pine-deep); }
.drawer-head .meta { color: var(--ink-faint); font-size: 12.5px; margin-top: 2px; }
.close-x {
  border: none; background: none; font-size: 22px; cursor: pointer;
  color: var(--ink-faint); line-height: 1; padding: 2px 6px;
}
.close-x:hover { color: var(--ink); }

/* Conversation */
.msg {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 9px;
  background: var(--paper);
}
.msg.in { background: var(--mint-soft); border-color: transparent; }
.msg-head {
  display: flex; gap: 8px; align-items: center;
  font-size: 11.5px; color: var(--ink-faint); margin-bottom: 6px;
  flex-wrap: wrap;
}
.msg-body { white-space: pre-wrap; font-size: 13px; line-height: 1.6; }
.msg .subject { font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--ink); }

/* ── Graphiques ────────────────────────────────────────────────────── */

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { background: var(--cream-2); border-radius: 3px; height: 17px; overflow: hidden; }
.bar-fill { background: var(--pine); height: 100%; border-radius: 3px; min-width: 2px; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.crit { background: var(--crit); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.bar-label { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tunnel */
.funnel-step {
  display: grid; grid-template-columns: 180px 1fr 60px 70px;
  gap: 10px; align-items: center; padding: 5px 0; font-size: 13px;
}
.funnel-bar { background: var(--cream-2); border-radius: 3px; height: 22px; overflow: hidden; }
.funnel-fill {
  background: linear-gradient(90deg, var(--pine), var(--pine-light));
  height: 100%; min-width: 2px;
}

/* ── Divers ────────────────────────────────────────────────────────── */

.muted { color: var(--ink-faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.empty {
  text-align: center; padding: 40px 20px; color: var(--ink-faint); font-size: 13.5px;
}
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--line); border-top-color: var(--pine);
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--pine-deep); color: #fff;
  padding: 11px 20px; border-radius: 8px; z-index: 60;
  font-size: 13.5px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  max-width: 90vw;
}
.toast.err { background: var(--crit); }
@media (prefers-color-scheme: dark) { .toast { color: var(--pine-deep); background: var(--mint); } }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; }

.sidebar h3 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); margin: 0 0 12px;
}
.sidebar .reset { width: 100%; margin-top: 6px; }

.remediation { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.remediation li {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 6px; padding: 11px 13px; list-style: none;
}
.remediation .t { font-weight: 600; font-size: 13px; margin-bottom: 3px; color: var(--ink); }
.remediation .d { font-size: 12.5px; color: var(--ink-soft); }
.remediation .w { font-size: 12px; color: var(--pine); margin-top: 5px; font-style: italic; }
.remediation ol { margin: 0; padding: 0; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
  .main { padding: 18px 16px 50px; }
}
