/* Flair — direction visuelle des maquettes : encre, papier, orange Flair, go vert, no-go bordeaux. */
:root {
  --ink: #121417;
  --ink-2: #2a2d33;
  --muted: #565b66;
  --faint: #8a8f99;
  --paper: #faf9f5;
  --card: #ffffff;
  --line: #ecece8;
  --line-2: #e2e2de;
  --flair: #c2410c;
  --flair-bg: #fcede6;
  --go: #146c43;
  --go-bg: #e3f1e9;
  --nogo: #8f1d2c;
  --nogo-bg: #f8e5e8;
  --dig: #7a4f00;
  --dig-bg: #fbf1da;
  --radius: 14px;
  --font: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --display: "Bricolage Grotesque", var(--font);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 40px; line-height: 1.05; font-weight: 700; }
h2 { font-size: 13px; font-family: var(--font); font-weight: 600; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; }
h3 { font-size: 18px; }
p { margin: 0 0 .6em; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* --- Cadre ---------------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #e9e9e4; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { font-family: var(--display); font-weight: 800; font-size: 24px; color: #fff; padding: 0 10px 18px; letter-spacing: -0.04em; text-decoration: none; }
.logo { display: inline-flex; align-items: baseline; gap: 3px; }
.logo .dot { width: 8px; height: 8px; border-radius: 50%; background: #e8703f; display: inline-block; }
.mobile-logo { color: var(--ink); padding: 0 0 14px; font-size: 26px; width: max-content; }
.mobile-logo.mobile-only { display: flex; }
.side a.nav { display: block; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: #c9cbd0; font-size: 14.5px; }
.side a.nav:hover { background: #1f2227; color: #fff; }
.side a.nav.on { background: #2a2d33; color: #fff; font-weight: 600; }
.side .grow { flex: 1; }
.side form select { width: 100%; background: #1f2227; color: #fff; border: 1px solid #3e424b; border-radius: 8px; padding: 7px; font: inherit; font-size: 13px; }
.side .who { font-size: 12.5px; color: #8a8f99; padding: 8px 10px; }
.main { padding: 28px 36px 80px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.crumb { color: var(--flair); font-size: 13.5px; text-decoration: none; display: inline-block; margin-bottom: 8px; }
.bottom-nav { display: none; }

/* --- Composants ---------------------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: 600 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c9c9c3; }
.btn.primary { background: var(--go); border-color: var(--go); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.flair { background: var(--flair); border-color: var(--flair); color: #fff; }
.btn.danger { color: var(--nogo); border-color: #f3a6b0; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; font: inherit; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f3c4ad; border-color: var(--flair); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field + .field { margin-top: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--ink); font-size: 14px; }
.check input { margin-top: 3px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #f1f1ed; color: var(--muted); white-space: nowrap; }
.pill.go { background: var(--go-bg); color: var(--go); }
.pill.nogo { background: var(--nogo-bg); color: var(--nogo); }
.pill.dig { background: var(--dig-bg); color: var(--dig); }
.pill.flair { background: var(--flair-bg); color: var(--flair); }
.pill.muted { background: #f1f1ed; color: var(--faint); }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: var(--go-bg); color: var(--go); }
.flash.err { background: var(--nogo-bg); color: var(--nogo); }
.notice { background: var(--dig-bg); color: var(--dig); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.notice.flair { background: var(--flair-bg); color: #9a3412; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data th a { text-decoration: none; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #fcfcfa; }
.table-wrap { overflow-x: auto; }

.stat { font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1; }
.tabs { display: inline-flex; background: #f1f1ed; border-radius: 10px; padding: 3px; gap: 2px; }
.tabs a { padding: 5px 12px; border-radius: 8px; text-decoration: none; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* --- Fiche prospect ------------------------------------------------------------------------- */
.fiche-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; margin-bottom: 22px; }
.fiche-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, .9fr); gap: 14px; align-items: start; }
.pipeline { display: flex; align-items: center; gap: 0; margin-top: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pipeline .step { display: flex; align-items: center; gap: 6px; padding-right: 10px; }
.pipeline .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #c9cbd0; background: #fff; }
.pipeline .step.done .dot { background: var(--ink); border-color: var(--ink); }
.pipeline .step.now .dot { background: var(--flair); border-color: var(--flair); }
.pipeline .step.now { color: var(--flair); font-weight: 600; }
.pipeline .bar { width: 22px; height: 2px; background: #c9cbd0; margin-right: 10px; }

.switch { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; background: var(--ink); border-radius: 999px; padding: 6px; min-width: 380px; gap: 6px; }
.switch form { margin: 0; display: contents; }
.switch button { border: 0; border-radius: 999px; padding: 14px 22px; font: 700 18px var(--display); cursor: pointer; letter-spacing: .02em; }
.switch .nogo { background: #2a1418; color: #f3a6b0; text-align: left; }
.switch .nogo.on, .switch .nogo:hover { background: var(--nogo); color: #fff; }
.switch .dig { background: #2a2d33; color: #f7d58a; font-size: 13px; padding: 8px 14px; }
.switch .dig.on, .switch .dig:hover { background: var(--dig); color: #fff; }
.switch .go { background: #173a2a; color: #9fd8b8; text-align: right; }
.switch .go.on, .switch .go:hover { background: var(--go); color: #fff; }
.switch-hint form, form.switch-hint { margin: 6px 0 0; }
.switch-hint { text-align: right; font-size: 13px; color: var(--muted); margin-top: 6px; }

.facts { list-style: none; padding: 0; margin: 10px 0; font-size: 14px; }
.facts li { display: flex; gap: 8px; padding: 4px 0; }
.facts li .mark { color: var(--go); font-weight: 700; }
.facts li .mark.warn { color: var(--nogo); }
.ref { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px; background: #f1f1ed; font: 600 11px var(--mono); color: var(--muted); text-decoration: none; vertical-align: 1px; }
.angle { background: var(--flair-bg); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.angle b { color: var(--flair); display: block; font-size: 12.5px; margin-bottom: 3px; }
.sources { font-size: 12px; color: var(--muted); margin-top: 12px; }
.sources a { color: var(--muted); }

.draft-text { font-size: 14.5px; white-space: pre-wrap; }
.draft textarea { min-height: 260px; font-size: 14.5px; }
.draft .subject { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.draft .footer-preview { margin-top: 10px; font-size: 12.5px; color: var(--faint); white-space: pre-wrap; border-top: 1px dashed var(--line-2); padding-top: 8px; }
.alert-list { list-style: none; padding: 0; margin: 10px 0 0; }
.alert-list li { font-size: 13px; color: var(--dig); background: var(--dig-bg); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.timeline li { display: grid; grid-template-columns: 50px 1fr; gap: 10px; padding: 6px 0; }
.timeline .when { color: var(--muted); font-size: 13px; }

.working { display: flex; align-items: center; gap: 10px; background: var(--flair-bg); color: #9a3412; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #f3c4ad; border-top-color: var(--flair); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Prospects --------------------------------------------------------------------------------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line-2); text-decoration: none; font-size: 13.5px; }
.filters a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cards { display: none; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; display: block; }
.pcard + .pcard { margin-top: 10px; }

.express { display: flex; gap: 8px; }
.express input { font-size: 16px; padding: 12px 14px; }
.express-card { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.candidates .cand { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: #fff; }

.triage-card { max-width: 560px; margin: 0 auto; }

/* --- Tableau de bord et matrice (V2) ------------------------------------------------------------ */
.rate { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.rate .stat { margin: 6px 0 8px; }
.bars { display: grid; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 40px; align-items: center; gap: 12px; padding: 5px 6px; border-radius: 8px; text-decoration: none; }
.bar-row:hover { background: #f6f6f2; }
.bar-row .mono { text-align: right; }
.bar-track { height: 10px; border-radius: 999px; background: #f1f1ed; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--ink-2); }
.bar-fill.go { background: var(--go); }
.bar-fill.nogo { background: var(--nogo); }
.bar-fill.dig { background: #c98a12; }
.bar-fill.muted { background: var(--faint); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.zone-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--line-2); }
.z-premier { background: var(--flair-bg); }
.z-ensuite { background: #fbf6ec; }
.z-plus_tard { background: #f6f6f3; }
.matrix-card { margin-top: 14px; padding: 12px; }
table.matrix { width: 100%; border-collapse: separate; border-spacing: 6px; table-layout: fixed; min-width: 900px; }
table.matrix th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; text-align: left; padding: 4px 6px; }
table.matrix tbody th { width: 96px; vertical-align: top; padding-top: 12px; color: var(--ink); }
table.matrix th.corner { width: 96px; text-transform: none; letter-spacing: 0; color: var(--faint); font-weight: 500; }
table.matrix td { vertical-align: top; border-radius: 10px; padding: 8px; height: 110px; }
table.matrix td.z-premier { box-shadow: inset 0 0 0 1px #f3c4ad; }
.mitem { display: grid; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; text-decoration: none; font-size: 13.5px; }
.mitem + .mitem { margin-top: 6px; }
.mitem:hover { border-color: var(--line-2); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.mitem .pill { justify-self: start; margin-top: 2px; }
.zone-list { margin-top: 14px; }
.zone-list.z-premier { border-color: #f3c4ad; }

/* --- Pages publiques -------------------------------------------------------------------------- */
.public { max-width: 640px; margin: 60px auto; padding: 0 16px; }
.public .card { padding: 28px; }
.login { max-width: 400px; margin: 10vh auto; padding: 0 16px; }

/* --- Mobile d'abord pour le terrain ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .fiche-cols { grid-template-columns: 1fr 1fr; }
  .fiche-cols > :last-child { grid-column: 1 / -1; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 18px 16px 90px; }
  h1 { font-size: 30px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--ink); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
  .bottom-nav a { color: #c9cbd0; text-decoration: none; font-size: 11.5px; text-align: center; padding: 6px 2px; border-radius: 8px; }
  .bottom-nav a.on { color: #fff; background: #2a2d33; }
  .fiche-head { grid-template-columns: 1fr; }
  .switch { min-width: 0; }
  .switch button { padding: 12px 14px; font-size: 16px; }
  .fiche-cols, .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desktop-only { display: none !important; }
  .cards { display: block; }
  .express { flex-direction: column; }
  .bar-row { grid-template-columns: 118px 1fr 32px; gap: 8px; }
}
@media (min-width: 761px) { .mobile-only { display: none !important; } }
