/* ============================================================
   Portfolio Intel — feuille de style institutionnelle
   Fond sombre gris-bleu · un accent · vert/rouge réservés aux statuts
   ============================================================ */

:root {
  /* Palette de surface (gris-bleu sombre) */
  --bg-0: #0e131b;          /* fond application */
  --bg-1: #151c27;          /* panneaux */
  --bg-2: #1b2432;          /* surfaces levées / survol */
  --bg-3: #212c3d;          /* champs, entrées */
  --line: #2a3648;          /* bordures */
  --line-soft: #232e3f;     /* séparateurs internes */
  /* Texte */
  --txt-0: #e9eef7;         /* principal */
  --txt-1: #aab7cc;         /* secondaire */
  --txt-2: #94a3bb;         /* atténué, contraste AA sur les surfaces sombres */
  /* Accent unique (bleu institutionnel) */
  --accent: #5aa2ff;
  --accent-strong: #3d87f0;
  --accent-soft: rgba(90, 162, 255, 0.14);
  --accent-border: rgba(90, 162, 255, 0.35);
  /* Statuts (réservés) */
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.13);
  --ok-border: rgba(62, 207, 142, 0.4);
  --err: #ff6b6b;
  --err-soft: rgba(255, 107, 107, 0.12);
  --err-border: rgba(255, 107, 107, 0.4);
  --warn: #e8b341;
  --warn-soft: rgba(232, 179, 65, 0.13);
  --warn-border: rgba(232, 179, 65, 0.4);
  /* Typographie & rythme */
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SF Mono", ui-monospace, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 19px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 14px 40px rgba(0, 0, 0, 0.5);
  --sidebar-w: 232px;
  --topbar-h: 58px;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--txt-0);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(90, 162, 255, 0.05), transparent 60%),
    var(--bg-0);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.noscript { margin: 2rem; color: var(--err); }

::selection { background: var(--accent-soft); }

/* Chiffres tabulaires partout où c'est numérique */
.num, .kpi-value, td.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: var(--fs-sm); }

a { color: var(--accent); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

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

/* Barres de défilement discrètes */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c3a50; border-radius: 6px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-track { background: transparent; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Structure applicative ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  min-width: 1280px;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #121925, #101622);
  border-right: 1px solid var(--line);
  padding: 18px 12px 14px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 8px 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
.brand-mark {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  padding: 6px;
  display: inline-flex;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14px; letter-spacing: 0.01em; }
.brand-text small { color: var(--txt-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--txt-1);
  text-decoration: none;
  font-size: var(--fs-md);
  font-weight: 500;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: var(--bg-2); color: var(--txt-0); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--txt-0);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
  background: var(--accent);
}
.nav-item.active svg { color: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}

.health {
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 0 6px;
  color: var(--txt-2); font-size: var(--fs-xs);
}
.health .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--txt-2);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}
.health.ok { color: var(--ok); }
.health.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.health.ko { color: var(--err); }
.health.ko .dot { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }

/* Zone principale */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 19, 27, 0.72);
  backdrop-filter: blur(6px);
}

.view-title { font-size: 16px; font-weight: 600; letter-spacing: 0.01em; }

.topbar-actions { display: flex; align-items: flex-end; gap: 14px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 40px;
}

.view { display: flex; flex-direction: column; gap: 18px; max-width: 1560px; }
.view[hidden] { display: none; }

/* ---------- Panneaux ---------- */

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  min-width: 0;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--txt-1);
}
.panel-tools { display: flex; align-items: center; gap: 10px; }

