/* ================================================================
   DESIGN SYSTEM — Agent PHP Standalone — Thème clair professionnel
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #F5F7FA;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;
  --border:       #E2E8F0;
  --border-2:     #CBD5E1;
  --primary:      #2563EB;
  --primary-light:#DBEAFE;
  --primary-hover:#1D4ED8;
  --success:      #16A34A;
  --success-bg:   #DCFCE7;
  --warning:      #D97706;
  --warning-bg:   #FEF3C7;
  --error:        #DC2626;
  --error-bg:     #FEE2E2;
  --info:         #0284C7;
  --info-bg:      #E0F2FE;
  --text:         #0F172A;
  --text-2:       #475569;
  --text-3:       #94A3B8;
  --mono:         'Consolas', 'Cascadia Code', 'Fira Code', monospace;
  --radius:       12px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg:    0 4px 24px rgba(0,0,0,0.10);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column; line-height: 1.6;
}

/* TOPBAR */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 30px; height: 61px;
  display: flex; align-items: center; gap: 20px;
  position: sticky; top: 0; z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-icon {
  width: 37px; height: 37px; background: var(--primary);
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.brand-sub  { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }
.sep { width: 1px; height: 32px; background: var(--border); }
.topbar-tabs { display: flex; gap: 4px; flex: 1; }
.tab-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 17px; border-radius: 9px;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; border: none; background: transparent; color: var(--text-2); transition: all 0.15s;
}
.tab-btn.active { background: var(--primary-light); color: var(--primary); }
.tab-btn:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.tab-badge {
  background: var(--primary); color: #fff;
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
.tab-badge.green  { background: var(--success); }
.tab-badge.orange { background: var(--warning); }
.pill-paused  { background: var(--warning-bg);  color: var(--warning); }
.pill-waiting { background: #F3F4F6;             color: #374151; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 15px; border-radius: 100px;
  font-size: 0.82rem; font-weight: 600;
}
.pill-ready   { background: var(--info-bg);       color: var(--info); }
.pill-running { background: var(--primary-light);  color: var(--primary); }
.pill-done    { background: var(--success-bg);     color: var(--success); }
.pill-error   { background: var(--error-bg);       color: var(--error); }
.dot-anim {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: dotpulse 2s ease-in-out infinite;
}
@keyframes dotpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* LAYOUT */
.screens { flex: 1; }
.screen { display: none; }
.screen.active { display: block; }
.main {
  max-width: 1100px; width: 100%;
  margin: 0 auto; padding: 30px 27px;
}

/* CARDS & FORMS */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 25px 27px;
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-title {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
  margin-bottom: 5px; display: flex; align-items: center; gap: 10px;
}
.card-sub { font-size: 0.82rem; color: var(--text-2); margin-bottom: 19px; }
.card-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-blue   { background: var(--primary-light); }
.icon-green  { background: var(--success-bg); }
.icon-orange { background: var(--warning-bg); }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px 24px; }
.form-group  { display: flex; flex-direction: column; gap: 6px; }
label {
  font-size: 0.9rem; font-weight: 600; color: var(--text);
  display: flex; justify-content: space-between; align-items: center;
}
.label-hint { font-size: 0.8rem; font-weight: 400; color: var(--text-3); }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
select {
  width: 100%; padding: 10px 14px;
  font-size: 0.88rem; border: 1px solid var(--border-2);
  border-radius: 8px; background: var(--surface); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit;
}
input:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.input-group { position: relative; display: flex; }
.input-group input { padding-right: 50px; }
.input-toggle {
  position: absolute; right: 1px; top: 50%; transform: translateY(-50%);
  width: 46px; height: calc(100% - 2px);
  border: none; background: transparent; cursor: pointer;
  font-size: 1rem; color: var(--text-3); border-radius: 0 7px 7px 0;
  display: flex; align-items: center; justify-content: center;
}
.input-toggle:hover { color: var(--text); background: var(--surface-2); }
.field-success {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.88rem; color: var(--success); margin-top: 5px;
}

/* BOUTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 19px; border-radius: 9px;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { background: var(--border-2); border-color: var(--border-2); color: var(--text-3); cursor: not-allowed; opacity: 0.7; }
.btn-primary:disabled:hover { background: var(--border-2); border-color: var(--border-2); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger  { background: var(--error-bg); color: var(--error); border-color: #FECACA; }
.btn-danger:hover { background: var(--error); color: #fff; }
.btn-lg { padding: 12px 27px; font-size: 0.88rem; }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn-test {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 17px; border-radius: 9px; font-size: 0.82rem; font-weight: 600;
  border: 1px solid var(--primary-light); background: var(--primary-light); color: var(--primary);
  cursor: pointer; transition: all 0.15s; margin-top: 2px;
}
.btn-test:hover { background: var(--primary); color: #fff; }
.btn-test:disabled {
  opacity: 0.45; cursor: not-allowed;
}
.btn-test:disabled:hover { background: var(--primary-light); color: var(--primary); }

.info-box {
  background: var(--info-bg); border: 1px solid #BAE6FD; border-radius: 10px;
  padding: 14px 15px; display: flex; gap: 12px; align-items: flex-start;
  font-size: 0.82rem; color: var(--info); margin-bottom: 19px;
}
.info-box svg { flex-shrink: 0; margin-top: 1px; }
.divider { height: 1px; background: var(--border); margin: 22px 0; }

/* CONFIGURATION SCREEN */
.config-header { text-align: center; padding: 32px 20px 26px; }
.config-header h1 { font-size: 1.44rem; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.config-header p  { font-size: 0.88rem; color: var(--text-2); max-width: 560px; margin: 0 auto; }

.config-steps {
  display: flex; justify-content: center; align-items: flex-start;
  gap: 0; max-width: 700px; margin: 0 auto 34px;
}
.config-step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.config-step:not(:last-child)::after {
  content: ''; position: absolute; top: 20px; left: 50%;
  width: 100%; height: 2px; background: var(--border-2); z-index: 0;
}
.config-step.done:not(:last-child)::after  { background: var(--success); }
.step-circle {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700;
  border: 2px solid var(--border-2); background: var(--surface); color: var(--text-3);
  position: relative; z-index: 1; transition: all 0.2s; margin-bottom: 8px;
}
.step-circle.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.step-circle.done   { border-color: var(--success); background: var(--success); color: #fff; }
.step-label { font-size: 0.82rem; font-weight: 600; color: var(--text-3); text-align: center; }
.step-label.active { color: var(--primary); }
.step-label.done   { color: var(--success); }

/* MONITORING */
.monitor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; margin-bottom: 19px; }
.server-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 19px;
  display: flex; align-items: flex-start; gap: 14px; box-shadow: var(--shadow);
}
.server-card-body { flex: 1; min-width: 0; }
.server-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-3); margin-bottom: 4px;
}
.server-host   { font-size: 0.88rem; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.server-detail { font-size: 0.82rem; color: var(--text-2); font-family: var(--mono); }
.server-status { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--text-2); margin-top: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--success); box-shadow: 0 0 5px var(--success); }
.dot-blue  { background: var(--primary); box-shadow: 0 0 5px var(--primary); }

.phases-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 25px; margin-bottom: 17px; box-shadow: var(--shadow);
}
.phases-row {
  display: grid; grid-template-columns: repeat(5, 1fr);
  position: relative; margin-bottom: 24px;
}
.phases-row::before {
  content: ''; position: absolute;
  top: 21px; left: 10%; right: 10%; height: 2px;
  background: var(--border); z-index: 0;
}
.phase-item { display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 1; }
.phase-circle {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border-2); background: var(--surface); color: var(--text-3);
  font-size: 0.82rem; font-weight: 700; transition: all 0.3s;
}
.phase-circle.done   { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.phase-circle.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 5px rgba(37,99,235,0.12); animation: phase-pulse 2s ease-in-out infinite; }
@keyframes phase-pulse { 0%,100% { box-shadow: 0 0 0 5px rgba(37,99,235,0.12); } 50% { box-shadow: 0 0 0 10px rgba(37,99,235,0.05); } }
.phase-name { font-size: 0.84rem; font-weight: 600; color: var(--text-2); text-align: center; line-height: 1.3; }
.phase-name.active { color: var(--primary); font-weight: 700; }
.phase-name.done   { color: var(--success); }
.phase-dur  { font-size: 0.78rem; color: var(--text-3); font-family: var(--mono); }

