/* Cockpit — feuille de style unique, aucune ressource externe.
 *
 * Palette : instance de référence du guide de visualisation. Les couleurs de
 * statut sont fixes et ne sont jamais réutilisées comme couleur de série ;
 * elles ne portent jamais l'information seules — un glyphe et un mot les
 * accompagnent partout, parce que vert et rouge sont indistinguables en
 * deutéranopie.
 *
 * Le mode sombre est *choisi*, pas obtenu par inversion : ses valeurs sont
 * calibrées pour la surface sombre.
 */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, .10);
  --series-1: #2a78d6;
  --series-1-soft: rgba(42, 120, 214, .14);

  --ok: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --unknown: #898781;

  --radius: 10px;
  --radius-sm: 6px;
  --gap: 14px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 6px 16px rgba(11, 11, 11, .05);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, .10);
    --series-1: #3987e5;
    --series-1-soft: rgba(57, 135, 229, .18);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, .10);
  --series-1: #3987e5;
  --series-1-soft: rgba(57, 135, 229, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}

.tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- connexion */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card h1 { margin: 0; font-size: 22px; }
.login-sub { margin: 0 0 14px; color: var(--text-secondary); }
.login-card label { font-size: 12px; color: var(--text-secondary); margin-top: 10px; }
.login-card .hint { color: var(--text-muted); }

input, select, textarea {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--baseline);
  border-radius: var(--radius-sm);
  background: var(--plane);
  color: var(--text-primary);
  width: 100%;
}

input:focus-visible, button:focus-visible, select:focus-visible,
[tabindex]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}

.login-error { color: var(--crit); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }

/* ---------------------------------------------------------- barres */

/* Barre, alertes et onglets collent ensemble, en un seul bloc.
   Auparavant chacun était `sticky` avec son propre `top` en dur (49px, la
   hauteur supposée de la barre) : dès que les incidents s'accumulaient, ou que
   la barre passait sur deux lignes, les trois se recouvraient. */
.entete {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--plane);
  display: flex;
  flex-direction: column;
  /* Le bloc collant ne dépasse jamais la moitié de l'écran : au-delà il ne
     resterait plus de place pour ce qu'on est venu regarder. */
  max-height: 55vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand { letter-spacing: .3px; }
.global-label { color: var(--text-secondary); font-size: 13px; }
.clock { color: var(--text-secondary); font-size: 13px; }

.icon-btn {
  font: inherit;
  font-size: 15px;
  line-height: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--plane); border-color: var(--border); }
.icon-btn[aria-pressed="false"] { opacity: .4; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex: none;
  box-shadow: 0 0 0 2px var(--surface-1);
}
.dot-ok { background: var(--ok); }
.dot-degraded { background: var(--warn); }
.dot-down { background: var(--crit); }
.dot-unknown { background: var(--unknown); }

.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.pill-live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill-muted { color: var(--text-muted); }
.pill-down { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }

.warnings {
  padding: 10px 16px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface-1));
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.warnings ul { margin: 0; padding-left: 20px; }

/* ---------------------------------------------------------- alertes */