.panel-body { padding: 16px 18px; }
.panel-body.no-pad { padding: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.count-chip {
  font-size: var(--fs-xs);
  color: var(--txt-1);
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 2px 9px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Formulaires ---------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label {
  font-size: var(--xs, var(--fs-xs));
  color: var(--txt-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field.inline { flex-direction: column; }
.inline .field-label { margin-bottom: 0; }
.grow { flex: 1; }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--txt-0);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color 0.12s, background 0.12s;
}
input:hover, select:hover, textarea:hover { border-color: #35455e; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #1a2333;
}
input::placeholder, textarea::placeholder { color: var(--txt-2); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 44px; }

#portfolio-select { min-width: 230px; }
#actor-input { width: 170px; }

.form-row { display: flex; gap: 10px; align-items: center; }

.form-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.submit-cell { justify-content: flex-end; }

.toolbar {
  display: flex; align-items: flex-end; gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.check-inline {
  display: flex; align-items: center; gap: 7px;
  color: var(--txt-1); font-size: var(--fs-sm);
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

.hint { color: var(--txt-2); font-size: var(--fs-sm); margin: 8px 0 0; }
.hint.tight { margin: 0; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: 600;
  color: #0b1220;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn.ghost {
  color: var(--txt-0);
  background: transparent;
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--bg-2); border-color: #3a4a63; }

.btn.danger {
  color: #ffb1b1;
  background: var(--err-soft);
  border-color: var(--err-border);
}
.btn.danger:hover { background: rgba(255, 107, 107, 0.2); }

.btn.ok {
  color: #9fe9c8;
  background: var(--ok-soft);
  border-color: var(--ok-border);
}
.btn.ok:hover { background: rgba(62, 207, 142, 0.2); }

.btn.sm { padding: 5px 11px; font-size: var(--fs-sm); }
.btn.icon { padding: 8px; }
.btn.icon svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(11, 18, 32, 0.35);
  border-top-color: #0b1220;
  animation: spin 0.7s linear infinite;
}
.btn.ghost.busy::after { border-color: rgba(233, 238, 247, 0.3); border-top-color: var(--txt-0); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges, chips, segments ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--txt-1);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-border); }
.badge.err { color: var(--err); background: var(--err-soft); border-color: var(--err-border); }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-border); }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs);
  color: var(--txt-1);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 10px;
  max-width: 340px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; stroke: var(--accent); stroke-width: 2; fill: none; flex: none; }

.segmented {
  display: inline-flex;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--txt-1);
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 5px 13px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.seg:hover { color: var(--txt-0); }
.seg.active { background: var(--accent-soft); color: var(--txt-0); box-shadow: inset 0 0 0 1px var(--accent-border); }

/* ---------- Tableaux ---------- */

.table-wrap { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}
.tbl th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt-2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(27, 36, 50, 0.45);
  white-space: nowrap;
}
.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--txt-0);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr:hover { background: rgba(27, 36, 50, 0.55); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }

.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl .sub { color: var(--txt-2); font-size: var(--fs-xs); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--txt-1); }
th.sortable::after { content: " ↕"; opacity: 0.45; font-size: 10px; }
th.sortable.sort-asc::after { content: " ↑"; opacity: 1; color: var(--accent); }
th.sortable.sort-desc::after { content: " ↓"; opacity: 1; color: var(--accent); }

.row-pass { box-shadow: inset 3px 0 0 var(--ok); }
.row-fail { box-shadow: inset 3px 0 0 var(--err); background: rgba(255, 107, 107, 0.045); }

.side-buy { color: var(--ok); font-weight: 600; }
.side-sell { color: var(--err); font-weight: 600; }

/* Pagination */
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding-top: 12px;
  color: var(--txt-2); font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.pager .btn { min-width: 34px; }

/* ---------- KPI ---------- */