.progress-bar-wrap { margin-top: 10px; }
.progress-bar-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.progress-bar-label { font-size: 0.88rem; color: var(--text-2); }
.progress-bar-pct   { font-size: 0.95rem; font-weight: 800; color: var(--text); font-family: var(--mono); }
.progress-bar-bg    { height: 9px; background: var(--border); border-radius: 100px; overflow: hidden; }
.progress-bar-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  background-size: 200% 100%; animation: shimmer 2s linear infinite; transition: width 0.5s ease;
}
@keyframes shimmer { 0%{background-position:0%} 100%{background-position:200%} }
.progress-bar-eta { font-size: 0.84rem; color: var(--text-3); text-align: right; margin-top: 6px; }

.current-op-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--primary); border-radius: var(--radius);
  padding: 17px 22px; display: flex; align-items: center; gap: 17px;
  margin-bottom: 17px; box-shadow: var(--shadow);
}
.op-spinner {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; animation: spin 2s linear infinite;
}
@keyframes spin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
.op-text { flex: 1; min-width: 0; }
.op-action { font-size: 0.88rem; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.op-file   { font-size: 0.85rem; color: var(--text-2); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-stats  { display: flex; gap: 24px; flex-shrink: 0; }
.op-stat   { text-align: right; }
.op-stat-val   { font-size: 0.95rem; font-weight: 800; color: var(--text); font-family: var(--mono); }
.op-stat-label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 19px; }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 19px; box-shadow: var(--shadow);
}
.metric-label { font-size: 0.67rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-3); margin-bottom: 7px; }
.metric-value { font-size: 1.28rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.metric-sub   { font-size: 0.82rem; color: var(--text-2); }
.val-blue   { color: var(--primary); }
.val-green  { color: var(--success); }
.val-orange { color: var(--warning); }
.val-indigo { color: #6366f1; }

/* CONSOLE */
.console-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 20px;
}
.console-header {
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: 14px 19px; display: flex; align-items: center; justify-content: space-between;
}
.console-title-wrap { display: flex; align-items: center; gap: 10px; }
.console-live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); animation: dotpulse 2s ease-in-out infinite; }
.console-title { font-size: 0.88rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-2); }
.console-tools { display: flex; align-items: center; gap: 8px; }
.filter-chip {
  padding: 5px 12px; border-radius: 100px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border-2); background: transparent; color: var(--text-3);
}
.filter-chip.active { background: var(--primary-light); color: var(--primary); border-color: #BFDBFE; }
.filter-chip:hover  { background: var(--surface-2); color: var(--text-2); }
.con-btn {
  padding: 6px 14px; border-radius: 7px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border-2); background: transparent; color: var(--text-2);
}
.con-btn:hover { background: var(--surface-2); }
.console-body {
  height: 374px; overflow-y: auto; padding: 10px 0;
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.8;
  background: #FAFBFD; scrollbar-width: thin;
}
.log-line { display: flex; align-items: baseline; padding: 2px 19px; }
.log-line:hover { background: rgba(37,99,235,0.03); }
.log-ts  { color: var(--text-3); font-size: 0.67rem; flex-shrink: 0; margin-right: 12px; user-select: none; }
.log-lvl {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.4px; flex-shrink: 0;
  margin-right: 12px; min-width: 52px; padding: 1px 6px; border-radius: 4px; text-align: center;
}
.lvl-info { color: var(--info);    background: var(--info-bg); }
.lvl-ok   { color: var(--success); background: var(--success-bg); }
.lvl-warn { color: var(--warning); background: var(--warning-bg); }
.lvl-err  { color: var(--error);   background: var(--error-bg); }
/* CRITICAL = audit M11 (ex: DROP TABLE attendu) — distinct de ERROR
   pour ne pas faire croire à un échec quand l'opérateur a explicitement
   demandé une opération destructive (mode truncate). */