.alert-bar {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  /* Hauteur réglée par le séparateur et retenue d'une session à l'autre.
     Au-delà, la liste défile sur elle-même plutôt que de pousser le tableau
     de bord hors de l'écran. */
  max-height: var(--hauteur-alertes, 190px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ---------------------------------------------------------- séparateur */

.separateur {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 11px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  user-select: none;
  flex: none;
}
.separateur:hover,
.separateur:focus-visible { background: var(--plane); }
.separateur.actif { background: color-mix(in srgb, var(--series-1) 18%, var(--surface-1)); }

.separateur-poignee {
  width: 46px;
  height: 3px;
  border-radius: 2px;
  background: var(--baseline);
}
.separateur:hover .separateur-poignee { background: var(--series-1); }

.separateur-note {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Replié : seule la première alerte reste visible, et la note dit combien
   d'autres attendent — sans quoi on oublie qu'elles existent. */
.alert-bar.replie { max-height: 46px; }

.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: var(--surface-1);
  border-left: 4px solid var(--unknown);
}
.alert-row.sev-critical { border-left-color: var(--crit); }
.alert-row.sev-warning  { border-left-color: var(--warn); }
.alert-row.sev-info     { border-left-color: var(--series-1); }
.alert-row.is-acked { opacity: .55; }

.alert-glyph { font-size: 14px; flex: none; }
.alert-main { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; }
.alert-detail { color: var(--text-secondary); font-size: 13px; }
.alert-meta { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

@keyframes pulse-crit {
  0%, 100% { background: var(--surface-1); }
  50% { background: color-mix(in srgb, var(--crit) 12%, var(--surface-1)); }
}
.alert-row.sev-critical:not(.is-acked) { animation: pulse-crit 2.4s ease-in-out 4; }
@media (prefers-reduced-motion: reduce) {
  .alert-row.sev-critical:not(.is-acked) { animation: none; }
}

/* ---------------------------------------------------------- onglets */

.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  overflow-x: auto;
  background: var(--plane);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-1); }
.tab[aria-selected="true"] {
  background: var(--surface-1);
  border-color: var(--border);
  color: var(--text-primary);
  font-weight: 600;
}
.tab-icon { font-size: 13px; }
.tab-badge {
  font-size: 11px;
  background: var(--crit);
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}
.tab-tier {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

/* ---------------------------------------------------------- panneau */

.panel { padding: 16px; max-width: 1500px; margin: 0 auto; }

.project-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: var(--gap);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, var(--baseline));
  border-radius: var(--radius);
}
.project-head h2 { margin: 0; font-size: 18px; }
.project-head p { margin: 2px 0 0; color: var(--text-secondary); font-size: 13px; }
.project-head .grow { flex: 1; }
.project-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.project-links a { color: var(--series-1); font-size: 12px; }

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  margin-bottom: var(--gap);
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Tuile d'indicateur : la valeur d'abord, l'état doublé d'un glyphe et d'un mot */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
.stat-label { color: var(--text-secondary); font-size: 13px; }
.stat-state { font-size: 12px; display: flex; align-items: center; gap: 5px; }
.state-ok       { color: var(--ok); }
.state-degraded { color: var(--serious); }
.state-down     { color: var(--crit); }
.state-unknown  { color: var(--text-muted); }

/* ---------------------------------------------------------- graphiques */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 96px; overflow: visible; }
.chart-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round;
              stroke-linejoin: round; }
.chart-area { fill: var(--series-1-soft); stroke: none; }
.chart-grid { stroke: var(--grid); stroke-width: 1; }
.chart-base { stroke: var(--baseline); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-cursor { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-marker { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart-empty { fill: var(--text-muted); font-size: 12px; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  z-index: 5;
}
.tooltip b { font-variant-numeric: tabular-nums; }

details.table-view { margin-top: 8px; }
details.table-view summary {
  cursor: pointer; font-size: 12px; color: var(--text-secondary);
}

/* ---------------------------------------------------------- tableaux */

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.kv th { width: 34%; white-space: nowrap; }

.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------- sondes */

.probe {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface-1);
}
.probe > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
}
.probe > summary::-webkit-details-marker { display: none; }
.probe-name { flex: 1; min-width: 0; }
.probe-err { color: var(--crit); font-size: 12px; }
.probe-meta { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.probe-body { padding: 0 12px 12px; }

pre.raw {
  margin: 0;
  padding: 10px;
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
pre.logs { max-height: 420px; white-space: pre; }

/* ---------------------------------------------------------- boutons */

.btn {
  font: inherit;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
.btn:hover { background: var(--plane); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-danger  { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-note {
  display: block; font-size: 11px; color: var(--text-muted);
  margin-top: 2px; max-width: 30ch; white-space: normal;
}

.action-btn { display: flex; flex-direction: column; align-items: flex-start; }
.action-btn .cls {
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted);
}

/* ---------------------------------------------------------- dialogue */

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 20px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog h2 { margin: 0 0 6px; font-size: 17px; }
.dialog-desc { color: var(--text-secondary); margin: 0 0 12px; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 16px 0 0; padding: 0; }
.dialog label { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 10px; }

/* ---------------------------------------------------------- pied */

.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 12px;
}
.statusbar .spacer { flex: 1; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--baseline);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  color: var(--text-secondary);
}

.console {
  font-family: var(--mono);
  font-size: 12px;
  background: #0d0d0d;
  color: #d8d8d2;
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mt { margin-top: var(--gap); }

/* ------------------------------------------- tableaux de bord métier */

.tdb-outils { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-fenetre[aria-pressed="true"] {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}
.tdb-filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: end;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tdb-filtre { display: flex; flex-direction: column; gap: 3px; }
.tdb-filtre select,
.tdb-filtre input {
  padding: 5px 8px;
  border: 1px solid var(--baseline);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  min-width: 150px;
}
.tdb-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--grid);
}

.tdb-meta { margin: 2px 0 4px; }
.tdb-meta a { color: var(--series-1); }

.tdb-section { margin-top: 20px; }
.tdb-section:first-of-type { margin-top: 10px; }
.tdb-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--grid);
  padding-bottom: 5px;
}
.tdb-section > p.small { margin: -4px 0 8px; max-width: 82ch; }

/* Les tuiles d'un tableau de bord sont plus denses que celles d'un projet :
   il y en a quatre par ligne là où les sondes en montrent deux. */
.tdb-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 0; }
.tdb-grid .stat-value { font-size: 22px; }