.kpi-band {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px 12px;
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.kpi-label {
  font-size: var(--fs-xs);
  color: var(--txt-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 6px;
  line-height: 1.3;
  min-height: 2.6em; /* deux lignes : aucun libelle tronque ("Couverture notation") */
}
.kpi-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.kpi-sub { font-size: var(--fs-xs); color: var(--txt-2); margin-top: 4px; }
.kpi.accent { border-color: var(--accent-border); }
.kpi.accent .kpi-value { color: var(--accent); }

/* ---------- Graphiques ---------- */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}
.chart-panel { grid-column: span 4; }
.chart-panel:nth-child(4) { grid-column: span 6; }
.chart-panel:nth-child(5) { grid-column: span 6; }

.chart-box {
  position: relative;
  height: 225px;
  padding: 10px 14px 12px;
}
.chart-box.tall { height: 320px; }
.chart-fallback {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  color: var(--txt-2); font-size: var(--fs-sm);
}

/* ---------- États : squelettes, vides, erreurs, messages ---------- */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  min-height: 14px;
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(170, 183, 204, 0.09), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skeleton.kpi { height: 84px; border-radius: var(--radius); }
.skeleton.row { height: 38px; margin: 6px 18px; }
.skeleton.chart { height: 200px; margin: 12px; border-radius: var(--radius); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding: 44px 20px;
  color: var(--txt-2);
  text-align: center;
}
.empty-state svg { width: 34px; height: 34px; stroke: var(--txt-2); stroke-width: 1.4; fill: none; }
.empty-state p { margin: 0; max-width: 460px; }
.empty-state .btn { margin-top: 6px; }

.msg {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--txt-1);
  padding: 11px 14px;
  font-size: var(--fs-md);
}
.msg.err { border-color: var(--err-border); background: var(--err-soft); color: #ffc9c9; }
.msg.ok { border-color: var(--ok-border); background: var(--ok-soft); color: #a7ecd0; }
.msg.warn { border-color: var(--warn-border); background: var(--warn-soft); color: #f2d49a; }
.msg strong { color: inherit; }

.import-status { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.import-status .errors-table { margin-top: 4px; }

/* ---------- Dropzone ---------- */

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 1.5px dashed #3a4a63;
  border-radius: var(--radius);
  background: rgba(27, 36, 50, 0.35);
  padding: 26px 16px 22px;
  margin-bottom: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone svg { width: 26px; height: 26px; stroke: var(--txt-2); stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dropzone .dz-main { margin: 2px 0 0; font-weight: 600; color: var(--txt-0); }
.dropzone .hint { margin: 0; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.dragover { border-style: solid; }
.dropzone.disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
  width: 380px;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #1a2332;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  padding: 11px 13px;
  font-size: var(--fs-md);
  color: var(--txt-0);
  animation: toast-in 0.22s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast .toast-x {
      background: none; border: none; color: var(--txt-2);
  cursor: pointer; padding: 0 2px; font-size: 15px; line-height: 1;
}
.toast .toast-x:hover { color: var(--txt-0); }
@keyframes toast-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ---------- Modales ---------- */

.modal-root {
  position: fixed; inset: 0;
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 13, 0.66);
  backdrop-filter: blur(3px);
  padding: 24px;
}
.modal-root[hidden] { display: none; }
.modal {
  width: 520px;
  max-width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: var(--fs-lg); }
.modal-x { background: none; border: none; color: var(--txt-2); font-size: 19px; cursor: pointer; padding: 2px 6px; }
.modal-x:hover { color: var(--txt-0); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
}

/* ---------- Vue Dashboard ---------- */

.dash-headline {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.dash-headline h2 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; }
.dash-headline .meta { color: var(--txt-2); font-size: var(--fs-sm); }

/* ---------- Vue Mandat ---------- */

.results-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-1);
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: 14px;
}
.results-banner.ok { border-color: var(--ok-border); background: var(--ok-soft); color: var(--ok); }
.results-banner.err { border-color: var(--err-border); background: var(--err-soft); color: #ff9d9d; }
.results-banner .spacer { flex: 1; }

/* ---------- Vue Propositions ---------- */

.prop-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prop-title-row h3 { font-size: var(--fs-xl); }
.prop-kv { color: var(--txt-2); font-size: var(--fs-sm); display: flex; gap: 16px; flex-wrap: wrap; }
.prop-kv b { color: var(--txt-1); font-weight: 600; }

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare-col { padding: 0; }
.compare-col + .compare-col { border-left: 1px solid var(--line); }
.compare-col h4 {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--txt-2);
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-soft);
}
.compare-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-md);
}
.compare-row:last-child { border-bottom: none; }
.compare-row .lbl { color: var(--txt-2); }
.compare-row .val { font-variant-numeric: tabular-nums; font-weight: 500; }
.compare-row .delta-neg { color: var(--err); font-weight: 600; }
.compare-row .delta-pos { color: var(--ok); font-weight: 600; }

