*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-black:    #181F2A;
  --c-red:      #C11F38;
  --c-blue:     #1F50A8;
  --c-brand:    #40D4A2;
  --c-navy:     #2233D9;
  --c-bg:       #F4F6FA;
  --c-white:    #FFFFFF;
  --c-border:   #D3D8E2;
  --c-muted:    #6B7488;
  --radius:     6px;
  --shadow:     0 2px 8px rgba(34,51,217,.07);
  --c-si:       #2233D9;
  --c-predicat: #6B38B5;
}

html, body {
  height: 100%;
  background: var(--c-bg);
  color: var(--c-black);
  font-family: 'DM Sans', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
#root { min-height: 100%; display: flex; flex-direction: column; }


/* ── top bar ── */
.topbar {
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-left { display: flex; align-items: center; gap: 20px; }

.logo-mark {
  display: flex;
  align-items: center;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.5px;
  text-decoration: none;
  user-select: none;
}
.logo-mark .via { color: var(--c-navy); }
.logo-mark .dc  { color: var(--c-brand); }

.logo-sep  { width: 1px; height: 26px; background: var(--c-border); }
.tool-name { font-size: 13.5px; font-weight: 500; color: var(--c-muted); }

.tab-nav { display: flex; }
.tab-btn {
  padding: 0 22px;
  height: 56px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-muted);
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  font-family: inherit;
  white-space: nowrap;
}
.tab-btn:hover        { color: var(--c-black); }
.tab-btn.active       { color: var(--c-navy); border-bottom-color: var(--c-navy); }


/* ── section separator ── */
.sep {
  border: none;
  height: 1px;
  margin: 28px 0;
  background: linear-gradient(90deg, transparent, var(--c-border) 15%, var(--c-border) 85%, transparent);
}


/* ── page ── */
.page {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title    { font-size: 21px; font-weight: 600; color: var(--c-black); letter-spacing: -.3px; }
.page-subtitle { font-size: 13px; color: var(--c-muted); margin-top: 3px; }


/* ── section label ── */
.section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-blue);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
  opacity: .6;
}


/* ── card ── */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}


/* ── form controls ── */
.field {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 7px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--c-black);
  background: var(--c-white);
  outline: none;
  transition: border-color .15s;
  height: 36px;
}
.field:focus       { border-color: var(--c-navy); }
.field::placeholder { color: #b0b8c4; }

select.field {
  cursor: pointer;
  padding-right: 28px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7488' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field-file {
  border: 1.5px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 7px 11px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fafbfc;
  outline: none;
  height: 36px;
  cursor: pointer;
  color: var(--c-black);
}
.field-file:hover { border-color: var(--c-navy); }


/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  height: 36px;
  border-radius: 20px;
  border: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
  transition: opacity .15s, background .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

.btn-red             { background: var(--c-red); color: #fff; border-color: var(--c-red); }
.btn-red:hover       { opacity: .87; }
.btn-red-outline     { background: transparent; color: var(--c-red); border-color: var(--c-red); }
.btn-red-outline:hover { background: rgba(193,31,56,.05); }
.btn-ghost           { background: transparent; color: var(--c-muted); border-color: var(--c-border); }
.btn-ghost:hover     { border-color: #b0b8c4; color: var(--c-black); }
.btn-sm              { height: 30px; padding: 0 13px; font-size: 12px; border-radius: 15px; }
.btn-icon            { width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: 15px; flex-shrink: 0; }
.btn-delete          { height: 26px; padding: 0 10px; font-size: 11px; border-radius: 4px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }


/* ── toolbar ── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-mb { margin-bottom: 24px; }


/* ── import section ── */
.import-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-muted);
}


/* ── results ── */
.results-list { display: flex; flex-direction: column; }
.result-row {
  display: flex;
  flex-direction: column;
  padding: 11px 0;
  border-bottom: 1px solid var(--c-border);
}
.result-row:last-child { border-bottom: none; }
.result-row-top    { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; }
.result-row-bottom { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 8px; }
.result-narrative  { font-size: 13px; color: var(--c-black); line-height: 1.5; flex: 1; margin: 0; }
.result-row-actions, .rapport-card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.result-name     { font-size: 13.5px; font-weight: 500; color: var(--c-black); }
.result-bar-wrap { display: flex; align-items: center; gap: 10px; }
.result-value    { color: var(--c-blue); font-size: 13px; font-weight: 500; white-space: nowrap; }
.result-line     { flex: 1; height: 2px; background: var(--c-blue); border-radius: 1px; opacity: .3; }
.result-ref      { font-family: 'DM Mono', monospace; color: var(--c-blue); font-size: 12px; opacity: .7; white-space: nowrap; }
.results-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
}


