/* Copyright (c) 2024-2026 MYTH TECHNOLOGIES. All rights reserved.
 *
 * Console IA (MythAI) — OPS-MYTHAI-CONSOLE-001.
 *
 * ⚠️ CE N'EST PAS UNE COPIE DE `hospital/app.css`, ET C'EST LA MÊME RAISON QUE POUR « Carte &
 * Navigation » : celui-là fait 700 lignes et porte l'histoire de onze écrans — des surcharges de
 * surcharges, des règles qui ne valent que pour un tiroir. En recopier un extrait aurait importé
 * cette histoire sans le moyen de savoir laquelle de ses couches sert encore ICI.
 *
 * Les VARIABLES et le socle (corps, police, `.ghost`, `.spacer`, `.small`, `.myth-logo`) viennent
 * de `shared/console.css` — celles-là sont vraiment partagées, et n'ont qu'un exemplaire.
 */

:root {
  --success-soft: color-mix(in srgb, #18a36f 13%, var(--panel));
  --warning-soft: color-mix(in srgb, #e89a23 14%, var(--panel));
  --danger-soft:  color-mix(in srgb, #df515d 14%, var(--panel));
  --info-soft:    color-mix(in srgb, #4c8fe7 13%, var(--panel));
}

/* ── Charpente ─────────────────────────────────────────────────────────── */
.ai-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.ai-sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px;
  border-right: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; gap: 14px;
}
.sidebar-brand-row { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.ai-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px; color: var(--text); text-decoration: none; }
.ai-brand img { width: 32px; height: 32px; object-fit: contain; }
.ai-brand strong, .ai-brand small { display: block; }
.ai-brand strong { letter-spacing: .07em; font-size: .82rem; }
.ai-brand small { color: var(--muted); font-size: .7rem; margin-top: 2px; }
.ai-nav-label { margin: 2px 8px -4px; color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.ai-nav {
  display: flex; gap: 10px; align-items: center; min-height: 40px; padding: 0 10px;
  color: var(--muted); text-decoration: none; font-size: .86rem; border-radius: 6px;
}
.ai-nav:hover { background: var(--panel-2); color: var(--text); }
.ai-nav.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, var(--panel-2)); font-weight: 700; }
.ai-nav .h-icon { width: 20px; height: 20px; }
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 4px; }

.ai-main { min-width: 0; }
.ai-topbar {
  min-height: 68px; position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--border);
  /* Fond OPAQUE, sans `backdrop-filter` : un flou d'arrière-plan compose la barre dans sa propre
     couche et le texte y perd le lissage sous-pixels (OPS-CONSOLE-FONT-SMOOTHING-001). */
  background: var(--bg);
}
.top-title strong, .top-title small { display: block; }
.top-title strong { font-size: .94rem; }
.top-title small { color: var(--muted); font-size: .75rem; margin-top: 3px; }
.top-spacer { flex: 1; }
.top-profile {
  max-width: 280px; padding: 7px 10px; text-align: left; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
}
.top-profile strong, .top-profile span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-profile strong { font-size: .78rem; }
.top-profile span { color: var(--muted); font-size: .68rem; margin-top: 2px; }
.icon-button {
  width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0;
  color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
}
.icon-button:hover { border-color: var(--accent); color: var(--accent); }
.ai-content { max-width: none; margin: 0; padding: clamp(14px, 1.6vw, 24px) clamp(16px, 2vw, 30px); }