.solver-info {
  display: flex; flex-direction: column; gap: 6px;
  color: var(--txt-1); font-size: var(--fs-sm);
}
.solver-info code { color: var(--accent); font-family: var(--mono); }

.decision-note {
  border-left: 3px solid var(--line);
  padding: 4px 0 4px 12px;
  color: var(--txt-1);
}

/* ---------- Vue Marché ---------- */

.market-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  color: var(--txt-2); font-size: var(--fs-sm);
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}
.market-meta b { color: var(--txt-1); font-weight: 600; }

/* ---------- Vue Ask ---------- */

.chat-panel { display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h) - 84px); }
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-msg { display: flex; flex-direction: column; gap: 6px; max-width: 82%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg .bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: var(--fs-md);
  line-height: 1.55;
}
.chat-msg.user .bubble {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-top-right-radius: 4px;
  white-space: pre-wrap;
}
.chat-msg.assistant .bubble {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  overflow-wrap: anywhere;
}
.chat-msg .who { font-size: var(--fs-xs); color: var(--txt-2); padding: 0 4px; }
.chat-msg.error .bubble {
  background: var(--err-soft);
  border-color: var(--err-border);
  color: #ffc9c9;
}
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }

.chat-composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
}
.chat-composer textarea { flex: 1; }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--txt-2);
  animation: bounce 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Markdown rendu */
.md h3, .md h4, .md h5 { margin: 12px 0 6px; color: var(--txt-0); }
.md h3 { font-size: var(--fs-lg); }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code {
  font-family: var(--mono); font-size: var(--fs-sm);
  background: rgba(27, 36, 50, 0.9);
  border: 1px solid var(--line-soft);
  border-radius: 4px; padding: 1px 5px;
}
.md blockquote {
  margin: 8px 0; padding: 4px 12px;
  border-left: 3px solid var(--accent-border);
  color: var(--txt-1);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.md a { color: var(--accent); }
.md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md table { border-collapse: collapse; font-size: var(--fs-sm); }
.md th, .md td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.md th { background: var(--bg-2); color: var(--txt-1); }

/* ---------- Vue Audit ---------- */

.payload-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: var(--fs-xs);
  user-select: none;
  white-space: nowrap;
}
.payload-details pre {
  margin: 8px 0 2px;
  padding: 10px 12px;
  background: #10161f;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--txt-1);
  max-width: 640px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
}

.target-link {
  background: none; border: none; padding: 0;
  font-family: var(--mono); font-size: var(--fs-sm);
  color: var(--accent);
  cursor: pointer;
}
.target-link:hover { text-decoration: underline; }

/* ---------- Divers ---------- */

.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.inline-status { display: inline-flex; align-items: center; gap: 8px; color: var(--txt-1); }
.mt { margin-top: 14px; }
.muted { color: var(--txt-2); }
.nowrap { white-space: nowrap; }


