/* ORION-OPS — console d'administration technique. Thème clair / sombre, responsive. */

:root {
  --bg: #f4f2fb;
  --surface: #ffffff;
  --surface-2: #f8f7fd;
  --sunken: #efecf8;
  --border: #e3dff0;
  --border-strong: #cfc8e6;
  --text: #1d1b2c;
  --text-2: #4b4764;
  --muted: #6e6a86;
  --primary: #5b3fd9;
  --primary-2: #4b2fc6;
  --primary-soft: #ece8fd;
  --on-primary: #ffffff;
  --ok: #0c7a4c; --ok-bg: #def4e9;
  --warn: #93590a; --warn-bg: #fdf1d8;
  --err: #b4261a; --err-bg: #fde6e3;
  --info: #1f5fbf; --info-bg: #e3edfd;
  --idle: #6e6a86; --idle-bg: #eceaf3;
  --code-bg: #f3f1fa;
  --shadow: 0 1px 2px rgb(30 20 80 / 0.06), 0 6px 20px rgb(30 20 80 / 0.06);
  --shadow-lg: 0 20px 60px rgb(30 20 80 / 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 248px;
  --topbar: 60px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Cascadia Code', 'JetBrains Mono', Consolas, 'SFMono-Regular', Menlo, monospace;
  /* Coloration SQL */
  --sql-kw: #6a37d6; --sql-str: #0c7a4c; --sql-num: #b4561a; --sql-cmt: #8a86a0; --sql-fn: #1f5fbf; --sql-id: #1d1b2c; --sql-type: #a0337a; --sql-op: #4b4764;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #15141c;
  --surface: #1e1d28;
  --surface-2: #232230;
  --sunken: #191822;
  --border: #302e40;
  --border-strong: #423f57;
  --text: #e2e0ec;
  --text-2: #bdb9d0;
  --muted: #9894ad;
  --primary: #a99df0;
  --primary-2: #bdb3f5;
  --primary-soft: #2c2847;
  --on-primary: #17161e;
  --ok: #6fd3a3; --ok-bg: #173226;
  --warn: #f0c46a; --warn-bg: #362b14;
  --err: #f59384; --err-bg: #3b1d1a;
  --info: #8fb6f5; --info-bg: #1b2a42;
  --idle: #9894ad; --idle-bg: #2a2937;
  --code-bg: #191822;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
  --sql-kw: #b7a8ff; --sql-str: #7fd6a8; --sql-num: #f3a76c; --sql-cmt: #7d7994; --sql-fn: #8fb6f5; --sql-id: #e2e0ec; --sql-type: #f094c9; --sql-op: #bdb9d0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Icônes : taille par défaut liée au texte (une icône dans un conteneur sans règle ne doit jamais occuper toute la largeur).
   Placée avant les autres règles : .btn svg, .nav-link svg, etc. gardent la main. */
svg[aria-hidden="true"] { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ── Coquille ── */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(140deg, #7b5cf5, #4b2fc6); color: #fff; font-weight: 800; }
.brand strong { display: block; letter-spacing: 0.08em; font-size: 14px; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.12em; }
.nav-group { margin-top: 10px; }
.nav-group > span { display: block; padding: 6px 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link .count { margin-left: auto; padding: 0 7px; border-radius: 99px; background: var(--sunken); color: var(--muted); font-size: 11px; font-weight: 700; }
.side-foot { margin-top: auto; padding: 12px 8px 0; color: var(--muted); font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: var(--topbar); padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar h1 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 0 1 0; }
/* Spécificité > .btn (déclaré plus bas) : le bouton menu ne sert que quand le menu est replié. */
.topbar .menu-btn { display: none; }
/* Pleine largeur à côté du menu, quel que soit l'écran (pas de plafond qui laisse un vide à droite). */
.content { padding: 24px clamp(16px, 2vw, 40px); display: grid; gap: 20px; width: 100%; min-width: 0; }
.content > .view { display: grid; gap: 20px; min-width: 0; align-content: start; }

/* ── Composants ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.stack > *, .grid > * { min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.page-intro { margin: -6px 0 0; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--primary); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); border-color: var(--primary-2); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--err) 85%, #000); border-color: var(--err); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--idle-bg); color: var(--idle); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.s-SAIN, .s-SUCCES, .s-ok { background: var(--ok-bg); color: var(--ok); }
.s-DEMARRAGE, .s-EN_COURS { background: var(--info-bg); color: var(--info); }
.s-DEMARRAGE::before, .s-EN_COURS::before { animation: pulse 1.2s infinite; }
.s-DEGRADE, .s-AVERTISSEMENT, .s-warn { background: var(--warn-bg); color: var(--warn); }
.s-ERREUR, .s-error, .s-missing { background: var(--err-bg); color: var(--err); }
.s-ARRETE, .s-EN_ATTENTE, .s-IGNORE, .s-ANNULE, .s-INCONNU { background: var(--idle-bg); color: var(--idle); }
@keyframes pulse { 50% { opacity: 0.35; } }

.pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); font-weight: 600; font-size: 12.5px; }
.pill:hover { text-decoration: none; border-color: var(--primary); }

.kpi { display: grid; gap: 4px; padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .value { font-size: 26px; font-weight: 800; line-height: 1.15; }
.kpi .sub { color: var(--muted); font-size: 12.5px; }
.kpi.is-link { cursor: pointer; }
.kpi.is-link:hover { border-color: var(--primary); }

/* Formulaires */
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
textarea.input { min-height: 80px; resize: vertical; }
.pw { position: relative; display: block; }
.pw .input { padding-inline-end: 44px; }
.pw-toggle { position: absolute; inset-block: 0; inset-inline-end: 2px; display: grid; place-items: center; width: 40px; border: 0; border-radius: 8px; background: none; color: var(--muted, inherit); cursor: pointer; }
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.choice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface);
}
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 60%, var(--surface)); }
.choice.danger:has(input:checked) { border-color: var(--err); background: color-mix(in srgb, var(--err-bg) 70%, var(--surface)); }
.choice input { margin-top: 3px; accent-color: var(--primary); }
.choice strong { display: block; }
.choice small { color: var(--muted); }
.search { position: relative; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }

/* Tableaux */
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; z-index: 1; padding: 9px 12px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* Messages */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--info-bg); color: var(--info); }
.alert svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.err { background: var(--err-bg); color: var(--err); }
.danger { color: var(--err); }
.field [aria-invalid="true"] { border-color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert strong { display: block; }

.diagnostic { border: 1px solid color-mix(in srgb, var(--err) 35%, var(--border)); border-left: 4px solid var(--err); border-radius: 12px; background: color-mix(in srgb, var(--err-bg) 45%, var(--surface)); padding: 14px 16px; }
.diagnostic h4 { margin: 0 0 8px; color: var(--err); font-size: 14px; }
.diagnostic dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.diagnostic dt { color: var(--muted); font-weight: 600; }
.diagnostic dd { margin: 0; overflow-wrap: anywhere; }
.diagnostic pre { margin: 10px 0 0; padding: 10px; border-radius: 8px; background: var(--code-bg); white-space: pre-wrap; max-height: 220px; overflow: auto; }

/* Services */
.layer-head { align-items: center; }
.layer-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.layer-ico { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--primary-bg, var(--surface-2)); color: var(--primary); }
.layer-ico svg { width: 20px; height: 20px; }
.source-bar { display: flex; align-items: center; gap: 10px; padding: 9px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.source-bar > svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.source-bar.is-worktree { background: var(--warn-bg); }
.source-bar.is-worktree > svg { color: var(--warn, #b26a00); }
.source-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ref-pick { display: grid; gap: 10px; grid-template-columns: auto minmax(0, 1fr); align-items: end; }
@media (max-width: 640px) {
  .source-bar { flex-wrap: wrap; padding: 9px 14px; }
  .source-bar .btn { width: 100%; justify-content: center; }
  .ref-pick { grid-template-columns: minmax(0, 1fr); }
}
.tests-grid { align-items: stretch; }
.test-card { display: flex; flex-direction: column; }
.test-card .card-body { flex: 1; }
.test-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.test-card .card-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.test-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.test-kpi { display: grid; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.test-kpi strong { font-size: 20px; line-height: 1.1; }
.test-kpi span { font-size: 11.5px; color: var(--muted); }
.test-kpi.ok strong { color: var(--ok, #1f8a4c); }
.test-kpi.err strong { color: var(--err); }
.test-bar { height: 6px; border-radius: 6px; background: var(--err-bg); overflow: hidden; }
.test-bar span { display: block; height: 100%; background: var(--ok, #1f8a4c); }
.test-history { display: flex; gap: 4px; flex-wrap: wrap; }
.test-history .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.test-history .dot.s-SUCCES { background: var(--ok, #1f8a4c); }
.test-history .dot.s-ERREUR { background: var(--err); }
.test-history .dot.s-AVERTISSEMENT { background: var(--warn); }
.test-kpi.is-link { border: 1px solid transparent; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.test-kpi.is-link:hover, .test-kpi.is-link:focus-visible { border-color: var(--err); background: var(--err-bg); outline: none; }
.ko-list { display: grid; gap: 6px; }
.ko-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "badge name ico" "badge msg ico"; gap: 2px 10px; align-items: center; width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-left: 3px solid var(--err); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.ko-item:hover, .ko-item:focus-visible { border-color: var(--err); background: var(--surface-2); outline: none; }
.ko-item > .badge { grid-area: badge; justify-self: start; }
.ko-item > svg { grid-area: ico; width: 16px; height: 16px; color: var(--muted); }
.ko-name { grid-area: name; min-width: 0; font: 12.5px var(--mono); overflow-wrap: anywhere; }
.ko-name code { color: var(--primary); font: inherit; }
.ko-msg { grid-area: msg; min-width: 0; color: var(--err); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ko-trace { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--code-bg); font: 11.5px/1.5 var(--mono); white-space: pre; overflow: auto; max-height: 340px; }
.ko-trace .own { color: var(--text); font-weight: 700; }
.ko-trace .lib { color: var(--muted); }
.ko-modal .test-message { padding: 10px 12px; border-radius: 8px; background: var(--err-bg); }
@media (max-width: 640px) { .ko-item { grid-template-areas: "badge ico" "name name" "msg msg"; grid-template-columns: auto auto; justify-content: space-between; } }
.test-failure { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: var(--surface); }
.test-failure summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.test-message { margin: 8px 0; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--err); }
@media (max-width: 640px) { .test-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .test-card .card-foot .btn { flex: 1; justify-content: center; } }
.deploy-block { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: border-color .15s; }
.deploy-block.has-selection { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.deploy-block-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); cursor: pointer; }
.deploy-block-head > input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--primary); cursor: pointer; }
.deploy-block-head .layer-ico { width: 32px; height: 32px; }
.deploy-block-head .layer-ico svg { width: 17px; height: 17px; }
.deploy-block-title { display: grid; flex: 1; min-width: 0; }
.deploy-block-title small { color: var(--muted); font-size: 12px; }
.deploy-block-body { padding: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.deploy-block-head .layer-ico { background: var(--surface); border: 1px solid var(--border); }
.svc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.svc { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.svc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.svc-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.svc-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.svc-icon svg { width: 19px; height: 19px; }
.svc-name strong { display: block; }
.svc-name small { color: var(--muted); font-size: 12px; }
.svc-detail { color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; min-height: 1.5em; }
.svc-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12px; }
.svc-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--border); }
.svc.s-border-ERREUR { border-color: color-mix(in srgb, var(--err) 45%, var(--border)); }
.svc.s-border-DEGRADE { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.blocked { font-size: 12px; color: var(--warn); }

/* Étapes de job */
.job-head { display: grid; gap: 6px; }
.progress { height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #8d73ff); border-radius: inherit; transition: width 0.3s; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.step { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.step-row { display: grid; grid-template-columns: 54px 26px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; }
.step-row:hover { background: var(--surface-2); }
.step-num { color: var(--muted); font: 600 12px var(--mono); }
.step-ico { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 800; background: var(--idle-bg); color: var(--idle); }
.step.SUCCES .step-ico { background: var(--ok-bg); color: var(--ok); }
.step.EN_COURS .step-ico { background: var(--info-bg); color: var(--info); }
.step.EN_COURS .step-ico::after { content: ''; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.step.ERREUR .step-ico { background: var(--err-bg); color: var(--err); }
.step.AVERTISSEMENT .step-ico { background: var(--warn-bg); color: var(--warn); }
.step-label { min-width: 0; }
.step-label strong { display: block; font-weight: 600; }
.step-label small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-time { color: var(--muted); font: 12px var(--mono); white-space: nowrap; }
.step-body { display: grid; gap: 10px; padding: 0 14px 14px; border-top: 1px dashed var(--border); }
.step-body .kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; padding-top: 12px; font-size: 13px; }
.step-body .kv dt { color: var(--muted); }
.step-body .kv dd { margin: 0; overflow-wrap: anywhere; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Console de logs */
.logbox { position: relative; max-height: 420px; overflow: auto; padding: 10px 0; border-radius: 10px; background: #14131b; color: #d9d6e6; font: 12px/1.55 var(--mono); }
.logbox.tall { max-height: calc(100vh - 260px); min-height: 320px; }
.logline { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.logline.nots { grid-template-columns: 1fr; }
.logline time { color: #6f6b86; }
.logline.cmd { color: #b7a8ff; font-weight: 600; }
.logline.error { color: #ff8f80; }
.logline.warn { color: #f0c46a; }
.logline.debug { color: #8a86a0; }
.logline mark { background: #5b3fd9; color: #fff; border-radius: 2px; }

/* Arbre */
.tree { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree-node { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.tree-node:hover { background: var(--surface-2); }
.tree-node.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-node svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); }
.tree-node .tw { width: 14px; display: inline-grid; place-items: center; color: var(--muted); font-size: 10px; }
.tree-node small { margin-left: auto; color: var(--muted); }

/* Tiroir / modale / toast */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgb(15 10 40 / 0.45); display: grid; place-items: center; padding: 16px; animation: fade 0.15s; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); }
.modal.lg { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 20px; overflow: auto; display: grid; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.drawer-wrap { position: fixed; inset: 0; z-index: 45; background: rgb(15 10 40 / 0.35); animation: fade 0.15s; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(920px, 100%); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lg); animation: slide 0.2s; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg); animation: slide 0.2s; }
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.cmd-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cmd-list li { padding: 8px 10px; border-radius: 8px; background: var(--code-bg); font: 12.5px var(--mono); overflow-wrap: anywhere; }
.cmd-list li.danger { background: var(--err-bg); color: var(--err); }

/* Onglets */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Connexion */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #e5dfff 0%, transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 28px; display: grid; gap: 16px; }
.auth-card h1 { margin: 0; font-size: 20px; }

/* ── SQL ── */
.sql-layout { --sql-side-w: 300px; display: grid; grid-template-columns: var(--sql-side-w) 10px minmax(0, 1fr); gap: 0 6px;
  height: calc(100vh - var(--topbar) - 48px); min-height: 480px; }
.sql-layout.sans-side { grid-template-columns: minmax(0, 1fr); }
.sql-layout.sans-side > .sql-side, .sql-layout.sans-side > .sql-split--v { display: none; }
.sql-side { display: flex; flex-direction: column; min-height: 0; }
.sql-main > .stack { display: flex; flex-direction: column; gap: 0; min-height: 0; flex: none; }
.sql-editor-pane { flex: none; min-height: 120px; display: flex; }
.sql-editor-pane > .editor { flex: 1; height: auto; min-height: 0; resize: none; }
.sql-results { flex: 1; min-height: 0; overflow: auto; padding-right: 2px; }
/* Onglets de résultats (fermables, clic molette pour fermer) */
.sql-onglets-barre { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; background: var(--bg); }
.sql-onglets { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; min-width: 0; padding-top: 6px; }
/* Chaque onglet a son fond de couleur (cycle de 6) ; l'onglet actif est plein et plus foncé. */
.sql-onglet { --tab: #1d4ed8; --tab-bg: #dbeafe; display: inline-flex; align-items: center; gap: 2px; max-width: 240px; flex: none;
  border: 1px solid var(--tab); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--tab-bg); box-shadow: inset 0 3px 0 var(--tab); }
.sql-onglet:nth-child(6n + 2) { --tab: #0f766e; --tab-bg: #ccfbf1; }
.sql-onglet:nth-child(6n + 3) { --tab: #c2410c; --tab-bg: #ffedd5; }
.sql-onglet:nth-child(6n + 4) { --tab: #6d28d9; --tab-bg: #ede9fe; }
.sql-onglet:nth-child(6n + 5) { --tab: #be123c; --tab-bg: #ffe4e6; }
.sql-onglet:nth-child(6n + 6) { --tab: #a16207; --tab-bg: #fef9c3; }
.sql-onglet.active { background: var(--tab); box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.18); }
.sql-onglet-titre { border: 0; background: none; color: var(--tab); font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 8px 4px 8px 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; font-family: var(--mono, monospace); }
.sql-onglet.active .sql-onglet-titre { color: #fff; }
.sql-onglet-fermer { border: 0; background: none; width: 22px; height: 22px; margin-inline-end: 4px; border-radius: 6px;
  display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--tab); }
.sql-onglet.active .sql-onglet-fermer { color: #fff; }
.sql-onglet-fermer:hover { background: rgba(0, 0, 0, 0.1); }
.sql-onglet.active .sql-onglet-fermer:hover { background: rgba(255, 255, 255, 0.25); }
/* Résultat d'une jointure : une bande de couleur par table et une bordure entre les tables */
.rgrid .tdeb { border-left: 3px solid var(--primary) !important; }
.rgrid--tables .rgrid-groupes th { height: 26px; box-sizing: border-box; }
.rgrid--tables thead tr:nth-child(2) th { top: 26px; }
.rgrid-groupes th { font-size: 11.5px; font-weight: 700; text-align: start; padding: 4px 8px; white-space: nowrap; font-family: var(--mono, monospace); }
.rgrid-groupes .grp-0 { background: #dbeafe; color: #1d4ed8; }
.rgrid-groupes .grp-1 { background: #ccfbf1; color: #0f766e; }
.rgrid-groupes .grp-2 { background: #ffedd5; color: #c2410c; }
.rgrid-groupes .grp-3 { background: #ede9fe; color: #6d28d9; }
.rgrid-groupes .grp-4 { background: #ffe4e6; color: #be123c; }
.rgrid-groupes .grp-5 { background: #fef9c3; color: #a16207; }
.sql-lignes-max { flex: none; padding: 4px 0; }
.sql-onglet-corps { padding-top: 8px; }
.sql-split { position: relative; flex: none; touch-action: none; user-select: none; }
.sql-split::after { content: ''; position: absolute; border-radius: 99px; background: var(--border-strong); transition: background 0.15s; }
.sql-split:hover::after, .sql-split:focus-visible::after { background: var(--primary); }
.sql-split:focus-visible { outline: none; }
.sql-split--h { height: 14px; cursor: row-resize; }
.sql-split--h::after { left: 50%; top: 5px; width: 56px; height: 4px; transform: translateX(-50%); }
.sql-split--v { cursor: col-resize; }
.sql-split--v::after { top: 50%; left: 3px; width: 4px; height: 56px; transform: translateY(-50%); }
body.is-dragging-y, body.is-dragging-y * { cursor: row-resize !important; user-select: none; }
body.is-dragging-x, body.is-dragging-x * { cursor: col-resize !important; user-select: none; }
.sql-side .tree-scroll { overflow: auto; padding: 8px; flex: 1; }
.sql-layout > section, .sql-layout > aside { min-width: 0; }
.sql-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.editor { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); min-height: 220px; height: 280px; resize: vertical; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--code-bg); }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.editor-gutter { padding: 10px 6px 10px 0; text-align: right; color: var(--muted); font: 13px/20px var(--mono); user-select: none; overflow: hidden; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--code-bg) 80%, var(--surface)); }
.editor-area { position: relative; overflow: hidden; }
.editor-hl, .editor-input {
  position: absolute; inset: 0; margin: 0; padding: 10px 12px; border: 0; font: 13px/20px var(--mono); white-space: pre; tab-size: 4;
  overflow: auto; letter-spacing: 0; word-spacing: 0;
}
.editor-hl { pointer-events: none; color: var(--sql-id); overflow: hidden; }
.editor-input { background: transparent; color: transparent; caret-color: var(--text); resize: none; outline: none; }
.editor-input::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); color: transparent; }
.tk-kw { color: var(--sql-kw); font-weight: 650; }
.tk-str { color: var(--sql-str); }
.tk-num { color: var(--sql-num); }
.tk-cmt { color: var(--sql-cmt); font-style: italic; }
.tk-fn { color: var(--sql-fn); }
.tk-type { color: var(--sql-type); }
.tk-op { color: var(--sql-op); }
.tk-err { text-decoration: wavy underline var(--err); }
.complete {
  position: fixed; z-index: 70; min-width: 260px; max-width: 460px; max-height: 260px; overflow: auto; padding: 4px; margin: 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); font: 12.5px var(--mono);
}
.complete li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.complete li.active { background: var(--primary-soft); color: var(--primary); }
.complete li .k { width: 18px; flex-shrink: 0; text-align: center; border-radius: 4px; font-size: 10.5px; font-weight: 800; color: #fff; }
.complete li .k.t { background: #1f5fbf; } .complete li .k.c { background: #0c7a4c; } .complete li .k.f { background: #a0337a; }
.complete li .k.k { background: #6a37d6; } .complete li .k.s { background: #b4561a; } .complete li .k.d { background: #93590a; }
.complete li small { margin-left: auto; color: var(--muted); }
.result-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.grid-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.rgrid { border-collapse: separate; border-spacing: 0; font: 12.5px var(--mono); min-width: 100%; }
.rgrid th { position: sticky; top: 0; z-index: 2; padding: 7px 10px; background: var(--surface-2); text-align: left; border-bottom: 1px solid var(--border-strong); border-right: 1px solid var(--border); white-space: nowrap; font-family: var(--font); }
.rgrid th small { display: block; color: var(--muted); font-weight: 500; font-family: var(--mono); font-size: 10.5px; }
.rgrid th.rn, .rgrid td.rn { position: sticky; left: 0; z-index: 1; background: var(--surface-2); color: var(--muted); text-align: right; min-width: 44px; }
.rgrid th.rn { z-index: 3; }
.rgrid td { padding: 5px 10px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rgrid td.num { text-align: right; }
.rgrid td.null { color: var(--muted); font-style: italic; }
.rgrid td.edited { background: var(--warn-bg); }
.rgrid td.editable { cursor: cell; }
.rgrid td input { width: 100%; min-width: 120px; border: 1px solid var(--primary); border-radius: 4px; padding: 2px 4px; font: inherit; background: var(--surface); }
.rgrid tr:hover td { background: var(--surface-2); }
.rgrid td.bool { text-align: left; }
.cell-bool { display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px; cursor: inherit; }
.rgrid td .cell-bool input { width: 16px; height: 16px; min-width: 0; padding: 0; border: 0; margin: 0; accent-color: var(--primary); cursor: pointer; }
.rgrid td .cell-bool input:disabled { cursor: default; }
.rgrid td.null .cell-bool span { font-style: italic; }
.rgrid td.structured { cursor: zoom-in; }
.cell-tag { margin-right: 6px; padding: 0 5px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface-2); color: var(--primary); font: 600 10px var(--font); letter-spacing: .03em; cursor: pointer; vertical-align: 1px; }
.cell-tag:hover { border-color: var(--primary); }
textarea.input.code-area { width: 100%; height: min(52vh, 520px); min-height: 200px; resize: vertical; font: 12.5px/1.55 var(--mono); white-space: pre; tab-size: 2; }
.text-err { color: var(--err); font-weight: 600; }
@media (max-width: 640px) { textarea.input.code-area { height: 46vh; font-size: 12px; } }
.rgrid tr:hover td.edited { background: var(--warn-bg); }

/* ── Responsive ── */
/* Console Git */
.git-prompt { display: flex; align-items: stretch; gap: 8px; }
.git-prefix { display: grid; place-items: center; padding: 0 12px; border-radius: 10px; background: var(--code-bg); color: var(--primary); font: 700 13px var(--mono); }
.git-input { flex: 1; min-width: 0; font: 13px var(--mono); }
.git-presets { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.git-presets h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.git-chips { display: grid; gap: 4px; }
.git-chip { display: grid; gap: 1px; padding: 5px 9px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 8px; background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.git-chip code { font: 11.5px var(--mono); overflow-wrap: anywhere; }
.git-chip small { font-size: 11px; color: var(--muted); }
.git-chip:hover:not(:disabled), .git-chip:focus-visible { background: var(--surface-2); border-color: var(--primary); outline: none; }
.git-chip:disabled { opacity: .45; cursor: not-allowed; }
.git-chip.k-read { border-left-color: var(--ok); }
.git-chip.k-write { border-left-color: var(--warn); }
.git-chip.k-destructive { border-left-color: var(--err); }
.git-presets-box > summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 4px 0 10px; }
.git-output { max-height: 560px; overflow: auto; }
.git-output:empty::before { content: 'Les résultats des commandes s’affichent ici (la plus récente en haut).'; color: var(--muted); font-size: 12.5px; }
.git-run { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.git-run.is-running { opacity: .7; }
.git-run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.git-run-head code { font: 600 12px var(--mono); overflow-wrap: anywhere; }
.git-out { margin: 0; padding: 10px 12px; background: var(--code-bg); font: 12px/1.5 var(--mono); white-space: pre; overflow: auto; max-height: 420px; }
.git-out.is-error { color: var(--err); white-space: pre-wrap; }
@media (max-width: 640px) { .git-prompt { flex-wrap: wrap; } .git-prompt .btn { width: 100%; justify-content: center; } }

/* Abréviations de l'éditeur SQL */
.info-btn { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px; padding: 0; border: 1.5px solid var(--primary); border-radius: 50%; background: none; color: var(--primary); font: italic 700 11px/1 Georgia, serif; cursor: pointer; vertical-align: -3px; }
.info-btn:hover, .info-btn:focus-visible { background: var(--primary); color: #fff; outline: none; }
kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 11px var(--mono); color: var(--text); white-space: nowrap; }
.snip-group h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.snip-list { display: grid; gap: 4px; }
.snip-item { display: grid; grid-template-columns: 64px minmax(140px, 220px) minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); text-align: left; font: inherit; font-size: 12.5px; cursor: pointer; }
.snip-item:hover, .snip-item:focus-visible { border-color: var(--border); background: var(--surface-2); outline: none; }
.snip-item.static { cursor: default; grid-template-columns: 130px minmax(0, 1fr); }
.snip-item.static:hover { border-color: transparent; background: none; }
.snip-item kbd { justify-self: start; }
.snip-item code { font: 11.5px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.complete .k.x { color: var(--warn); }
@media (max-width: 640px) {
  .snip-item { grid-template-columns: 56px minmax(0, 1fr); }
  .snip-item code { grid-column: 1 / -1; }
}

/* Schéma de travail de l'éditeur SQL */
.schema-box:empty { display: none; }
.schema-pick { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.schema-pick svg, .schema-chip svg { width: 15px; height: 15px; }
.schema-pick .input { width: auto; max-width: 240px; }
.schema-chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; font-size: 13px; }
.tree-node.is-current { color: var(--primary); font-weight: 600; }

/* Historique SQL : 100 dernières requêtes réussies + épinglées */
.tab { display: inline-flex; align-items: center; gap: 6px; }
.tab svg { width: 15px; height: 15px; }
.sql-hist-modal { height: auto; max-height: calc(100vh - 48px); }
.sql-hist-actions .btn-icon { width: 26px; height: 26px; }
.sql-hist-actions svg { width: 14px; height: 14px; }
.sql-hist-modal .modal-body { align-content: start; }
.sql-hist-tools { display: flex; gap: 8px; align-items: center; }
.sql-hist-tools .input { flex: 1; min-width: 0; }
.sql-hist-list { display: grid; gap: 6px; }
.sql-hist-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
.sql-hist-pager:empty { display: none; }
.sql-hist-item { display: grid; gap: 4px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.sql-hist-item:hover, .sql-hist-item:focus-visible { border-color: var(--primary); background: var(--surface-2); outline: none; }
.sql-hist-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 11.5px; }
.sql-hist-meta .badge { font-size: 10.5px; padding: 1px 7px; }
.sql-hist-title { font-size: 12.5px; }
.sql-hist-actions { margin-left: auto; display: flex; gap: 2px; }
.sql-hist-actions .is-on { color: var(--primary); opacity: 1; }
.sql-snippet { margin: 0; padding: 6px 9px; border-radius: 8px; background: var(--code-bg); font: 11.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.6em; overflow: hidden; }
@media (max-width: 640px) {
  .sql-hist-modal { max-height: calc(100vh - 16px); }
  .sql-hist-actions .btn-icon { width: 36px; height: 36px; }
}

@media (max-width: 1100px) {
  .sql-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .sql-layout > .sql-split--v { display: none; }
  .sql-side { position: static; max-height: 360px; order: 2; }
  .sql-results { overflow: visible; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 40; left: 0; width: min(290px, 85vw); transform: translateX(-102%); transition: transform 0.2s; box-shadow: none; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .content { padding: 16px 12px; gap: 14px; }
  .topbar .hide-sm { display: none; }
  .topbar h1 { font-size: 15px; }
  .topbar select.input { max-width: 96px; padding-left: 6px; padding-right: 2px; }
  .topbar .pill { padding: 0 8px; }
  .topbar .pill .badge { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .step-row { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .step-num, .step-row .step-dur { display: none; }
  .step-body .kv { grid-template-columns: 1fr; }
  .diagnostic dl { grid-template-columns: 1fr; }
  .logline { grid-template-columns: 1fr; }
  .logline time { display: none; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Console Git : complétion, aide, assistant reset */
.git-saisie { position: relative; flex: 1; min-width: 0; display: flex; }
.git-saisie .git-input { flex: 1; }
.git-suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; margin: 0; padding: 4px; list-style: none; max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-lg); }
.git-suggest li { display: flex; align-items: baseline; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.git-suggest li code { font: 12.5px var(--mono); color: var(--text); flex: none; }
.git-suggest li small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-suggest li.is-active, .git-suggest li:hover { background: var(--primary-soft); }
.git-reset { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.git-reset select { width: auto; max-width: 100%; }
.git-reset-preview { padding: 6px 10px; border-radius: 8px; background: var(--code-bg); font: 12.5px var(--mono); }
.git-reset-preview.danger, .git-reset-table .danger strong { color: var(--err); }
.git-reset-table { display: grid; gap: 6px; }
.git-reset-table > div { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 10px; font-size: 13px; }
.git-reset-table strong { font-family: var(--mono); }
.snip-item.git-ex { grid-template-columns: minmax(200px, 240px) minmax(0, 1fr); }
.snip-item.git-ex code { color: var(--text); }

/* Git : lieux (dépôt distant / local) et choix du dépôt */
.git-lieux { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; align-items: center; margin-top: 12px; }
.git-lieux a { display: inline-flex; align-items: center; gap: 4px; overflow-wrap: anywhere; }
.git-lieux a svg { width: 13px; height: 13px; }
.git-lieux code { font: 12px var(--mono); overflow-wrap: anywhere; }
@media (max-width: 640px) { .git-lieux { grid-template-columns: minmax(0, 1fr); } .git-lieux > .muted { margin-top: 6px; } }
.git-depot { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.git-depot:hover, .git-depot:focus-visible { border-color: var(--primary); outline: none; }
.git-depot.is-active { border-color: var(--primary); background: var(--primary-soft); }
.git-depot code { font: 12.5px var(--mono); overflow-wrap: anywhere; }
.git-depot small { color: var(--muted); }

/* Page Applications : tuiles de liens */
.section-title { margin: 6px 0 0; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.app-links { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.app-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
.app-link:hover { border-color: var(--primary); transform: translateY(-1px); }
.app-link__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.app-link__txt { display: grid; gap: 2px; min-width: 0; }
.app-link__txt code { color: var(--muted); }
.app-link__ext { color: var(--muted); }
.dash-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Déployer : onglets, modes, interrupteurs, versions, rétention ── */
.seg-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow-x: auto; scrollbar-width: none; }
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tab { display: inline-flex; align-items: center; gap: 7px; flex: 1 0 auto; justify-content: center; min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 650; cursor: pointer; white-space: nowrap; }
.seg-tab svg { width: 16px; height: 16px; }
.seg-tab:hover { color: var(--text); background: var(--surface-2); }
.seg-tab.active { background: var(--primary); color: var(--on-primary); }
.seg-tab .count { padding: 0 7px; border-radius: 99px; background: color-mix(in srgb, currentColor 16%, transparent); font-size: 11px; }

.dep-summary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.dep-stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 0; }
.dep-stat > span { color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.dep-stat > strong { font-size: 15px; overflow-wrap: anywhere; }
.dep-stat > small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.dep-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .dep-layout { grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr); } .dep-aside { position: sticky; top: calc(var(--topbar) + 16px); } }
.dep-aside .card-body { max-height: calc(100vh - 300px); overflow: auto; }
@media (max-width: 1099px) { .dep-aside .card-body { max-height: none; } }

.mode-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.mode-card { position: relative; display: grid; gap: 6px; padding: 16px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface); text-align: start; color: var(--text); font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.mode-card:hover { border-color: var(--border-strong); }
.mode-card.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.mode-card.zero.active { border-color: var(--warn); background: color-mix(in srgb, var(--warn-bg) 60%, var(--surface)); }
.mode-card-head { display: flex; align-items: center; gap: 10px; }
.mode-card-head .layer-ico { width: 34px; height: 34px; }
.mode-card-head strong { font-size: 15px; }
.mode-card small { color: var(--muted); }
.mode-card ul { margin: 2px 0 0; padding-inline-start: 18px; color: var(--text-2); font-size: 12.5px; }
.mode-card .tag { position: absolute; top: 12px; inset-inline-end: 12px; }

.switch-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; }
.switch-row.off-warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); background: color-mix(in srgb, var(--warn-bg) 50%, var(--surface)); }
.switch-row > div { flex: 1; min-width: 0; }
.switch-row strong { display: block; }
.switch-row small { color: var(--muted); }
.switch { position: relative; flex: none; width: 42px; height: 24px; margin-top: 1px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background .15s; pointer-events: none; }
.switch i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
[dir='rtl'] .switch input:checked + i::after { transform: translateX(-18px); }
.switch input:focus-visible + i { outline: 2px solid var(--primary); outline-offset: 2px; }

.suite-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suite-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }

.zero-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: z; }
.zero-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 13px; }
.zero-list li::before { counter-increment: z; content: counter(z); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--warn-bg); color: var(--warn); font-weight: 800; font-size: 11.5px; }

.mod-choice { position: relative; }
.mod-choice .mod-zero { margin-inline-start: auto; }
.launch-bar { display: grid; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.launch-bar .btn { width: 100%; min-height: 44px; font-size: 14.5px; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover:not(:disabled) { background: color-mix(in srgb, var(--warn) 85%, #000); border-color: var(--warn); }
:root[data-theme='dark'] .btn-warn { color: #1d1b2c; }

.ver-list { display: grid; gap: 10px; }
.ver { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.ver.current { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); box-shadow: inset 4px 0 0 var(--ok); }
.ver-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ver-title strong { font: 700 14px var(--mono); }
.ver-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; }
.ver-meta code { color: var(--text-2); }
.ver-mods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ver-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
@media (max-width: 640px) {
  .ver { grid-template-columns: minmax(0, 1fr); }
  .ver-actions { justify-content: stretch; }
  .ver-actions .btn { flex: 1; }
}

.ret-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.ret-cat { display: grid; gap: 6px; align-content: start; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.ret-cat strong { font-size: 14px; }
.ret-cat .big { font-size: 22px; font-weight: 800; line-height: 1.1; }
.ret-cat small { color: var(--muted); }
.ret-bar { height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.ret-bar i { display: block; height: 100%; background: var(--warn); }
.ret-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.ret-form .input { max-width: 100%; }
@media (max-width: 640px) {
  .seg-tab { flex: 1 0 auto; padding: 0 10px; }
  .launch-bar { padding: 12px 14px; }
}

/* Mobile : indicateurs compacts, barre d'action fixe, plan repliable, barre du haut sans débordement */
.avatar { display: none; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 12px; }
.plan-toggle { display: none; }
@media (max-width: 1099px) {
  .dep-aside.collapsed .card-body { display: none; }
  .plan-toggle { display: inline-flex; }
  .dep-pane .launch-bar { position: fixed; z-index: 30; inset-inline: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgb(30 20 80 / .08); }
  .dep-pane .launch-bar small { display: none; }
  .dep-pane { padding-bottom: 84px; }
}
@media (min-width: 861px) and (max-width: 1099px) { .dep-pane .launch-bar { inset-inline-start: var(--sidebar); } }
@media (max-width: 640px) {
  .dep-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dep-stat { padding: 10px 12px; }
  .dep-stat > strong { font-size: 13.5px; }
  .dep-stat > small { font-size: 11.5px; }
  .seg-tab .tab-long { display: none; }
  .topbar .pill.user-pill { padding: 0 4px; border: 0; background: none; }
  .topbar .pill.user-pill .badge { display: none; }
  .topbar .pill.user-pill .avatar { display: grid; }
  .card-head { padding-top: 12px; padding-bottom: 12px; }
  .mode-card { padding: 14px; }
}
@media (min-width: 641px) { .seg-tab .tab-short { display: none; } }

/* Menu : groupes par usage, repliables */
.side { gap: 2px; }
.nav-group { margin-top: 6px; }
.nav-group:first-of-type { margin-top: 0; }
.nav-links { display: grid; gap: 1px; }
.nav-head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 10px 6px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.nav-head:hover { color: var(--text); background: var(--surface-2); }
.nav-chev { width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.nav-group.folded .nav-chev { transform: rotate(-45deg); }
[dir='rtl'] .nav-group.folded .nav-chev { transform: rotate(135deg); }
.nav-group.folded .nav-links { display: none; }
.nav-group + .nav-group { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); padding-top: 6px; }
.nav-link { min-height: 36px; }

/* Charte graphique intégrée */
.charte-frame iframe { display: block; width: 100%; height: calc(100dvh - var(--topbar) - 200px); min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
@media (max-width: 640px) { .charte-frame iframe { height: calc(100dvh - var(--topbar) - 170px); min-height: 420px; } }

/* Structure (explorateur) : arbre + détail, une colonne sur mobile */
.explorer-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .explorer-layout { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); } .explorer-side { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100vh - var(--topbar) - 40px); } }
.explorer-side { display: flex; flex-direction: column; min-height: 0; }
.explorer-side .tree-scroll { overflow: auto; padding: 8px; flex: 1; min-height: 0; }
@media (max-width: 899px) { .explorer-side .tree-scroll { max-height: 340px; } }
.explorer-main { min-width: 0; display: grid; gap: 16px; align-content: start; }
.schema-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.schema-card { display: grid; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.schema-card strong svg { vertical-align: -3px; color: var(--primary); }
.schema-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.schema-stat { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "ico n" "ico l"; gap: 0 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface); }
.schema-stat svg { grid-area: ico; color: var(--muted); }
.schema-stat strong { grid-area: n; font-size: 18px; line-height: 1.1; }
.schema-stat span { grid-area: l; color: var(--muted); font-size: 12px; }
.schema-stat.zero strong { color: var(--muted); }
.mode-card { align-content: start; }

/* Planification et changements */
.ver.plan-off { opacity: .65; }
.day-chip { padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.day-chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.day-chip input { position: absolute; opacity: 0; pointer-events: none; }
.chg-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn-bg) 70%, var(--surface)); color: var(--text); }
.chg-banner > svg { width: 20px; height: 20px; color: var(--warn); flex: none; }
.chg-banner > div { flex: 1 1 260px; min-width: 0; }
.chg-banner strong { display: block; }
.chg-banner small { color: var(--text-2); }
.chg-banner.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: color-mix(in srgb, var(--ok-bg) 60%, var(--surface)); }
.chg-banner.ok > svg { color: var(--ok); }
.chg-dot { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 750; }
.chg-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.launch-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.launch-row .btn:last-child { min-height: 44px; }

/* États vides : une icône discrète au-dessus du message */
.empty > svg { display: block; width: 40px; height: 40px; margin: 0 auto 10px; color: var(--muted); opacity: .7; }
.empty p { margin: 0 0 4px; font-weight: 600; color: var(--text-2); }

/* Aucun bloc de page ne doit élargir l'écran (longues lignes de code, JSON, chemins) */
.content > .view > * { min-width: 0; }
pre.logbox { white-space: pre-wrap; overflow-wrap: anywhere; }