.lvl-crit { color: #92400E;        background: #FEF3C7; }
.lvl-file { color: #7C3AED;        background: #EDE9FE; }
.log-msg  { color: var(--text-2);  word-break: break-all; }
.msg-ok   { color: #15803D; }
.msg-warn { color: #B45309; }
.msg-err  { color: #B91C1C; }
.msg-crit { color: #92400E; font-weight: 600; }
.msg-file { color: #6D28D9; }
.console-footer {
  background: var(--surface-2); border-top: 1px solid var(--border);
  padding: 8px 19px; display: flex; justify-content: space-between; align-items: center;
}
.console-count { font-size: 0.78rem; color: var(--text-3); font-family: var(--mono); }
.autoscroll-label { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; color: var(--text-3); cursor: pointer; }

/* SECURITY BAR */
.security-bar {
  background: #F0F9FF; border: 1px solid #BAE6FD; border-radius: 12px;
  padding: 14px 19px; display: flex; align-items: center; gap: 12px;
  font-size: 0.78rem; color: var(--info);
}
.security-bar-text { flex: 1; color: var(--text-2); }
.security-bar-text strong { color: var(--primary); }
.token-badge {
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid #BFDBFE; border-radius: 7px; padding: 6px 14px; flex-shrink: 0;
}

/* ─── BARRE D'ACTIONS ─────────────────────────── */
.action-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 20px;
  margin-bottom: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.action-bar-status {
  display: flex;
  align-items: center;
  gap: 12px;
}
.state-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 700;
}
.state-running  { background: var(--primary-light); color: var(--primary); }
.state-paused   { background: var(--warning-bg);    color: var(--warning); }
.state-done     { background: var(--success-bg);    color: var(--success); }
.state-error    { background: var(--error-bg);      color: var(--error); }
.state-waiting  { background: #F3F4F6;              color: #374151; }
.state-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.state-dot.anim { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.action-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-action {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 9px;
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid transparent;
  transition: all 0.15s; white-space: nowrap;
  font-family: inherit;
}
.btn-action:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-pause    { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.btn-pause:hover:not(:disabled)    { background: #FCD34D; }
.btn-resume   { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-resume:hover:not(:disabled)   { background: #BFDBFE; }
.btn-restart  { background: #F3F4F6; color: var(--text); border-color: var(--border-2); }
.btn-restart:hover:not(:disabled)  { background: var(--border); }
.btn-cancel   { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.btn-cancel:hover:not(:disabled)   { background: #FECACA; }

/* ─── ÉCRAN TERMINÉ ──────────────────────────── */
.completed-card {
  background: var(--success-bg);
  border: 1.5px solid #86EFAC;
  border-radius: var(--radius);
  padding: 30px 27px;
  text-align: center;
  margin-bottom: 17px;
}
.completed-icon {
  width: 54px; height: 54px;
  background: var(--success);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 15px;
}
.completed-title { font-size: 1.12rem; font-weight: 800; color: var(--success); margin-bottom: 7px; }
.completed-sub   { font-size: 0.9rem;  color: var(--text-2); margin-bottom: 24px; }
.completed-stats {
  display: flex; justify-content: center; gap: 32px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.cstat { text-align: center; }
.cstat-val  { font-size: 1.12rem; font-weight: 800; color: var(--text); }
.cstat-lbl  { font-size: 0.78rem; color: var(--text-2); margin-top: 3px; }
.completed-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ─── ÉCRAN ERREUR ────────────────────────────── */
.error-card {
  background: var(--error-bg);
  border: 1.5px solid #FCA5A5;
  border-radius: var(--radius);
  padding: 24px 27px;
  margin-bottom: 17px;
}
.error-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.error-icon {
  width: 40px; height: 40px; background: var(--error); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.error-title { font-size: 0.95rem; font-weight: 800; color: var(--error); }
.error-code  { font-size: 0.8rem; color: var(--error); opacity: 0.8; margin-top: 3px; font-family: var(--mono); }
.error-msg   { font-size: 0.88rem; color: #7F1D1D; background: #FEE2E2; border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; line-height: 1.6; }
.error-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Modal de confirmation */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 500;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; padding: 32px 28px;
  max-width: 420px; width: calc(100% - 32px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}
.modal-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
.modal-body  { font-size: 0.9rem; color: var(--text-2); line-height: 1.6; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Modale "Parcourir" filesystem — variante plus large que modal-box (V101.PATH). */
.modal-fs-box {
  max-width: 580px;
}
.fs-breadcrumb {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  font-size: 0.82rem; color: var(--text-2);
  padding: 8px 12px; background: var(--surface-2, #F8FAFC);
  border-radius: 8px; margin-bottom: 12px; min-height: 18px;
}
.fs-breadcrumb a {
  color: var(--primary); cursor: pointer; text-decoration: none;
  padding: 2px 4px; border-radius: 4px;
}
.fs-breadcrumb a:hover { background: rgba(37,99,235,0.08); }
.fs-breadcrumb .fs-sep { color: var(--text-3); }
.fs-listing {
  border: 1px solid var(--border); border-radius: 8px;
  max-height: 320px; min-height: 120px; overflow-y: auto;
  margin-bottom: 12px; background: #fff;
}
.fs-listing .fs-loading,
.fs-listing .fs-empty,
.fs-listing .fs-error {
  padding: 18px 14px; font-size: 0.85rem; color: var(--text-2); text-align: center;
}
.fs-listing .fs-error { color: var(--error); }
.fs-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.fs-item:last-child { border-bottom: none; }
.fs-item:hover { background: var(--surface-2, #F8FAFC); }
.fs-item-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.fs-item-name { flex: 1; color: var(--text-1); }
.fs-item-size { color: var(--text-3); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.fs-item.fs-file { cursor: default; opacity: 0.6; } /* fichiers : visibles mais non cliquables */
.fs-item.fs-file:hover { background: transparent; }
.fs-item.fs-parent { font-weight: 600; }
.fs-current-path {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.78rem; padding: 8px 12px;
  background: var(--surface-2, #F8FAFC); border-radius: 6px; margin-bottom: 16px;
}
.fs-current-path code {
  background: #fff; border: 1px solid var(--border); padding: 2px 6px;
  border-radius: 4px; font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.78rem; word-break: break-all;
}
.fs-current-label { color: var(--text-3); font-weight: 600; }

/* Bouton "?" d'aide contextuelle dans les blocs de Configuration (V101.HELP).
   Petit cercle discret à droite du titre, ouvre #screen-help à l'ancre du bloc. */
.card-help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); border: 1.5px solid var(--border);
  color: var(--primary); font-size: 0.78rem; font-weight: 700;
  cursor: pointer; padding: 0; flex-shrink: 0;
  transition: all 0.12s; line-height: 1;
}
.card-help-btn:hover {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.card-help-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* Input avec icône Parcourir intégrée (V101.PATH).
   Pattern UI standard "input + icon", l'icône est positionnée en absolute
   à droite de l'input, et l'input garde un padding-right pour ne pas la
   chevaucher. La saisie clavier reste possible. */
.input-browse-wrap {
  position: relative; display: block;
}
.input-browse-wrap > input {
  width: 100%; padding-right: 38px; /* place pour l'icône à droite */
}
.input-browse-icon {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text-3); cursor: pointer; padding: 0;
  transition: background 0.12s, color 0.12s;
}
.input-browse-icon:hover {
  background: rgba(37,99,235,0.10); color: var(--primary);
}
.input-browse-icon:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.input-browse-icon:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* Bouton d'aide dans la topbar (Sprint S7) */
.help-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--border, rgba(255,255,255,0.2));
  background: rgba(255,255,255,0.06); color: var(--text-2, #94a3b8);
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 12px; transition: all 0.15s; font-family: inherit;
}
.help-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ==========================================================
   Écran Aide / Documentation — Sprint S7
   Layout 2 colonnes : sidebar fixe + contenu scrollable.
   La topbar fait 61px sticky : on prend le reste de la fenêtre.
   ========================================================== */
#screen-help.active {
  display: flex; flex-direction: column;
  height: calc(100vh - 61px); background: #f9fafb;
}
.help-layout {
  display: flex; flex: 1; overflow: hidden; min-height: 0;
}

/* Sidebar : sommaire ancré (fond sombre, aligné sur techdoc-sidebar) */
.help-sidebar {
  width: 280px; flex-shrink: 0;
  background: #1f2937; border-right: 1px solid #111827;
  padding: 24px 18px; overflow-y: auto;
  display: flex; flex-direction: column;
}
.help-sidebar-title {
  font-size: 0.7rem; font-weight: 700; color: #f9fafb;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0 8px 12px; border-bottom: 1px solid #374151; margin-bottom: 12px;
}
.help-toc { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.help-toc-group { display: contents; }
.help-toc-section {
  font-size: 0.78rem; font-weight: 700; color: #e5e7eb;
  padding: 12px 8px 4px; margin-top: 4px;
}
.help-toc-section.help-toc-todo { color: #6b7280; font-style: italic; font-weight: 600; }
/* Variante bouton pliable (data-help-toc-toggle) — hérite des styles de
   .help-toc-section et y ajoute juste l'interaction. Garde le rendu d'un
   header de TOC, pas d'un bouton stylé. */
button.help-toc-section {
  background: transparent; border: 0; width: 100%; text-align: left;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  border-radius: 6px;
}
button.help-toc-section:hover { background: #374151; color: #fff; }
.help-toc-caret {
  font-size: 0.65rem; line-height: 1;
  transition: transform 0.12s ease-out;
  display: inline-block; opacity: 0.7; flex-shrink: 0;
}
button.help-toc-section[aria-expanded="false"] .help-toc-caret { transform: rotate(-90deg); }
.help-toc-children { display: flex; flex-direction: column; gap: 2px; }
button.help-toc-section[aria-expanded="false"] + .help-toc-children { display: none; }
.help-toc-link {
  display: block; padding: 6px 10px; border-radius: 6px;
  font-size: 0.85rem; color: #d1d5db; text-decoration: none;
  border-left: 2px solid transparent; transition: all 0.12s;
}
.help-toc-link.help-toc-sub { padding-left: 18px; font-size: 0.82rem; color: #9ca3af; }
.help-toc-link:hover { background: #374151; color: #fff; }
.help-toc-link.active {
  background: #1e3a8a; color: #dbeafe; border-left-color: #60a5fa;
  font-weight: 600;
}
.help-back-btn {
  margin-top: 16px; padding: 10px 14px;
  background: transparent; border: 1px solid #4b5563; border-radius: 8px;
  color: #d1d5db; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; font-family: inherit; text-align: left;
}
.help-back-btn:hover { background: #374151; color: #fff; }

/* Contenu principal */
.help-content {
  flex: 1; overflow-y: auto; padding: 24px 36px 60px;
  font-size: 0.92rem; line-height: 1.65; color: #1f2937;
}
.help-content p { margin: 0 0 12px; }
.help-content code {
  background: #f3f4f6; border-radius: 4px; padding: 1px 6px;
  font-size: 0.85em; font-family: var(--mono, monospace); color: #1e3a8a;
}

.help-header-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 16px; margin-bottom: 12px; border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; background: #f9fafb; z-index: 10;
}
.help-h1 { margin: 0; font-size: 1.3rem; font-weight: 700; color: #111827; }
.help-close-btn {
  background: transparent; border: none; font-size: 1.6rem; line-height: 1;
  color: #6b7280; cursor: pointer; padding: 4px 8px; font-family: inherit;
}
.help-close-btn:hover { color: #111827; }

.help-section { margin-bottom: 28px; scroll-margin-top: 60px; }
.help-section-todo { opacity: 0.7; }

/* Titres et structure de la doc */
.help-intro {
  background: #eff6ff; border-left: 3px solid #2563eb;
  padding: 12px 16px; border-radius: 6px; margin-bottom: 24px !important;
  color: #1e3a8a; font-size: 0.92rem;
}
.help-h2 {
  font-size: 1.15rem; font-weight: 700; color: #111827;
  margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid #e5e7eb;
}
.help-h3 {
  font-size: 1rem; font-weight: 700; color: #2563eb;
  margin: 0 0 10px;
}

/* Tableau "Champ → rôle → exemple" */
.help-table {
  width: 100%; border-collapse: collapse; margin: 8px 0 14px;
  font-size: 0.86rem;
}
.help-table th, .help-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
.help-table th {
  background: #f9fafb; font-weight: 700; color: #4b5563;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.help-table td:first-child { font-weight: 600; color: #1f2937; white-space: nowrap; }

/* Encadré "à savoir" */
.help-callout {
  background: #fef3c7; border-left: 3px solid #d97706;
  padding: 10px 14px; border-radius: 6px; margin: 12px 0;
  font-size: 0.86rem; color: #78350f;
}

/* Listes */
.help-list, .help-errors {
  margin: 6px 0 14px; padding-left: 22px; font-size: 0.88rem;
}
.help-list li, .help-errors li { margin-bottom: 5px; }
.help-errors-title {
  font-weight: 700; color: #b91c1c; margin: 12px 0 4px !important;
  font-size: 0.86rem;
}
.help-errors li { color: #4b5563; }

/* Section "à venir" en bas */
.help-sep { border: none; border-top: 1px dashed #d1d5db; margin: 28px 0 16px; }
.help-todo { color: #6b7280; font-size: 0.86rem; font-style: italic; }
.help-todo-list { color: #9ca3af; font-size: 0.86rem; padding-left: 22px; }
.help-todo-list li { margin-bottom: 3px; }

/* Tableau de sélection des candidats backup (CDC §4.1.5) */
.candidates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  margin-top: 4px;
}
.candidates-table thead th {
  text-align: left;
  font-weight: 700;
  color: var(--text-2);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-2);
  background: var(--surface-2);
}
.candidates-table tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.candidates-table tbody tr:hover {
  background: var(--surface-2);
}
.candidates-table tbody tr.selected {
  background: var(--primary-light);
}
.candidates-table .candidate-format {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.candidates-table .candidate-format.confirmed {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}
.candidates-table .candidate-format.ambiguous {
  background: #FEF3C7;
  color: #92400E;
  border-color: #FCD34D;
}
.candidates-table input[type="radio"] {
  width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--primary);
}

/* Liste déroulante des formats possibles (Ambiguous 2+ formats) — CDC §4.1.5 */
.candidate-format-select {
  display: inline-block;
  padding: 4px 28px 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  cursor: pointer;
  font-family: inherit;
  appearance: auto;
  -webkit-appearance: auto;
  max-width: 320px;
}
.candidate-format-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ============================================================ */
/* DOCUMENTATION TECHNIQUE — Sprint S7                          */
/* ============================================================ */

/* Bouton dans la topbar (à gauche du bouton ?) */
.techdoc-btn {
  width: 32px; height: 32px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  margin-right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.techdoc-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Layout général : sidebar + main, comme l'aide */
#screen-tech-doc { display: none; }
#screen-tech-doc.active { display: block; }
.techdoc-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  min-height: calc(100vh - 60px);
  background: #f8fafc;
}

.techdoc-sidebar {
  background: #1f2937;
  color: #e5e7eb;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.techdoc-sidebar-title {
  font-size: 14px;
  font-weight: 600;
  color: #f9fafb;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 1px solid #374151;
}
.techdoc-toc {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.techdoc-toc-link {
  color: #d1d5db;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.4;
  transition: background .12s, color .12s;
  cursor: pointer;
}
.techdoc-toc-link:hover { background: #374151; color: #fff; }
.techdoc-back-btn {
  background: transparent;
  border: 1px solid #4b5563;
  color: #d1d5db;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-top: auto;
  transition: background .12s, color .12s;
}
.techdoc-back-btn:hover { background: #374151; color: #fff; }

/* Contenu principal */
.techdoc-content {
  padding: 24px 40px 80px;
  overflow-y: auto;
  max-width: 980px;
}
.techdoc-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 12px;
}
.techdoc-h1-title {
  font-size: 22px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}
.techdoc-close-btn {
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 28px;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.techdoc-close-btn:hover { color: #111827; }
.techdoc-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 6px;
}

/* Rendu Markdown via MarkdownLite */
.techdoc-article { color: #1f2937; line-height: 1.6; font-size: 14.5px; }
.techdoc-article .md-h1 { font-size: 24px; font-weight: 700; margin: 0 0 16px; color: #111827; }
.techdoc-article .md-h2 { font-size: 20px; font-weight: 600; margin: 28px 0 12px; color: #111827; padding-top: 8px; border-top: 1px solid #e5e7eb; }
.techdoc-article .md-h3 { font-size: 16.5px; font-weight: 600; margin: 22px 0 10px; color: #1f2937; }
.techdoc-article .md-h4 { font-size: 15px; font-weight: 600; margin: 18px 0 8px; color: #1f2937; }
.techdoc-article .md-p  { margin: 0 0 12px; }
.techdoc-article .md-list { margin: 0 0 12px; padding-left: 24px; }
.techdoc-article .md-list li { margin-bottom: 4px; }
.techdoc-article .md-quote {
  background: #f0f9ff;
  border-left: 3px solid #38bdf8;
  margin: 12px 0;
  padding: 10px 16px;
  color: #0c4a6e;
  border-radius: 0 6px 6px 0;
}
.techdoc-article .md-code-inline {
  background: #f1f5f9;
  color: #be185d;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.techdoc-article .md-code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  line-height: 1.45;
  margin: 12px 0;
}
.techdoc-article .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
}
.techdoc-article .md-table th,
.techdoc-article .md-table td {
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.techdoc-article .md-table th {
  background: #f3f4f6;
  font-weight: 600;
  color: #374151;
}
.techdoc-article .md-table tr:nth-child(even) td { background: #fafbfc; }
.techdoc-article .md-link { color: #2563eb; text-decoration: underline; }
.techdoc-article .md-link:hover { color: #1d4ed8; }
.techdoc-article .md-hr { border: none; border-top: 1px solid #e5e7eb; margin: 24px 0; }