/* ---------- UI-003 : editeur de mandat, scenarios, badges ---------- */
.modal.wide { width: min(980px, 96vw); }
.mandate-editor { display: flex; flex-direction: column; gap: 12px; }
.mandate-rows { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; padding-right: 4px; }
.mandate-row { display: grid; grid-template-columns: 28px 200px 1fr 200px auto; gap: 8px; align-items: start;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
.mandate-row .mr-index { color: var(--txt-2); font-size: 12px; padding-top: 8px; }
.mandate-row .mr-params { display: flex; flex-wrap: wrap; gap: 8px; }
.mandate-row .mr-params .field.inline { min-width: 140px; }
.mandate-row .mr-params input, .mandate-row .mr-params select { width: 100%; }
.scen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .scen-grid { grid-template-columns: 1fr; } .mandate-row { grid-template-columns: 28px 1fr; } }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-inline.block { display: flex; gap: 8px; align-items: flex-start; }
.scen-tenors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.scen-tenors .field.inline input { width: 90px; }
.notes { margin: 12px 0 0; padding-left: 18px; color: var(--txt-2); font-size: 12.5px; }
.notes li { margin-bottom: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable.selected td { background: var(--accent-soft); }
.badge.sm { font-size: 10px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.kpi.warn { border-color: var(--warn-border); }
.kpi.warn .kpi-value { color: var(--warn); }

[hidden] { display: none !important; }

.sent-heads li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sent-heads a { color: var(--txt-0); text-decoration: none; }
.sent-heads a:hover { text-decoration: underline; }
tr.sent-detail td { background: var(--bg-2); }

.cmp-grid { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
#committee-print { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body.print-mode > * { display: none !important; }
  body.print-mode > #committee-print { display: block !important; }
  body.print-mode { background: white; color: black; height: auto; }
  #committee-print { font: 10pt/1.4 Arial, sans-serif; }
  #committee-print * {
    color: black !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    max-height: none !important;
  }
  #committee-print h1 { font-size: 18pt; margin-bottom: 10pt; }
  #committee-print h2, #committee-print h3, #committee-print h4 { break-after: avoid; }
  #committee-print .panel, #committee-print .compare-grid { border: 0; }
  #committee-print .panel-head, #committee-print .panel-body { padding: 8pt 0; }
  #committee-print .compare-grid { display: block; }
  #committee-print .compare-col + .compare-col { border: 0; }
  #committee-print table { width: 100%; table-layout: fixed; }
  #committee-print thead { display: table-header-group; }
  #committee-print tr { break-inside: avoid; }
  #committee-print th, #committee-print td {
    padding: 5pt;
    border-bottom: 1px solid #999;
    white-space: normal !important;
    overflow-wrap: anywhere;
    font-size: 9pt;
  }
  #committee-print .badge { border: 1px solid #777; }
}
@media (max-width: 1100px) { .cmp-grid { grid-template-columns: 1fr; } }