/* ── Bandeaux d'environnement et de contexte ───────────────────────────── */
.environment-bar {
  display: flex; gap: 10px; align-items: center; min-height: 38px; margin: -4px 0 18px;
  padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--warn) 42%, var(--border));
  background: var(--warning-soft); font-size: .78rem;
}
.environment-bar strong { color: var(--warn); }
.context-bar {
  display: grid; gap: 10px; align-items: end; margin-bottom: 22px; padding: 10px;
  border: 1px solid var(--border); background: var(--panel);
  grid-template-columns: minmax(160px, .8fr) minmax(200px, 1fr) minmax(200px, 1fr) minmax(150px, .6fr);
}
.context-heading { display: grid; gap: 4px; min-height: 38px; align-content: center; }
.context-fixed { grid-template-columns: minmax(180px, .8fr) minmax(0, 2fr); align-items: center; }
.context-heading span { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.context-heading strong { font-size: .83rem; }
.context-field { min-width: 0; display: grid; gap: 4px; }
.context-field span { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.context-field select { width: 100%; min-height: 38px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; color: var(--text); background: var(--panel-2); }

/* ── En-tête de module, indicateurs ────────────────────────────────────── */
.module-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.module-header h1 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: clamp(1.5rem, 2.4vw, 2.1rem); }
.module-header h1 .h-icon { width: 1.1em; height: 1.1em; color: var(--accent); }
.module-header p:not(.eyebrow) { max-width: 78ch; margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.kpi { min-height: 118px; padding: 15px; border: 1px solid var(--border); border-left-width: 3px; background: var(--panel); }
.kpi span, .kpi small { display: block; color: var(--muted); font-size: .72rem; }
.kpi strong { display: block; margin: 10px 0 7px; font-size: 1.9rem; line-height: 1; }
.kpi.good { border-left-color: #18a36f; } .kpi.warn { border-left-color: #e89a23; }
.kpi.bad { border-left-color: #df515d; }  .kpi.info { border-left-color: #4c8fe7; }

/* ── Panneaux et tableaux ──────────────────────────────────────────────── */
.panel { margin-bottom: 18px; border: 1px solid var(--border); background: var(--panel); }
.panel > header { display: flex; justify-content: space-between; gap: 12px; align-items: start; min-height: 62px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel h2 { margin: 0; font-size: 1rem; }
.panel header p { margin: 5px 0 0; color: var(--muted); font-size: .77rem; }
/* `overflow:hidden` : sans lui, un tableau large ne se contente pas de défiler dans `.grid-wrap`,
   il DÉBORDE du panneau — les boutons d'action sortent de la carte, coupés en plein libellé.
   Visible sur une capture, invisible pour toute garde d'attributs. */
.grid-panel { overflow: hidden; }
.grid-wrap { max-width: 100%; overflow: auto; }
.grid-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.data-grid { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-grid th { height: 42px; padding: 0 14px; color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--border); text-align: left; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; }
.data-grid td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: .81rem; vertical-align: top; }
.data-grid tr:last-child td { border-bottom: 0; }
.data-grid strong, .data-grid small { display: block; }
.data-grid small { margin-top: 3px; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.data-grid .key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .69rem; }
.mono { font-variant-numeric: tabular-nums; }
.c-num { white-space: nowrap; }
.c-text { min-width: 220px; }
.cell-text { display: block; line-height: 1.5; }
.c-id { min-width: 240px; }
.c-range { min-width: 190px; }
code.evt { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .74rem; padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; }

.h-status { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border: 1px solid var(--border); border-radius: 999px; font-size: .67rem; font-weight: 700; white-space: nowrap; }
.h-status.good { color: var(--accent-2); border-color: #159364; background: var(--success-soft); }
.h-status.warn { color: var(--warn); border-color: var(--warn); background: var(--warning-soft); }
.h-status.bad  { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.h-status.info { color: var(--accent); border-color: var(--accent); background: var(--info-soft); }

.filter-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 16px 0; }
.panel > header .filter-actions { padding: 0; }
.filter-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.filter-actions .h-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.filter-limit { display: grid; gap: 4px; font-size: .77rem; color: var(--muted); }
.filter-limit input, .filter-limit select { min-height: 34px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.filter-hint { margin: 12px 16px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.filter-notice { margin: 12px 16px; padding: 10px 12px; color: var(--text); background: var(--info-soft); border-radius: 8px; font-size: .82rem; line-height: 1.5; }
.ghost-button { background: transparent; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); padding: 6px 10px; cursor: pointer; }
.ghost-button:hover { color: var(--accent); border-color: var(--accent); }
button.secondary { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 7px 12px; }
.link-button { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: .78rem; }
.console-link { text-decoration: none; }

.empty-state { display: grid; justify-items: center; max-width: 640px; margin: 50px auto; padding: 20px; text-align: center; }
.empty-state .h-icon { width: 30px; height: 30px; color: var(--accent); }
.empty-state h2 { margin: 12px 0 5px; font-size: 1rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .83rem; line-height: 1.5; }

.quality-gaps { margin: 12px 16px; display: grid; gap: 10px; }
.quality-gaps dt { font-weight: 650; font-size: .84rem; }
.quality-gaps dd { margin: 3px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.5; }

.context-notice {
  display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warning-soft);
  font-size: .8rem; line-height: 1.5;
}
.context-notice .h-icon { width: 20px; height: 20px; color: var(--warn); flex: 0 0 auto; }
.context-notice p { margin: 5px 0 0; }

/* ── Réglages ──────────────────────────────────────────────────────────── */
.settings-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px 16px; }
.record-filter { display: grid; gap: 5px; min-width: 0; }
.record-filter > span { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.record-filter input, .record-filter select { min-height: 34px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 150px; }
/* Une provenance se lit AVANT le texte : la bande de gauche dit « réglable / ailleurs / illisible »
   sans qu'on ait à parcourir la ligne jusqu'à la dernière colonne. */
.settings-grid tr.ctrl-tunable    td:first-child { box-shadow: inset 3px 0 0 #18a36f; }
.settings-grid tr.ctrl-elsewhere  td:first-child { box-shadow: inset 3px 0 0 #4c8fe7; }
.settings-grid tr.ctrl-not_exposed td:first-child { box-shadow: inset 3px 0 0 #e89a23; }
.reason-codes { line-height: 1.9; }
.amp { display: grid; gap: 5px; }
.amp-bar { display: block; height: 5px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.amp-bar i { display: block; height: 100%; background: var(--accent); }
.amp-bar.down i { background: var(--danger); }
.amp-bar.both i { background: linear-gradient(90deg, var(--danger), var(--accent)); }

/* ── Calibrage ─────────────────────────────────────────────────────────── */
.calib-slider { display: flex; align-items: center; gap: 8px; }
.calib-slider input[type="range"] { flex: 1; min-width: 110px; accent-color: var(--accent); }
.calib-bound { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.calib-grid tr.calib-moved td { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.calib-origin { margin-top: 12px; }
.calib-sample, .calib-activate { padding-bottom: 4px; }
.preset-list { list-style: none; margin: 12px 16px 0; padding: 0; display: grid; gap: 8px; }
.preset-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.preset-list strong { display: block; font-size: .85rem; }
.preset-list small { display: block; margin-top: 3px; color: var(--muted); font-size: .74rem; }
.preset-list .filter-actions { padding: 0; }

/* ── Contextes ─────────────────────────────────────────────────────────── */
.context-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); padding: 12px 16px 16px; }
.context-card { border: 1px solid var(--border); border-left-width: 3px; border-left-color: var(--border); border-radius: 10px; padding: 13px 15px; display: grid; gap: 10px; align-content: start; background: var(--panel); }
.context-card.on { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.context-card.planned { border-left-color: var(--warn); }
.context-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.context-card strong { display: block; font-size: .9rem; }
.context-card small { display: block; margin-top: 3px; color: var(--muted); font-size: .73rem; }
.context-card .domain-reason { margin: 0; color: var(--muted); font-size: .79rem; line-height: 1.5; }
.context-card button { justify-self: start; }

/* Ce que le palier voit — deux colonnes, visibles à gauche, hors palier à droite. Côte à côte
   plutôt que l'une sous l'autre : la question posée est « qu'est-ce qui manque au public », et une
   comparaison qui demande de faire défiler n'en est pas une. */
.tier-cats { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); padding: 14px 16px 4px; }
.tier-cats-title { margin: 0 0 8px; color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tier-cats ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.tier-cats li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.tier-cats li small { color: var(--muted); font-size: .74rem; }

/* ── Scénario ─────────────────────────────────────────────────────────── */
/* Les groupes côte à côte : dix-huit champs en UNE colonne obligeraient à faire défiler entre le
   formulaire et le résultat, et c'est justement l'aller-retour qu'on vient supprimer. */
.sc-groupes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); padding: 14px 16px 4px; }
.sc-groupe { margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; display: grid; gap: 12px; align-content: start; }
.sc-groupe legend { padding: 0 6px; color: var(--accent); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sc-champ { display: grid; gap: 5px; min-width: 0; }
.sc-champ > span { color: var(--muted); font-size: .72rem; font-weight: 650; }
.sc-champ input[type="number"], .sc-champ select { min-height: 34px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 0; }
.sc-champ small { color: var(--muted); font-size: .71rem; line-height: 1.45; }
/* Une case à cocher se lit à l'horizontale : la mettre sous son libellé comme un champ texte
   fabrique une colonne de cases orphelines qu'on n'associe plus à rien. */
.sc-case { grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px; }
.sc-case input { order: -1; width: 16px; height: 16px; accent-color: var(--accent); }
.sc-case small { grid-column: 1 / -1; }
.filter-option { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
/* Un levier sans effet reste LISIBLE mais recule : il ne doit ni disparaître (on croirait un
   réglage manquant) ni retenir l'œil (il n'a rien apporté ici). */
.sc-inactif td { opacity: .62; }
.sc-motifs { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; }

/* ── Apprentissage ─────────────────────────────────────────────────────── */
.report-card { margin: 12px 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; }
.report-card header { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: baseline; }
.report-card p { margin: 8px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; white-space: pre-wrap; }

/* ── Étroit ────────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .context-bar { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .ai-shell { grid-template-columns: minmax(0, 1fr); }
  .ai-sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-brand-row { width: 100%; }
  .sidebar-bottom { margin-top: 0; border-top: 0; padding-top: 0; display: flex; }
  .ai-topbar { flex-wrap: wrap; gap: 8px; }
  .ai-topbar .top-title { flex: 1 1 100%; min-width: 0; }
  .ai-topbar .top-profile { margin-left: auto; max-width: calc(100% - 120px); }
  .ai-topbar .icon-button { flex: 0 0 36px; }
}

/* MYTH-DEMANDE-GROUPES-001 — « Catégories et horaires » : la grille 0 h → 23 h en cases cliquables. */
.dg-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 12px; padding: 0 16px; }
.dg-controls label { display: flex; gap: 8px; align-items: center; }
.dg-cap { width: 56px; }
.dg-grid { display: grid; grid-template-columns: repeat(24, minmax(28px, 1fr)); gap: 2px; min-width: 720px; }
.dg-cell { padding: 0; height: 32px; font-size: 12px; border-radius: 3px; border: 1px solid transparent; cursor: pointer; }
.dg-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dg-cell.now { border-color: var(--text); }
.dg-cell.lvl-0 { background: var(--panel-2); color: var(--muted); }
.dg-cell.lvl-1 { background: #cde2fb; color: #0d366b; }
.dg-cell.lvl-2 { background: #86b6ef; color: #0d366b; }
.dg-cell.lvl-3 { background: #3987e5; color: #fff; }
.dg-cell.lvl-4 { background: #256abf; color: #fff; }
.dg-cell.lvl-5 { background: #104281; color: #fff; }
.dg-title { margin: 16px; }
.dg-rank { display: flex; flex-wrap: wrap; gap: 8px 28px; padding-left: 20px; margin: 12px 16px 18px; }
.dg-activate { display: grid; gap: 8px; margin-top: 14px; padding: 0 16px 16px; }
.dg-activate label { display: grid; gap: 6px; color: var(--muted); font-size: .8rem; }
.dg-activate textarea { width: 100%; padding: 8px; min-height: 64px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.dg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dg-history { display: grid; gap: 8px; padding-left: 18px; margin: 12px 16px 16px; }

/* OPS-MYTHAI-CAS-ET-VOTES-0411-001 — Cas et votes */
.data-grid tr.selected td { background: var(--info-soft); }
.case-text { margin: 0 16px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.case-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 16px; }
.case-facts dt { color: var(--muted); }
.case-facts dd { margin: 0; overflow-wrap: anywhere; }

/* OPS-MYTHAI-LECTURE-PERIMEE-0511-001 — le cas s'ouvre dans le tiroir partagé (shared/console.css). */
.case-drawer .case-steps { justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.case-drawer .case-pad { margin: 16px 18px; }
.case-drawer .dg-activate { margin: 12px 16px 20px; }

/* OPS-CONSOLE-IA-SIGNALEMENTS-0511-001 — « Signalements IA », sous « Cas et votes » ; échange et purge
   dans le même tiroir. */
.ai-nav.ai-nav-sub { margin-left: 18px; font-size: .92em; }
.case-report { padding: 8px 0; border-block: 1px solid var(--border); }
.case-exchange { display: grid; gap: 10px; margin: 0 16px 12px; padding-left: 18px; }
.case-exchange li p { margin: 2px 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.case-exchange li.current { color: var(--text); font-weight: 600; }
.case-purge { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.case-purge summary { cursor: pointer; color: var(--danger); font-weight: 600; }
.case-purge label { display: grid; gap: 4px; margin-top: 8px; }
button.danger { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; font-weight: 600; }
.case-question { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