/* ── score table ── */
.scrollable { overflow-x: auto; }
.data-filters { display: flex; gap: 8px; padding: 0 0 10px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.score-table th,
.score-table td     { border: 1px solid var(--c-border); padding: 8px 14px; text-align: center; white-space: nowrap; }
.score-table th     { background: #EEF2F8; font-weight: 600; color: var(--c-navy); font-size: 11.5px; letter-spacing: .04em; }
.score-table th.row-header { text-align: left; }
.score-table td.row-label  { text-align: left; font-weight: 500; color: var(--c-black); background: #f9fafb; }
.score-table td.col-type   { text-align: left; }
.score-table th.col-type   { font-size: 11px; color: var(--c-muted); font-weight: 500; width: 88px; }

.score-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.score-high  { background: #dff4e9; color: #1a6b3a; }
.score-med   { background: #fef3e2; color: #b45c0a; }
.score-low   { background: #fde9ec; color: #a01224; }

/* kind badges used in the matrix */
.kind-badge          { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 10px; letter-spacing: .04em; }
.kind-badge-si       { background: #eaf0fb; color: var(--c-si); }
.kind-badge-predicat { background: #f3edfb; color: var(--c-predicat); }


/* ── data table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th,
.data-table td { border: 1px solid var(--c-border); padding: 8px 14px; text-align: left; }
.data-table th { background: #EEF2F8; font-weight: 600; font-size: 11.5px; letter-spacing: .05em; color: var(--c-navy); }
.data-table td.name-cell { color: var(--c-black); font-weight: 500; }
.data-table td { color: var(--c-blue); }
.data-table tr:nth-child(even) td { background: #f9fafb; }


/* ── status chip ── */
.chip       { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.chip-ready { background: #dff4e9; color: #1a6b3a; }
.chip-dot   { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }


/* ── empty state ── */
.empty-state { text-align: center; padding: 32px 0; color: var(--c-muted); font-size: 13px; }


/* ── toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--c-black);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }


/* ── modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box     { background: var(--c-white); border-radius: 10px; padding: 24px; width: 360px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.modal-title   { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.modal-textarea {
  width: 100%;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
  min-height: 90px;
  outline: none;
}
.modal-textarea:focus { border-color: var(--c-navy); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }


/* ── rule editor ── */
.rule-list { display: flex; flex-direction: column; gap: 10px; }

.rule-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.rule-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f9fafb;
  border-bottom: 1px solid var(--c-border);
}
.rule-card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.rule-card-body    { padding: 14px 16px; }

.rule-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-navy);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rule-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  min-width: 52px;
}
.rule-lbl-inline { min-width: auto; }
.rule-arrow      { color: var(--c-muted); font-size: 16px; font-weight: 300; }

.kind-pills { display: flex; gap: 6px; }
.kind-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--c-border);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  background: var(--c-white);
  color: var(--c-muted);
  letter-spacing: .04em;
  transition: all .15s;
}
.kind-pill:hover           { border-color: #aab0be; color: var(--c-black); }
.kind-pill.active-si       { background: #eaf0fb; color: var(--c-si);       border-color: var(--c-si); }
.kind-pill.active-predicat { background: #f3edfb; color: var(--c-predicat); border-color: var(--c-predicat); }

/* mandatory max-pts card */
.maxpts-card {
  background: var(--c-white);
  border: 1.5px solid var(--c-navy);
  border-left: 4px solid var(--c-navy);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 4px rgba(13,43,94,.08);
}
.maxpts-lock {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eef2f8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.maxpts-label    { font-size: 13.5px; font-weight: 600; color: var(--c-navy); }
.maxpts-sublabel { font-size: 11.5px; color: var(--c-muted); margin-top: 1px; }
.maxpts-input    { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.maxpts-input input {
  width: 150px;
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: var(--c-navy);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-family: inherit;
  outline: none;
  background: #f8f9fb;
}
.maxpts-input input:focus { border-color: var(--c-navy); background: var(--c-white); }
.maxpts-unit { font-size: 13px; font-weight: 600; color: var(--c-muted); }

.rule-fields { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.field-row           { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-row .field    { flex: 1; min-width: 90px; }
.field-row .field-xs { max-width: 90px; }
.field-row .field-sm { max-width: 130px; }
.field-row .field-md { max-width: 200px; }
.field-row .field-lg { max-width: 260px; }
.field-predicat      { flex: 2; min-width: 200px; }

.add-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: transparent;
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-muted);
  font-family: inherit;
  transition: border-color .15s, color .15s;
}
.add-rule:hover  { border-color: var(--c-red); color: var(--c-red); }
.add-rule-plus {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 300;
  flex-shrink: 0;
}


/* ── job status ── */
.job-status {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.job-status-running { background: #EEF2F8; color: var(--c-navy); }
.job-status-done    { background: #dff4e9; color: #1a6b3a; }
.job-status-error   { background: #fde9ec; color: #a01224; }


/* ── spinner ── */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ── rapport section ── */
.rapport-list { display: flex; flex-direction: column; gap: 14px; }
.rapport-card { background: var(--c-white); border: 1px solid var(--c-border); border-radius: 8px; padding: 16px; }
.rapport-card-head { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; margin-bottom: 10px; }
.rapport-narrative-long { font-size: 13px; color: var(--c-black); line-height: 1.6; white-space: pre-wrap; margin: 0 0 12px; }

/* Override fallback compact — réutilise seulement la couleur/taille de .empty-state,
   sans son text-align: center ni son padding: 32px 0 (UI-SPEC ligne 126 : scopé à
   une ligne/carte, pas un bloc centré pleine largeur). Déclaré après .empty-state
   pour garantir la spécificité nécessaire. */
.result-narrative-empty, .rapport-narrative-empty { color: var(--c-muted); text-align: left; padding: 0; }


/* ── rapport page ── */
.rapport-page { flex: 1; padding: 32px; max-width: 860px; margin: 0 auto; width: 100%; }
.rapport-page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.rapport-rules-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.rapport-rule-item {
  font-size: 13px;
  color: var(--c-black);
  line-height: 1.5;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}
.rapport-page-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* iframe wrapper — plan 20-03 (D-16) */
.rapport-iframe {
  display: block;
  border: none;
  flex: 1;
  width: 100%;
}


/* ── prompt editor ── */
.prompt-card {}
.prompt-textarea {
  width: 100%;
  min-height: 220px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--c-black);
  background: var(--c-white);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.prompt-textarea:focus { border-color: var(--c-navy); }
.prompt-textarea::placeholder { color: #b0b8c4; }

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}


/* ── Historique (Phase 14) ── */

/* Bouton d'action de nav — distinct des .tab-btn (pas d'état actif, pas de border-bottom) */
.btn-histo {
  padding: 0 18px;
  height: 36px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--c-navy);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
  transition: background .15s, border-color .15s;
}
.btn-histo:hover { background: rgba(34,51,217,.06); border-color: var(--c-navy); }

/* Modal historique — variante de .modal-box adaptée à une liste */
.histo-modal {
  min-width: 420px;
  max-width: 560px;
  width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

/* Conteneur scrollable de la liste des jobs */
.histo-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0 12px;
  flex: 1;
}

/* Ligne de job cliquable */
.histo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  cursor: pointer;
  transition: background .12s;
}
.histo-item:hover { background: rgba(107,116,136,.08); border-color: #b0b8c4; }

/* Champs inline de chaque item : UUID, heure, statuts */
.histo-meta {
  font-size: 12px;
  color: var(--c-muted);
  white-space: nowrap;
}
.histo-meta + .histo-meta::before {
  content: '·';
  margin-right: 10px;
  color: var(--c-border);
}


@media print {
  .topbar,
  .tab-nav,
  .rapport-page-footer,
  .btn-histo,
  .toast-container { display: none !important; }

  body { background: white; color: black; font-size: 12pt; }
  .rapport-page { padding: 24px; max-width: none; }
  .rapport-narrative-long { white-space: pre-wrap; }
  a { color: black; text-decoration: none; }
  .score-badge, .chip { border: 1px solid #ccc; }
}