/* ---- Composition d'un livre ---- */
.blend-row { display: grid; grid-template-columns: 1fr 120px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.blend-row select, .blend-row input { width: 100%; }

/* ---- Provenance des donnees (dashboard) ---- */
.quality-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.quality-item { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.quality-item .q-label { font-size: 12px; color: var(--txt-2); display: flex; justify-content: space-between; gap: 8px; }
.quality-item .q-bar { height: 6px; border-radius: 3px; background: var(--bg-3); margin: 8px 0 6px; overflow: hidden; }
.quality-item .q-bar > span { display: block; height: 100%; background: var(--accent); }
.quality-item.est .q-bar > span { background: var(--warn, #f5b942); }
.quality-item.inf .q-bar > span { background: #8b7cf6; }
.quality-item.miss .q-bar > span { background: var(--danger, #ff6b6b); }
.quality-item .q-sub { font-size: 11.5px; color: var(--txt-2); }
.badge.est { background: rgba(245,185,66,.14); color: #f5b942; }
.badge.inf { background: rgba(139,124,246,.16); color: #a99cf9; }
.badge.worst { background: rgba(120,190,255,.14); color: #8ec5ff; }

/* ---- Positionnement relatif ---- */
.rel-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.rel-kpi { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.rel-kpi .k-label { font-size: 11.5px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .04em; }
.rel-kpi .k-value { font-size: 18px; font-weight: 600; margin-top: 4px; }
.rel-kpi .k-sub { font-size: 11.5px; color: var(--txt-2); }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.rel-grid .chart-box { height: 220px; }
.rel-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
.agent-chip { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--bg-3); color: var(--txt-2); border: 1px solid var(--line); margin-left: 10px; white-space: nowrap; }
.agent-chip.local { color: #7ee2a8; border-color: rgba(126,226,168,.35); }

.ask-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; max-width: 760px; }
.ask-suggestions .btn { white-space: normal; text-align: left; font-size: 12px; }

/* =====================================================================
   Ecrans etroits : Z Fold7 deplie (~800 x 720, quasi carre), iPhone 16 (393 x 852), Z Fold7 plie (~380 x 900).
   Pas de page mobile separee : la meme console, avec une navigation en rail d'icones (tablette / pliable ouvert)
   puis en barre d'onglets basse (telephone). Tableaux : defilement horizontal, jamais de coupe.
   ===================================================================== */

/* --- Tablette et pliable ouvert (<= 1100 px) : rail d'icones, grilles en une colonne --- */
@media (max-width: 1100px) {
  .app { min-width: 0; grid-template-columns: 64px 1fr; }
  .sidebar { padding: 14px 8px 10px; }
  .brand { padding: 2px 4px 12px; justify-content: center; }
  .brand-text, .nav-item span, .sidebar-foot .health span:not(.dot) { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item svg { width: 20px; height: 20px; }
  .sidebar-foot { padding: 8px 0 0; }
  .sidebar-foot .health { justify-content: center; margin-bottom: 8px; }
  .sidebar-foot .btn { font-size: 0; padding: 8px 0; }
  .sidebar-foot .btn::before { font-size: 12px; }
  .sidebar-foot a.btn::before { content: "Tuto"; }
  .sidebar-foot #btn-settings::before { content: "API"; }
  .sidebar-foot #btn-logout::before { content: "Quitter"; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 40px; }
  .grid-2, .charts-grid { grid-template-columns: 1fr; }
  .chart-panel, .chart-panel:nth-child(4), .chart-panel:nth-child(5) { grid-column: auto; }
  .kpi-band { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-wrap: wrap; }
  .mandate-row { grid-template-columns: 28px 1fr; }
  .blend-row { grid-template-columns: 1fr 90px 36px; }
}

/* --- Telephone (<= 640 px) : barre d'onglets basse, en-tete empile, KPI sur 2 colonnes --- */
@media (max-width: 640px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: 100dvh; }
  .main { height: auto; min-height: 0; grid-row: 1; }
  .sidebar {
    grid-row: 2; flex-direction: row; align-items: center; gap: 4px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { display: none; }
  .nav { flex-direction: row; gap: 2px; flex: 1; justify-content: space-between; }
  .nav-item { flex-direction: column; gap: 3px; padding: 6px 2px; min-width: 44px; border-radius: 8px; }
  .nav-item span { display: block; font-size: 9px; letter-spacing: 0; white-space: nowrap; }
  .nav-item.active::before { display: none; }
  .sidebar-foot { display: flex; flex-direction: row; align-items: center; gap: 6px; padding: 0 0 0 6px; border-left: 1px solid var(--line-soft); }
  .sidebar-foot .health { margin: 0; }
  .sidebar-foot .btn { margin: 0 !important; }
  .topbar { height: auto; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .view-title { font-size: 15px; }
  .topbar-actions { gap: 8px; align-items: flex-end; }
  .topbar-actions .field { flex: 1; min-width: 0; }
  .topbar-actions .field.inline:nth-child(2) { display: none; }  /* acteur : dans Parametres API sur telephone */
  .topbar-actions select, .topbar-actions input { width: 100%; max-width: none; }
  .content { padding: 12px 12px 24px; }
  .view { gap: 12px; }
  .panel-head { padding: 10px 12px; flex-wrap: wrap; }
  .panel-body { padding: 12px; }
  .panel-tools { flex-wrap: wrap; }
  .kpi-band { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row > * { flex: 1 1 auto; }
  .btn { padding: 9px 12px; }
  .modal-root { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: calc(100dvh - 24px); border-radius: 12px 12px 0 0; }
  .rel-grid, .rel-tables, .quality-grid, .rel-kpis, .scen-grid, .cmp-grid { grid-template-columns: 1fr; }
  .chart-box { height: 220px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  .toasts { top: 8px; left: 8px; right: 8px; width: auto; max-width: none; }
}