/* Tables larges : beaucoup de colonnes étroites plutôt qu'un défilement
   horizontal permanent, qui cacherait la dernière colonne en permanence. */
.tdb-large table { font-size: 12px; }
.tdb-large td { padding: 4px 8px; }

.jauges { display: flex; flex-direction: column; gap: 12px; }
.jauge-tete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.jauge-nom { font-weight: 600; }
.jauge-chiffres { display: flex; align-items: baseline; gap: 8px; }
.jauge-piste {
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--grid);
  overflow: hidden;
}
.jauge-part { height: 100%; border-radius: 999px; background: var(--baseline); }
.jauge-part.etat-serie    { background: var(--series-1); }
.jauge-part.etat-ok       { background: var(--ok); }
.jauge-part.etat-degraded { background: var(--serious); }
.jauge-part.etat-down     { background: var(--crit); }
.jauge .stat-state { margin-top: 3px; }

.tdb-resume {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.tdb-ecart { font-size: 12px; font-weight: 600; display: inline-flex; gap: 3px; }
.tdb-hausse { color: var(--ok); }
.tdb-baisse { color: var(--serious); }
.histo { display: block; width: 100%; height: 60px; }
.histo rect { fill: var(--series-1); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags .pill { display: inline-flex; align-items: baseline; gap: 2px; }

.nuage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  padding: 14px;
  background: var(--plane);
  border-radius: var(--radius-sm);
  line-height: 1.3;
}
.nuage span { color: var(--series-1); font-weight: 600; }

/* ---------------------------------------------------------- notices */

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head h3 { margin: 0; flex: 1; }

.guide summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
.guide summary::-webkit-details-marker { display: none; }
.guide-icon { font-size: 14px; }

.prose { max-width: 76ch; }
.prose p { margin: 8px 0; }
.prose ul { margin: 8px 0; padding-left: 20px; }
.prose li { margin: 3px 0; }
.prose h4, .prose h5, .prose h6 { margin: 14px 0 4px; font-size: 13px; }
.prose code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.doc-label {
  margin: 12px 0 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

/* Attendu et remède : deux blocs distincts, chacun avec son glyphe — la
   couleur seule ne les distinguerait pas en deutéranopie. */
.doc-block {
  margin: 6px 0;
  padding: 8px 11px;
  border-left: 3px solid var(--baseline);
  background: var(--plane);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  max-width: 82ch;
}
.doc-ok   { border-left-color: var(--ok); }
.doc-fail { border-left-color: var(--crit); }

/* ---------------------------------------------------------- bancs */

.bench-group {
  margin: 16px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--grid);
  padding-bottom: 4px;
}
.bench-glyph { font-size: 14px; width: 16px; text-align: center; flex: none; }
.bench-summary { font-size: 12px; }

.tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}
.tag-warn {
  color: var(--crit);
  border-color: color-mix(in srgb, var(--crit) 40%, transparent);
}

/* ---------------------------------------------------------- assistant */

body.with-assistant .panel { max-width: none; margin-right: 420px; }
body.with-assistant .entete,
body.with-assistant .statusbar { padding-right: 420px; }

.assistant {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, .08);
}

.assistant-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.assistant-head .spacer { flex: 1; }

.assistant-status {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.assistant-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble { max-width: 100%; }
.bubble-user .bubble-body {
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-left: 28px;
}
.bubble-claude .bubble-body { font-size: 14px; }
.bubble-body p:first-child { margin-top: 0; }
.bubble-body p:last-child { margin-bottom: 0; }

.bubble-trace {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  border-left: 2px solid var(--grid);
  padding-left: 8px;
}
.trace-line { padding: 1px 0; }
.trace-tool { color: var(--text-secondary); }
.trace-error { color: var(--crit); }

.assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 8px;
}
.chip {
  font: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--baseline);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.chip:hover { background: var(--plane); color: var(--text-primary); }

.assistant-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.assistant-form textarea { resize: vertical; min-height: 60px; }

@media (max-width: 1100px) {
  .assistant { width: 100%; }
  body.with-assistant .panel { margin-right: 0; }
  body.with-assistant .entete,
  body.with-assistant .statusbar { padding-right: 0; }
}

/* ---------------------------------------------------------- mobile
   Le cockpit se consulte depuis le téléphone depuis le 04/08/2026. Ce qu'un
   écran de poche change vraiment, et qui ne se voit pas en réduisant une
   fenêtre de bureau :

   - le doigt n'est pas un curseur. Une cible de 24 px se rate, et sur cette
     page les boutons ratés coupent le son ou déconnectent ;
   - la hauteur est la ressource rare, pas la largeur. Un bandeau d'alertes à
     55 vh plus l'en-tête ne laisserait rien de ce qu'on est venu regarder ;
   - `:hover` n'existe pas. Tout ce qui n'était signalé qu'au survol devient
     invisible — d'où les bordures permanentes sur les onglets ;
   - un tableau large pousse la page entière en débordement horizontal, et la
     colonne de gauche disparaît. Il défile dans son propre cadre. */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .topbar-right { gap: 2px; }
  .global-label, .clock { font-size: 12px; }

  /* 40 px : la plus petite cible qu'un pouce atteint sans viser. */
  .icon-btn {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
  }

  .keys { display: none; }          /* aucun clavier à qui parler de raccourcis */
  .statusbar { padding: 8px 12px; gap: 10px; }

  .grid { grid-template-columns: 1fr; }
  .panel { padding: 12px; }

  /* Sans hauteur rendue, le bandeau d'alertes occupe l'écran entier et le
     projet qu'on venait consulter se trouve sous le pli. */
  .alert-bar { max-height: 40vh; }

  .tabs {
    padding: 6px 8px 0;
    /* Le défilement des onglets s'arrête net sur l'onglet visé plutôt que de
       glisser entre deux — sur un écran étroit, deux onglets à moitié
       affichés ne se lisent ni l'un ni l'autre. */
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .tab { padding: 10px 12px; scroll-snap-align: start; }
  .tab:not([aria-selected="true"]) { border-color: var(--border); opacity: .85; }

  .project-head { flex-wrap: wrap; }

  /* Un tableau plus large que l'écran défile dans son cadre, jamais en
     poussant la page : sinon le titre et les onglets partent hors champ et on
     ne sait plus ce qu'on regarde. */
  .card { overflow-x: auto; }
  table { min-width: max-content; }
  table.kv { min-width: 0; }
  table.kv th { width: auto; white-space: normal; }

  /* La boîte d'action porte la re-saisie du mot de passe et du code TOTP :
     elle doit tenir en entier, clavier ouvert. */
  .dialog { width: calc(100vw - 24px); max-width: none; margin: 12px auto; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; padding: 12px; }

  .login-card { width: calc(100vw - 32px); }
}

/* L'encoche et la barre de gestes de l'iPhone recouvrent le contenu en
   plein écran (« Ajouter à l'écran d'accueil »), y compris la barre d'état
   du bas où se lit le nombre de sondes. */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(12px, env(safe-area-inset-left)); }
  .statusbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}
