/* Estimatif interactif — feuille de styles (look NuxtUI 4 / Tailwind 4 inspired) */

:root {
  /* Neutrals — slate */
  --bg: #ffffff;
  --bg-2: #f8fafc;       /* slate-50 */
  --bg-3: #f1f5f9;       /* slate-100 */
  --line: #e2e8f0;       /* slate-200 */
  --line-2: #cbd5e1;     /* slate-300 */
  --ink: #0f172a;        /* slate-900 */
  --ink-2: #334155;      /* slate-700 */
  --ink-3: #64748b;      /* slate-500 */
  --ink-4: #94a3b8;      /* slate-400 */

  /* Brand */
  --primary: #4f46e5;    /* indigo-600 */
  --primary-h: #4338ca;  /* indigo-700 */
  --primary-soft: #eef2ff;
  --primary-soft-bd: #e0e7ff;
  --primary-text: #4338ca;

  /* Semantic */
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-bd: #a7f3d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-bd: #fde68a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-bd: #fecaca;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --info-bd: #bae6fd;

  /* Radii */
  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.04);
  --shadow: 0 1px 2px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 4px 6px -2px rgba(15,23,42,0.05), 0 12px 24px -6px rgba(15,23,42,0.10);

  /* Fonts */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============ APP SHELL ============ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f1f5f9;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid #0f172a;
  flex-wrap: wrap;
}
.topbar .brand {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
  display: flex; align-items: center; gap: 10px;
}
.topbar .brand::before {
  content: '';
  width: 24px; height: 24px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
}
.topbar .brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0;
}
.topbar .spacer { flex: 1; }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 500;
}
.user-pill b { color: #f1f5f9; font-weight: 600; }
.user-pill .role-badge {
  font-size: 10px;
  background: var(--primary);
  color: #fff;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* ============ Version picker (topbar) ============
   Bouton + dropdown pour naviguer entre versions de l'estimatif.
   Vit dans la topbar slate, donc design adapté (clair sur fond sombre). */
.version-picker {
  position: relative;
  margin-left: 14px;
}
.version-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: #e2e8f0;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  font-family: inherit;
}
.version-trigger:hover { background: rgba(255,255,255,0.14); }
.version-trigger-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex: none;
}
.version-trigger.is-archived .version-trigger-dot {
  background: var(--ink-3);
}
.version-trigger-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #cbd5e1;
}
.version-trigger-label {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f1f5f9;
}
.version-trigger-caret {
  font-size: 10px;
  color: #94a3b8;
  margin-left: 2px;
}

/* Badge "Dernière modification" — affiché à côté du sélecteur de version,
   en orange, dans la topbar slate. */
.last-modified-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 5px 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: #fbbf24;
  font-family: inherit;
  white-space: nowrap;
}
.last-modified-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  flex: none;
  animation: last-modified-pulse 2s ease-in-out infinite;
}
@keyframes last-modified-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}
.last-modified-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}
.last-modified-date {
  font-weight: 600;
  color: #fcd34d;
  font-variant-numeric: tabular-nums;
}

.version-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 420px;
  max-width: 560px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg, 0 10px 30px rgba(15,23,42,0.18));
  z-index: 100;
  overflow: hidden;
  font-family: inherit;
}
.version-create-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: var(--primary-soft);
  color: var(--primary-text, var(--primary));
  border: none;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.version-create-btn:hover { background: var(--primary); color: #fff; }
.version-create-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
}

.version-list {
  max-height: 380px;
  overflow-y: auto;
}
.version-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
}
.version-item:last-child { border-bottom: none; }
.version-item:hover { background: var(--bg-2); }
.version-item.selected { background: var(--primary-soft); }
.version-item.is-hidden { opacity: 0.6; }

.version-item-main {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: inherit;
  min-width: 0;
}
.version-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.version-item-id {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 3px;
  flex: none;
}
.version-item.selected .version-item-id { background: #fff; color: var(--primary); }
.version-item-label {
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.version-item-meta {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.version-item-note { font-style: italic; }

.version-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 999px;
  flex: none;
}
.version-badge.current { background: var(--success); color: #fff; }
.version-badge.locked  { background: var(--bg-2); color: var(--ink-3); border: 1px solid var(--line); }
.version-badge.hidden  { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-bd); }

.version-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 4px 4px;
  flex: none;
}
.version-item-actions .icon-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14px;
  transition: all 0.12s;
}
.version-item-actions .icon-btn:hover {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}
.version-item.is-hidden .version-item-actions .icon-btn:first-child { color: var(--warning); }

/* Dialog inline pour créer / dupliquer une version */
.version-dialog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.version-dialog-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.version-dialog-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #fff;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--primary-soft-bd);
}
.version-dialog-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.version-dialog-field span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.version-dialog-field .cell-input {
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--r-sm);
}
.version-dialog-field .cell-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}
.version-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.btn.sm.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.sm.primary:hover:not(:disabled) {
  background: var(--primary-text, var(--primary));
  filter: brightness(0.92);
}
.btn.sm.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ Mode banner ============ */
.mode-banner {
  background: var(--warning-soft);
  border-bottom: 1px solid var(--warning-bd);
  color: #78350f;
  padding: 8px 28px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mode-banner.demo { background: #fef3c7; border-color: #fbbf24; }
.mode-banner.error { background: var(--danger-soft); border-color: var(--danger-bd); color: #991b1b; }
.mode-banner.archived { background: var(--bg-2); border-color: var(--line-2); color: var(--ink-2); }
.mode-banner b { font-weight: 700; }
.mode-banner code {
  background: rgba(15,23,42,0.06);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* ============ Tabs ============ */
.tabs-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  display: flex;
  gap: 2px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.tab-btn-icon { font-size: 16px; flex-shrink: 0; }
.tab-btn-label { /* visible par défaut, masqué en mobile */ }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--primary-text);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-btn .tab-count {
  background: var(--bg-3);
  color: var(--ink-3);
  font-size: 10px;
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-weight: 600;
  font-family: var(--font-mono);
}
.tab-btn.active .tab-count {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.tabs-bar .spacer { flex: 1; }
.tabs-bar .actions { display: flex; gap: 8px; padding: 8px 0; }

/* ============ Page container ============ */
.page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px 80px;
  width: 100%;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-md);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--bg-2); border-color: var(--line-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.btn.primary:hover:not(:disabled) {
  background: var(--primary-h);
  border-color: var(--primary-h);
}
.btn.dark {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn.dark:hover:not(:disabled) { background: #1e293b; }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-2);
}
.btn.ghost:hover:not(:disabled) { background: var(--bg-3); }
.btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger-bd);
}
.btn.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.xs { padding: 2px 7px; font-size: 11px; gap: 3px; }

/* ============ Login ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top left, rgba(99,102,241,0.08), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(124,58,237,0.06), transparent 50%),
    var(--bg-2);
}
.login-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 36px 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.login-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 4px 12px rgba(99,102,241,0.25);
}
.login-brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.login-brand-name small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 1px;
  letter-spacing: 0;
}
.login-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin: 24px 0 4px;
}
.login-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 20px;
}
.login-field {
  margin-bottom: 14px;
}
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.login-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.login-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.login-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger-bd);
  color: #991b1b;
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  margin-bottom: 14px;
}
.login-btn {
  width: 100%;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.login-btn:hover:not(:disabled) { background: var(--primary-h); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.login-readonly {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.login-readonly-link {
  background: none;
  border: none;
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
}
.login-readonly-link:hover { text-decoration: underline; }
.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-4);
}

/* ============ Quote head (résumé exécutif) ============ */
.quote-head {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f1f5f9;
  border-radius: var(--r-xl);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}
.quote-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.02em;
}
.quote-head .muted { color: #94a3b8; font-size: 13px; }
.quote-head .sub { color: #cbd5e1; font-size: 13px; margin-top: 6px; max-width: 520px; line-height: 1.55; }

/* TJM control */
.tjm-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-md);
  padding: 6px 10px;
  flex-wrap: wrap;
}
.tjm-control .lbl { color: #94a3b8; font-size: 12px; font-weight: 500; }
.tjm-input {
  width: 80px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  text-align: right;
  -moz-appearance: textfield;
}
.tjm-input::-webkit-outer-spin-button,
.tjm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tjm-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}
.tjm-presets {
  display: flex;
  gap: 4px;
  margin-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  padding-left: 10px;
}
.tjm-preset {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #cbd5e1;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.15s;
}
.tjm-preset:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}
.tjm-preset.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* ============ Résumé executif — cards ============ */
.quote-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.qsum-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.qsum-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.qsum-card.mvp::before { background: var(--success); }
.qsum-card.opt::before { background: var(--info); }
.qsum-card.next::before { background: var(--ink-4); }
.qsum-card.grand {
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
  border-color: var(--primary-soft-bd);
}
.qsum-card.grand::before { background: var(--primary); }

.qsum-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.qsum-card.mvp .qsum-tag { color: var(--success); }
.qsum-card.opt .qsum-tag { color: var(--info); }
.qsum-card.grand .qsum-tag { color: var(--primary); }

.qsum-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.qsum-desc { font-size: 12px; color: var(--ink-3); line-height: 1.45; flex: 1; }
.qsum-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 11px;
}
.qsum-stats > div { display: flex; flex-direction: column; gap: 2px; }
.qsum-stats .muted {
  color: var(--ink-4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.qsum-stats b { color: var(--ink); font-size: 13px; font-weight: 700; }
.qsum-money {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.qsum-card.grand .qsum-money { color: var(--primary); }
.qsum-card.mvp .qsum-money { color: var(--success); }

/* ============ Section heads ============ */
.quote-section { margin-bottom: 28px; }
.qsection-head { margin-bottom: 12px; }
.qsection-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  color: var(--ink-3);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.qsection-tag.mvp { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-bd); }
.qsection-tag.opt { background: var(--info-soft); color: var(--info); border: 1px solid var(--info-bd); }
.qsection-tag.next { background: var(--bg-3); color: var(--ink-2); border: 1px solid var(--line-2); }
.qsection-tag.warn { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-bd); }
.qsection-tag.crit { background: var(--danger); color: #fff; border: 1px solid var(--danger); }
.qsection-head h2 {
  margin: 4px 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.qsection-head .sub {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* ============ Quote table ============ */
.quote-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.quote-table th {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.quote-table th.num { text-align: right; }
.quote-table th.center { text-align: center; }
.quote-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  vertical-align: top;
  color: var(--ink-2);
}
.quote-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}
.quote-table tr:last-child td { border-bottom: none; }
.quote-table tr.row-edited td { background: rgba(99, 102, 241, 0.04); }

.quote-table tr.q-section td {
  background: var(--bg-3);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.quote-table tr.q-section.fond td { background: #f5f3ff; border-left: 3px solid #a78bfa; }
.quote-table tr.q-section.integ td { background: #fff7ed; border-left: 3px solid #fb923c; }
.quote-table tr.q-section.mvp td { background: #ecfdf5; border-left: 3px solid var(--success); }
.quote-table tr.q-section.opt td { background: #f0f9ff; border-left: 3px solid var(--info); }
.quote-table tr.q-section.next td { background: var(--bg-3); border-left: 3px solid var(--ink-4); }
.quote-table tr.q-section td:hover { filter: brightness(0.97); }

.qs-arrow {
  display: inline-block;
  width: 14px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  margin-right: 4px;
}

.quote-table tr.qtotal td {
  background: var(--bg-2);
  border-top: 2px solid var(--line-2);
  font-size: 13px;
  padding: 11px 12px;
  color: var(--ink);
  font-weight: 700;
}
.quote-table tr.qtotal.section-total td {
  background: var(--bg);
  border-top: 1px dashed var(--line-2);
  font-style: italic;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12px;
}
.quote-table tr.qtotal.grand td {
  background: linear-gradient(90deg, var(--primary), var(--primary-h));
  color: #fff;
  border-top: none;
  font-size: 14px;
  font-weight: 700;
}
.quote-table tr.qtotal.grand td.num { color: #fff; }

/* ============ Cell edit ============ */
.cell-edit-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.day-input {
  width: 56px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: var(--r-sm);
  text-align: right;
  -moz-appearance: textfield;
  transition: border-color 0.15s, background 0.15s;
}
.day-input::-webkit-outer-spin-button,
.day-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.day-input::placeholder { color: var(--ink-3); }
.day-input:hover {
  border-color: var(--line);
  background: var(--bg-2);
}
.day-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.cell-edit-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-3);
  white-space: nowrap;
}
.cell-edit-meta .orig { text-decoration: line-through; }
.reset-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  width: 16px; height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.reset-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============ Inline editable ============ */
.inline-edit {
  display: inline-block;
  border-bottom: 1px dashed transparent;
  cursor: text;
  padding: 1px 3px;
  margin: -1px -3px;
  border-radius: 3px;
  transition: background 0.12s, border-color 0.12s;
  min-width: 30px;
}
.inline-edit:hover {
  background: var(--primary-soft);
  border-bottom-color: var(--primary);
}
.inline-edit:focus {
  outline: none;
  background: #fff;
  border: 1px solid var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
  padding: 0 2px;
}
.inline-edit-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  display: inline-block;
  min-width: 100px;
}
.inline-edit-multi {
  display: block;
  white-space: pre-wrap;
}

/* ============ Action chips (édition) ============ */
.row-actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.quote-table tr:hover .row-actions { opacity: 1; }
.row-action-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-3);
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.row-action-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-soft-bd);
}
.row-action-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-bd);
}

.add-row-btn {
  background: transparent;
  border: 1px dashed var(--line-2);
  color: var(--ink-3);
  width: 100%;
  padding: 8px;
  font-size: 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}
.add-row-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* ============ Edit bar (saved indicator) ============ */
.edit-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.03));
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 10px 16px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: 13px;
  flex-wrap: wrap;
}
.edit-bar-icon {
  background: var(--primary);
  color: #fff;
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.edit-bar .muted { color: var(--ink-2); font-size: 12px; }
.edit-bar-delta {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
}
.edit-bar-delta.up { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.edit-bar-delta.down { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.edit-bar-spacer { flex: 1; }
.saved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-soft);
  border: 1px solid var(--success-bd);
  color: #15803d;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ============ Récap final ============ */
.quote-grand {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.quote-grand h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge.mvp { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-bd); }
.badge.opt { background: var(--info-soft); color: var(--info); border: 1px solid var(--info-bd); }
.badge.next { background: var(--bg-3); color: var(--ink-2); border: 1px solid var(--line-2); }
.badge.warn { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-bd); }
.badge.crit { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-bd); }

/* ============ Critique : facturation électronique ============ */
.quote-section.critical {
  border: 2px solid var(--danger);
  border-radius: var(--r-md);
  padding: 20px;
  background: linear-gradient(135deg, var(--danger-soft) 0%, #ffffff 60%);
}
.critical-banner {
  background: #fff;
  border: 1px solid var(--danger-bd);
  border-left: 4px solid var(--danger);
  border-radius: var(--r-sm);
  padding: 14px 18px;
  margin-top: 12px;
}
.cb-title {
  font-weight: 700;
  font-size: 14px;
  color: #991b1b;
  margin-bottom: 8px;
}
.cb-body {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
}
.cb-body + .cb-body { margin-top: 8px; }

.archi-option {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.archi-option.highlight {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.06), rgba(34, 197, 94, 0.02));
  border: 1.5px solid rgba(34, 197, 94, 0.4);
  position: relative;
}
.archi-option.highlight::before {
  content: "★ Recommandé";
  position: absolute;
  top: -10px;
  right: 12px;
  background: #15803d;
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}
.archi-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13.5px;
  flex-wrap: wrap;
}
.archi-num {
  background: var(--danger);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.archi-option.highlight .archi-num { background: #15803d; }
.archi-impact {
  background: var(--warning-soft);
  border-left: 3px solid var(--warning);
  padding: 7px 11px;
  font-size: 12px;
  border-radius: var(--r-sm);
  margin-top: 6px;
  color: var(--ink-2);
}

/* ============ Lexique ============ */
.lexicon-filter {
  width: 280px;
  font-size: 13px;
  padding: 7px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--ink);
}
.lexicon-filter:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.lexicon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.lexicon-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-xs);
}
.lexicon-term {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-text);
  letter-spacing: 0.02em;
}
.lexicon-def {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
}

/* ============ Quote ul ============ */
.quote-ul {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.65;
}
.quote-ul li { margin-bottom: 6px; }
.quote-ul b { color: var(--ink); }

/* ============ Cards (transversaux) ============ */
.tx-grid {
  display: grid;
  gap: 14px;
}
.tx-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.tx-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tx-card h3 .badge { font-size: 10px; }
.tx-card p {
  font-size: 13px;
  color: var(--ink-2);
  margin: 6px 0;
  line-height: 1.55;
}
.tx-card ul {
  font-size: 13px;
  color: var(--ink-2);
  margin: 6px 0;
  padding-left: 18px;
  line-height: 1.6;
}
.tx-card ul li { margin-bottom: 3px; }
.tx-card b { color: var(--ink); font-weight: 600; }

/* ============ Misc ============ */
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.b { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* Loader */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--ink-3);
  font-size: 13px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: var(--r-full);
  border: 2px solid var(--bg-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

@media (max-width: 980px) {
  .quote-summary { grid-template-columns: repeat(2, 1fr); }
  .lexicon-grid { grid-template-columns: 1fr; }
  .quote-head { flex-direction: column; }
}

/* ============================================================
   Onglet CHIFFRAGE — phase / group / lines
   ============================================================ */

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
  line-height: 1.2;
}
.page-sub {
  font-size: 14px;
  color: var(--ink-3);
  margin-bottom: 16px;
  line-height: 1.55;
  max-width: 720px;
}

/* ====== Stack technique : barre de badges colorés ======
   Affichée sous le sous-titre en lecture seule. Chaque catégorie
   a sa propre couleur (cf. STACK_CATEGORIES côté JS). */
.stack-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stack-bar-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex: none;
}
.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stack-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.stack-badge.backend  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.stack-badge.frontend { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.stack-badge.ui       { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.stack-badge.db       { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.stack-badge.security { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.stack-badge.tooling  { background: var(--bg-2); color: var(--ink-3); border-color: var(--line); }

/* ====== Édition du méta (titre / sous-titre / stack) ====== */
.meta-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}
.meta-editor-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.meta-editor-row.meta-editor-stack { align-items: flex-start; }
.meta-editor-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  flex: none;
  min-width: 90px;
  padding-top: 6px;
}
.stack-edit-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  align-items: center;
}
.stack-edit-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  border-left-width: 3px;
}
.stack-edit-item.backend  { border-left-color: #1d4ed8; }
.stack-edit-item.frontend { border-left-color: #047857; }
.stack-edit-item.ui       { border-left-color: #be185d; }
.stack-edit-item.db       { border-left-color: #c2410c; }
.stack-edit-item.security { border-left-color: #b91c1c; }
.stack-edit-item.tooling  { border-left-color: var(--ink-3); }
.stack-edit-name {
  width: 130px;
  font-size: 12px;
  font-weight: 600;
  border: none !important;
  padding: 4px 6px;
}
.stack-edit-category {
  font-size: 11px;
  padding: 4px 6px;
  border: none !important;
  background: var(--bg-2);
  border-radius: 3px;
  cursor: pointer;
}
.add-stack-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--primary);
  border: 1px dashed var(--primary-soft-bd);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.12s;
}
.add-stack-btn:hover {
  background: var(--primary-soft);
}
.section-h {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--ink-4);
}
.kpi.accent::before,
.kpi.mvp::before    { background: var(--success); }
.kpi.opt::before    { background: var(--info); }
.kpi.next::before   { background: var(--ink-4); }
.kpi.total {
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
  border-color: var(--primary-soft-bd);
}
.kpi.total::before { background: var(--primary); }
.kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.kpi.accent .kpi-label,
.kpi.mvp .kpi-label    { color: var(--success); }
.kpi.opt .kpi-label    { color: var(--info); }
.kpi.next .kpi-label   { color: var(--ink-3); }
.kpi.total .kpi-label  { color: var(--primary); }
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi.accent .kpi-value,
.kpi.mvp .kpi-value    { color: var(--success); }
.kpi.opt .kpi-value    { color: var(--info); }
.kpi.total .kpi-value  { color: var(--primary); }
.kpi-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* CTA bar (régie / forfait) */
/* ====== Sélecteur de phases incluses dans le prix engagé (lecture seule) ======
   Permet au client de simuler n'importe quelle combinaison de phases dans
   le calcul des CTA Régie / Forfait sans modifier l'estimatif. */
.commit-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 18px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}
.commit-selector-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex: none;
}
.commit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}
.commit-selector-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
  margin-left: auto;
  flex: none;
}
.commit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #fff;
  color: var(--ink-3);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.commit-chip:hover:not(:disabled):not(.active) {
  background: var(--bg-2);
  color: var(--ink);
  border-color: var(--line-2);
}
.commit-chip:disabled { cursor: default; }
.commit-chip-mark {
  font-size: 11px;
  width: 12px;
  text-align: center;
  font-family: inherit;
}
/* Variantes par kind quand active — la couleur reflète celle de la phase */
.commit-chip.active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.commit-chip.active.mvp   { background: var(--success); }
.commit-chip.active.opt   { background: var(--info); }
.commit-chip.active.next  { background: var(--ink-4); }

.cta-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
.cta-card {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-xs);
}
.cta-card:hover {
  border-color: var(--primary-soft-bd);
  background: var(--bg-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.cta-card.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
  box-shadow: var(--shadow);
}
.cta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.cta-card.active .cta-label { color: var(--primary-text); }
.cta-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  line-height: 1.1;
}
.cta-card.active .cta-amount { color: var(--primary); }
.cta-foot {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.4;
}
/* Liste explicative en bas de chaque card — aide le client à choisir
   entre régie et forfait sans avoir besoin d'un commentaire externe. */
.cta-explanation {
  margin: 14px 0 0;
  padding: 12px 0 0 18px;
  border-top: 1px dashed var(--line);
  list-style: disc;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.cta-explanation li {
  margin-bottom: 4px;
}
.cta-explanation li::marker {
  color: var(--ink-3);
}
.cta-explanation li:last-child { margin-bottom: 0; }
.cta-card.active .cta-explanation { border-top-color: var(--primary-soft-bd); }
.cta-card.active .cta-explanation li::marker { color: var(--primary); }

/* TJM controls (mode édition) */
.tjm-controls {
  display: flex;
  gap: 0;
  align-items: stretch;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}
.tjm-controls .tjm-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  padding: 0 16px;
  flex: 0 0 auto;
}
.tjm-controls .tjm-control:first-child { padding-left: 0; }
.tjm-controls .tjm-control label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.tjm-controls .tjm-control input {
  width: 100px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
  background: var(--bg-2);
}
.tjm-controls .tjm-control input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: #fff;
}
.tjm-divider { width: 1px; background: var(--line); margin: 4px 0; }

/* Phase */
.phase {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.phase-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.phase-head:hover { background: var(--bg-3); }
.phase.mvp .phase-head   { background: linear-gradient(135deg, #d1fae5, var(--bg)); border-bottom-color: var(--success-bd); }
.phase.opt .phase-head   { background: linear-gradient(135deg, var(--info-soft), var(--bg)); border-bottom-color: var(--info-bd); }
.phase.next .phase-head  { background: var(--bg-3); }
.phase-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.phase-caret {
  font-size: 11px;
  color: var(--ink-3);
  width: 14px;
  font-family: var(--font-mono);
}
.phase-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: var(--ink);
  color: #fff;
  padding: 4px 9px;
  border-radius: var(--r-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex: none;
}
.phase.mvp .phase-label   { background: var(--success); }
.phase.opt .phase-label   { background: var(--info); }
.phase.next .phase-label  { background: var(--ink-4); }
.phase-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.phase-desc {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.phase-totals {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  flex: none;
}
.phase-totals > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.phase-totals .lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.phase-totals .val {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-mono);
}
.phase-totals .val.money {
  color: var(--primary);
}
.phase-body {
  padding: 12px 14px 14px;
}

/* Group */
.group {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
/* Drag d'une SECTION (Group) : opacity sur la source, et un trait fin posé
   dans le gap au-dessus ou au-dessous de la section cible (selon position du
   curseur). Le trait sert de curseur d'insertion : on voit nettement où la
   section glissée va atterrir. Nécessite overflow visible côté group, on
   l'override conditionnellement. */
.group.group-dragging { opacity: 0.45; }
.group.group-drop-before,
.group.group-drop-after {
  overflow: visible;
  position: relative;
}
.group.group-drop-before::before,
.group.group-drop-after::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  height: 4px;
  background: var(--primary);
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
  pointer-events: none;
  z-index: 10;
}
.group.group-drop-before::before { top: -7px; }
.group.group-drop-after::after  { bottom: -7px; }
/* Drag d'une LIGNE : feedback sur la source + barres top/bottom sur la cible */
.lines tr.dragging td { opacity: 0.4; }
.lines tr.drop-before td { box-shadow: inset 0 2px 0 var(--primary); }
.lines tr.drop-after td  { box-shadow: inset 0 -2px 0 var(--primary); }
/* Curseur grab sur la cellule code (ligne) et sur le code de section (group)
   — c'est la zone "handle" pour démarrer le drag. */
.lines tr[draggable="true"] td.id-col,
.group-head[draggable="true"] .group-code {
  cursor: grab;
}
.lines tr[draggable="true"]:active td.id-col,
.group-head[draggable="true"]:active .group-code {
  cursor: grabbing;
}
.group.fond  { border-left: 3px solid #a78bfa; }
.group.integ { border-left: 3px solid #fb923c; }
.group.secu  { border-left: 3px solid #ef4444; }
.group.ui    { border-left: 3px solid #ec4899; }
.group.data  { border-left: 3px solid #14b8a6; }
.group.biz   { border-left: 3px solid #ca8a04; }
.group.pm    { border-left: 3px solid #65a30d; }
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
  flex-wrap: wrap;
}
.group.fond .group-head  { background: #f5f3ff; }
.group.integ .group-head { background: #fff7ed; }
.group.secu .group-head  { background: #fef2f2; }
.group.ui .group-head    { background: #fdf2f8; }
.group.data .group-head  { background: #f0fdfa; }
.group.biz .group-head   { background: #fefce8; }
.group.pm .group-head    { background: #f7fee7; }
.group-head:hover { filter: brightness(0.97); }
.group-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.group-caret {
  font-size: 11px;
  color: var(--ink-3);
  width: 14px;
  font-family: var(--font-mono);
}
.group-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--ink);
  color: #fff;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  flex: none;
}
.group.fond .group-code  { background: #7c3aed; }
.group.integ .group-code { background: #ea580c; }
.group.secu .group-code  { background: #dc2626; }
.group.ui .group-code    { background: #db2777; }
.group.data .group-code  { background: #0d9488; }
.group.biz .group-code   { background: #a16207; }
.group.pm .group-code    { background: #4d7c0f; }
.group-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}
.group-intro {
  font-size: 12px;
  color: var(--ink-3);
  font-style: italic;
}
.group-totals {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  flex: none;
}
.group-totals .gt-val {
  font-weight: 700;
  color: var(--ink);
  margin-left: 4px;
}

/* Lines table */
/* Scroll horizontal quand le tableau ne tient pas (mobile, étroit) */
.table-wrap {
  padding: 4px 8px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.lines {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  /* Empêche les colonnes de trop se compresser : si le total dépasse la
     largeur du wrap, on déclenche le scroll horizontal */
  min-width: 540px;
}
.lines th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.lines th.num { text-align: right; }
.lines th.act { width: 30px; }
.lines th.id-col { width: 60px; }
.lines td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-2);
}
.lines tr:last-child td { border-bottom: none; }
.lines tr:hover td { background: var(--bg-2); }
.lines td.id-col {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  white-space: nowrap;
  width: 60px;
}
.lines td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  width: 70px;
}
.lines td.num.bold { font-weight: 700; }
.lines td.act { width: 30px; text-align: right; }
.lines td.label-cell { max-width: 0; }
.lines tfoot td {
  background: var(--bg-2);
  border-top: 2px solid var(--line-2);
  border-bottom: none;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  padding: 9px 10px;
}

/* Cell input */
.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s;
}
.cell-input.label { font-weight: 500; }
.cell-input.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  width: 60px;
}
.cell-input:hover {
  border-color: var(--line);
  background: var(--bg-2);
}
.cell-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 2px var(--primary-soft);
}
textarea.cell-input {
  resize: vertical;
  min-height: 36px;
  line-height: 1.5;
}

.comment {
  margin-top: 4px;
  padding: 6px 9px;
  background: var(--warning-soft);
  border-left: 2px solid var(--warning);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: #78350f;
}
.comment.editor-only::before {
  content: 'Note interne · ';
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--warning);
  text-transform: uppercase;
}
.comment .cell-input {
  background: transparent;
  border: none;
  padding: 2px 0;
  font-size: 12px;
  color: #78350f;
}
.comment .cell-input:hover { background: rgba(255,255,255,0.6); }
.comment .cell-input:focus {
  background: #fff;
  border: 1px solid var(--warning);
  box-shadow: 0 0 0 2px var(--warning-soft);
}

/* Icon button */
.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  font-family: inherit;
  line-height: 1;
}
.icon-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger-bd);
  color: var(--danger);
}
.icon-btn.add {
  border: 1px dashed var(--line-2);
  width: auto;
  height: auto;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--ink-3);
}
.icon-btn.add:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============ Tags de ligne (badges) ============
   Système unifié : chaque ligne du chiffrage porte un tag (api, front, design,
   gestion, devops, conformite, doc, data). La couleur est injectée via la
   propriété custom --tag-color (cf. LINE_TAGS dans tab-chiffrage.jsx). */

.tag-col {
  width: 130px;
  text-align: left;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--tag-color) 12%, white);
  color: color-mix(in srgb, var(--tag-color) 80%, black);
  border: 1px solid color-mix(in srgb, var(--tag-color) 35%, white);
  white-space: nowrap;
}
.tag-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tag-color);
  flex-shrink: 0;
}

/* Bouton-pastille pour ouvrir le sélecteur de tag (mode édition) */
.tag-picker {
  position: relative;
  display: inline-block;
}
.tag-picker-trigger {
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--tag-color) 50%, white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-picker-trigger:hover {
  border-color: var(--tag-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tag-color) 18%, transparent);
}
.tag-caret {
  margin-left: 2px;
  font-size: 10px;
  opacity: 0.7;
}
.tag-picker-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
}
.tag-picker-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-1);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.tag-picker-option:hover {
  background: color-mix(in srgb, var(--tag-color) 10%, transparent);
  border-color: color-mix(in srgb, var(--tag-color) 30%, transparent);
}
.tag-picker-option.active {
  background: color-mix(in srgb, var(--tag-color) 15%, transparent);
  border-color: var(--tag-color);
}

/* Chips compactes pour la ventilation par tag (utilisées dans tfoot, KPIs) */
.tag-breakdown {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.tag-breakdown.compact { font-size: 10px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: color-mix(in srgb, var(--tag-color) 10%, white);
  color: color-mix(in srgb, var(--tag-color) 75%, black);
  border: 1px solid color-mix(in srgb, var(--tag-color) 25%, white);
  white-space: nowrap;
}
.tag-chip-label { opacity: 0.85; }
.tag-chip-val { font-weight: 800; }

/* Ligne footer du tableau d'un groupe : ventilation par tag */
.lines tfoot tr.subtotal-tags td {
  background: var(--bg-2);
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 11px;
}

/* Synthèse globale par tag (sous le bandeau de KPIs phases) */
.tag-summary {
  margin: 14px 0 18px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.tag-summary-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.tag-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.tag-summary-card {
  background: color-mix(in srgb, var(--tag-color) 6%, white);
  border: 1px solid color-mix(in srgb, var(--tag-color) 25%, white);
  border-left: 3px solid var(--tag-color);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.tag-summary-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: color-mix(in srgb, var(--tag-color) 75%, black);
  margin-bottom: 4px;
}
.tag-summary-name { text-transform: uppercase; }
.tag-summary-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}
.tag-summary-sub {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Chips dans les KPIs de phase : compactes, pleine largeur sous la valeur */
.kpi .tag-breakdown {
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ============ Lexique ============ */
/* Toolbar du lexique : barre de recherche + compteur + bouton ajouter */
.lexique-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.lex-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 280px;
  max-width: 480px;
}
.lex-search-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--ink-3);
  pointer-events: none;
  font-family: var(--font-mono);
}
.lex-search-input {
  width: 100%;
  padding: 9px 36px 9px 36px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.lex-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.lex-search-input::placeholder { color: var(--ink-3); }
.lex-search-clear {
  position: absolute;
  right: 6px;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.lex-search-clear:hover { background: var(--bg-2); color: var(--ink); }
.lex-search-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 999px;
}
/* Lien type bouton inline (utilisé dans le message "Aucun résultat") */
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.link-btn:hover { color: var(--ink); }

.lexique-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.lex-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  box-shadow: var(--shadow-xs);
  /* Indispensable : sans min-width:0, un enfant non-shrinkable (input, ProseMirror,
     longue chaîne sans espace) force le débordement de la card grid.
     PAS d'overflow:hidden ici — la card doit s'adapter en hauteur au contenu de
     l'éditeur (Quill peut être de plusieurs lignes). Le débordement horizontal
     est géré par min-width:0 + overflow-wrap sur les enfants. */
  min-width: 0;
}
.lex-item > * {
  min-width: 0;
  max-width: 100%;
}
.lex-item input,
.lex-item textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}
.lex-item .rich-editor-wrap,
.lex-item .ql-container,
.lex-item .ql-editor {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.lex-term {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-text);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.lex-def {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.lex-actions {
  position: absolute;
  top: 8px;
  right: 8px;
}

.empty {
  text-align: center;
  padding: 40px;
  color: var(--ink-3);
  font-size: 13px;
  background: var(--bg);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}

/* ============ Critiques ============ */
/* Sous-onglets : un par kind (warn / crit / info / rule / hypo). */
.crit-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.crit-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  position: relative;
  margin-bottom: -1px;
  font-family: inherit;
}
.crit-tab:hover {
  background: var(--bg-2);
  color: var(--ink);
}
.crit-tab.active {
  background: var(--bg);
  border-color: var(--line);
  border-bottom-color: var(--bg);
  color: var(--ink);
  cursor: default;
}
.crit-tab-icon { font-size: 16px; line-height: 1; display: inline-flex; align-items: center; }
.crit-tab-label { white-space: nowrap; }
.crit-tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--ink-3);
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
  border: 1px solid var(--line);
}
/* Variantes par tone : trait coloré sur l'onglet actif + couleur du texte
   On stocke le tone dans --tone pour le réutiliser sur le badge compteur. */
.crit-tab.active.warning  { --tone: var(--warning); }
.crit-tab.active.danger   { --tone: var(--danger); }
.crit-tab.active.info     { --tone: var(--info); }
.crit-tab.active.rule     { --tone: #7c3aed; }
.crit-tab.active.question { --tone: #0891b2; }
.crit-tab.active.neutral  { --tone: var(--ink-3); }
.crit-tab.active {
  color: var(--tone);
  box-shadow: inset 0 2px 0 var(--tone);
}
.crit-tab.active .crit-tab-count {
  background: var(--tone);
  color: #fff;
  border-color: var(--tone);
}

.critiques-wrap {
  display: grid;
  gap: 14px;
}
.critique-block {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
  border-left: 3px solid var(--ink-4);
}
.critique-block:has(.crit-head:first-child:nth-of-type(1)) {
  /* défaut neutre */
}
.crit-head {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Couleur via texte d'icône leading */
.critique-block:has(.crit-head:first-child:not(:empty)) {}
.critique-block .crit-head:first-line { color: inherit; }

/* Variantes par contenu de l'icône */
.critique-block { border-left-color: var(--ink-4); }
/* On colorie via classes — on ajoute des règles qui matchent le texte */
.critique-block .crit-head { color: var(--ink-3); }

/* Variantes par couleur via attribut text */
.critique-block:has(.crit-head:first-child) { /* fallback */ }

.critique-block h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.crit-body {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}
.crit-body em { color: var(--ink); font-style: normal; font-weight: 600; }
.crit-body strong { color: var(--ink); font-weight: 700; }
.crit-body ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.crit-body ul li { margin-bottom: 4px; }

/* Variantes critique selon ⚠ vs ℹ */
.critique-block.warn {
  border-left-color: var(--warning);
  background: linear-gradient(135deg, var(--warning-soft) 0%, #fff 60%);
}
.critique-block.warn .crit-head { color: var(--warning); }
.critique-block.info {
  border-left-color: var(--info);
}
.critique-block.info .crit-head { color: var(--info); }

/* ========================================================
   Nouveau : kind-picker, group-meta, sections suppr/ajout,
   colonne montant, mode lecture multi-tons, critiques CRUD
   ======================================================== */

/* Kind picker (sélecteur de type pour sections / critiques) */
.kind-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.kind-chip {
  --chip: #cbd5e1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: #fff;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.kind-chip .kind-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip);
  display: inline-block;
}
.kind-chip:hover {
  background: var(--bg-2);
  border-color: var(--line-2);
}
.kind-chip.active {
  background: var(--chip);
  border-color: var(--chip);
  color: #fff;
  font-weight: 600;
}
.kind-chip.active .kind-dot {
  background: #fff;
  border: 1px solid rgba(255,255,255,0.6);
}

/* Group head — partie droite contenant totaux + bouton suppr */
.group-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn.delete-section {
  width: 22px;
  height: 22px;
  font-size: 14px;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.icon-btn.delete-section:hover {
  color: var(--danger);
  border-color: var(--danger-bd);
  background: var(--danger-soft);
}

/* Bandeau d'édition de la section (code, intro, kind) */
.group-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.group-meta-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}

/* Bouton "Ajouter une section" dans une phase */
.add-section-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: var(--primary-soft);
  color: var(--primary-text);
  border: 1px dashed var(--primary-soft-bd);
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.12s;
}
.add-section-btn:hover {
  background: var(--primary);
  color: #fff;
  border-style: solid;
  border-color: var(--primary);
}

/* Bouton "Ajouter une phase" — variante plus marquée du add-section-btn */
.add-phase-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  margin: 8px 0 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--primary);
  border: 2px dashed var(--primary-soft-bd);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.12s;
}
.add-phase-btn:hover {
  background: var(--primary);
  color: #fff;
  border-style: solid;
  border-color: var(--primary);
}

/* Bouton "danger" générique — utilisé pour la suppression de phase */
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger-bd);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.12s;
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.phase-delete-btn { margin-left: auto; }

/* Édition d'une phase — bandeau visible quand la phase est ouverte */
.phase-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
}
.phase-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.phase-meta-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  flex: none;
  min-width: 90px;
}

/* Mini toggle Aperçu prix Régie/Forfait dans tjm-controls */
.tjm-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
  height: 36px;
}
.tjm-mode-toggle button {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.12s;
  height: 100%;
}
.tjm-mode-toggle button:hover { background: var(--bg-2); color: var(--ink); }
.tjm-mode-toggle button.active {
  background: var(--primary);
  color: #fff;
  cursor: default;
}
.tjm-mode-toggle button + button { border-left: 1px solid var(--line); }
.tjm-mode-toggle button.active + button,
.tjm-mode-toggle button + button.active { border-left-color: var(--primary); }

/* Colonne montant (€ par ligne) */
.lines th.money-col,
.lines td.money-col {
  text-align: right;
  width: 110px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  font-size: 12px;
}
.lines tfoot td.money-col {
  font-weight: 700;
  color: var(--primary-text);
  font-size: 13px;
}
.group-totals .gt-money {
  font-weight: 700;
  color: var(--primary-text);
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

/* Critiques CRUD — refonte */
.critique-block {
  position: relative;
}
.crit-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.crit-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.crit-actions .icon-btn {
  width: 24px;
  height: 24px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-3);
  border-radius: var(--r);
}
.crit-actions .icon-btn:hover:not(:disabled) {
  background: var(--bg-2);
  color: var(--ink);
}
.crit-actions .icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.crit-icon {
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* Variantes critiques par tone */
.critique-block.warning {
  border-left-color: var(--warning);
  background: linear-gradient(135deg, var(--warning-soft) 0%, #fff 60%);
}
.critique-block.warning .crit-head { color: var(--warning); }

.critique-block.danger {
  border-left-color: var(--danger);
  background: linear-gradient(135deg, var(--danger-soft) 0%, #fff 60%);
}
.critique-block.danger .crit-head { color: var(--danger); }

.critique-block.rule {
  border-left-color: #7c3aed;
  background: linear-gradient(135deg, #f5f3ff 0%, #fff 60%);
}
.critique-block.rule .crit-head { color: #7c3aed; }

.critique-block.question {
  border-left-color: #0891b2;
  background: linear-gradient(135deg, #ecfeff 0%, #fff 60%);
}
.critique-block.question .crit-head { color: #0891b2; }

/* État masqué (visible:false) — uniquement visible en mode édition.
   En lecture, les cards masquées sont entièrement filtrées en amont. */
.critique-block.is-hidden {
  opacity: 0.55;
  background: repeating-linear-gradient(
    -45deg,
    var(--bg-2) 0,
    var(--bg-2) 8px,
    var(--bg) 8px,
    var(--bg) 16px
  );
}
.critique-block.is-hidden h4,
.critique-block.is-hidden .crit-body {
  filter: grayscale(0.4);
}
.crit-hidden-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Bloc de réponse aux questions — affiché sous le corps de la question.
   Visuellement distinct (encart vert/teal) pour montrer que c'est une réponse
   séparée du bloc principal. */
.crit-answer {
  margin-top: 14px;
  padding: 12px 14px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-left: 3px solid #14b8a6;
  border-radius: var(--r-sm);
}
/* Réponse verrouillée : visuel apaisé (gris) pour signaler la lecture seule */
.crit-answer.is-locked {
  background: #f8fafc;
  border-color: #e2e8f0;
  border-left-color: #64748b;
}
.crit-answer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #0f766e;
}
.crit-answer.is-locked .crit-answer-label {
  color: #475569;
}
.crit-answer-icon {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  color: #14b8a6;
}
.crit-answer.is-locked .crit-answer-icon {
  color: #64748b;
}
.crit-answer-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  color: #475569;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
}
.crit-answer .rich-editor,
.crit-answer .ProseMirror,
.crit-answer .editor-readonly {
  background: #fff;
  border-radius: var(--r-sm);
}

/* Actions sous l'éditeur de réponse */
.crit-answer-viewer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.crit-answer-warn {
  font-size: 12px;
  color: #b45309;
  font-style: italic;
}
.crit-answer-admin-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #99f6e4;
}
.crit-answer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #0f766e;
  cursor: pointer;
  user-select: none;
}
.crit-answer-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.critique-block.neutral {
  border-left-color: var(--ink-3);
  background: linear-gradient(135deg, var(--bg-3) 0%, #fff 60%);
}
.critique-block.neutral .crit-head { color: var(--ink-2); }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  font-size: 14px;
}

/* Inputs dans les critiques en édition */
.critique-block textarea.cell-input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  resize: vertical;
}
.critique-block textarea.cell-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ============ Éditeur riche (Quill snow override) ============
   Aligne l'éditeur Quill sur le design system Otidea — typo, bordures, focus. */
/* Fix débordement dans containers étroits (grilles, flex avec min-width:0) :
   l'éditeur prend toute la largeur disponible et se laisse rétrécir. */
.rich-editor-wrap {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.rich-editor-wrap .ql-toolbar.ql-snow,
.rich-editor-wrap .ql-container.ql-snow {
  border-color: var(--line);
  box-sizing: border-box;
  max-width: 100%;
}
/* Toolbar : permet le wrap des boutons sur plusieurs lignes si la largeur
   est insuffisante (cas des cards étroites en grille 2 colonnes). */
.rich-editor-wrap .ql-toolbar.ql-snow {
  white-space: normal;
}
.rich-editor-wrap .ql-toolbar.ql-snow {
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--bg-2);
  padding: 6px 8px;
}
.rich-editor-wrap .ql-container.ql-snow {
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  /* Quill définit height:100% par défaut (conçu pour éditeur plein écran).
     Dans notre cas, on veut que la hauteur s'adapte au contenu, sinon le
     container essaie de prendre 100% du parent et déborde quand la toolbar
     n'est pas comptée. */
  height: auto;
}
.rich-editor-wrap .ql-editor {
  min-height: 100px;
  line-height: 1.55;
  color: var(--ink);
  padding: 10px 14px;
  /* Idem : on retire le height:100% par défaut de Quill pour que l'éditeur
     grandisse avec son contenu. */
  height: auto;
  overflow-y: visible;
}
.rich-editor-wrap.compact .ql-editor {
  min-height: 60px;
  font-size: 13px;
}
.rich-editor-wrap .ql-editor:focus { outline: none; }
.rich-editor-wrap .ql-editor.ql-blank::before {
  color: var(--ink-3);
  font-style: normal;
  left: 14px;
  right: 14px;
}
.rich-editor-wrap:focus-within .ql-toolbar.ql-snow,
.rich-editor-wrap:focus-within .ql-container.ql-snow {
  border-color: var(--primary);
}
.rich-editor-wrap:focus-within .ql-container.ql-snow {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.rich-editor-wrap .ql-snow .ql-stroke { stroke: var(--ink-3); }
.rich-editor-wrap .ql-snow .ql-fill { fill: var(--ink-3); }
.rich-editor-wrap .ql-snow .ql-picker { color: var(--ink-2); }
.rich-editor-wrap .ql-snow.ql-toolbar button:hover .ql-stroke,
.rich-editor-wrap .ql-snow.ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--primary);
}
.rich-editor-wrap .ql-snow.ql-toolbar button:hover .ql-fill,
.rich-editor-wrap .ql-snow.ql-toolbar button.ql-active .ql-fill {
  fill: var(--primary);
}
.rich-editor-wrap .ql-snow.ql-toolbar button.ql-active,
.rich-editor-wrap .ql-snow .ql-picker-label.ql-active {
  color: var(--primary);
}

/* Rendu lecture seule du contenu HTML produit par Quill */
.rich-readonly {
  line-height: 1.55;
  color: var(--ink-2);
  font-size: 13px;
}
.rich-readonly p { margin: 0 0 8px; }
.rich-readonly p:last-child { margin-bottom: 0; }
.rich-readonly h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 8px 0 6px;
}
.rich-readonly ul, .rich-readonly ol {
  margin: 0 0 8px;
  padding-left: 22px;
}
/* Force le bon marker selon le type de liste — au cas où un reset global
   aurait supprimé list-style. Indispensable car certains resets CSS
   (Tailwind preflight, etc.) mettent list-style: none sur ul/ol. */
.rich-readonly ul { list-style: disc outside; }
.rich-readonly ol { list-style: decimal outside; }
.rich-readonly ul ul { list-style: circle outside; }
.rich-readonly ul ul ul { list-style: square outside; }
.rich-readonly li { margin-bottom: 3px; display: list-item; }
.rich-readonly blockquote {
  border-left: 3px solid var(--primary-soft-bd);
  padding: 2px 10px;
  color: var(--ink-3);
  margin: 0 0 8px;
  font-style: italic;
}
.rich-readonly code {
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.rich-readonly pre,
.rich-readonly .ql-syntax {
  background: var(--bg-2);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  margin: 0 0 8px;
  color: var(--ink);
}
.rich-readonly a {
  color: var(--primary);
  text-decoration: underline;
}
.rich-readonly strong { color: var(--ink); font-weight: 700; }
.rich-readonly em { font-style: italic; }

/* ============ Bootstrap form (premier accès / data manquante) ============
   Affiché à l'éditeur quand le serveur n'a pas encore de data.json.
   Crée le squelette initial à partir d'un mini formulaire. */
.bootstrap-page {
  min-height: calc(100vh - 56px);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%);
  padding: 40px 20px 60px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.bootstrap-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 32px 36px;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.bootstrap-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.bootstrap-header p {
  font-size: 13.5px;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.55;
}
.bootstrap-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.bootstrap-section:first-of-type {
  border-top: none;
  padding-top: 0;
}
.bootstrap-section h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}
.bootstrap-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.bootstrap-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.bootstrap-field input {
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.bootstrap-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.bootstrap-hint {
  font-size: 11.5px;
  color: var(--ink-3);
  font-style: italic;
}
.bootstrap-field-row {
  display: flex;
  gap: 16px;
}
.bootstrap-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger-bd);
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
}
.bootstrap-actions {
  display: flex;
  justify-content: flex-end;
}
.bootstrap-actions .btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 22px;
}
.bootstrap-actions .btn.primary:hover:not(:disabled) {
  filter: brightness(0.92);
}
.bootstrap-actions .btn.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}
.bootstrap-foot {
  font-size: 12px;
  color: var(--ink-3);
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* État viewer : pas de form, juste un message d'attente */
.bootstrap-card.bootstrap-empty {
  text-align: center;
  align-items: center;
}
.bootstrap-icon {
  font-size: 40px;
  line-height: 1;
}
.bootstrap-card.bootstrap-empty h1 {
  margin: 0;
}
.bootstrap-card.bootstrap-empty p {
  max-width: 420px;
  margin: 0 auto;
}

/* ====================================================
   Modal globale (alertAction / confirmAction)
   Voir public/modal.jsx — overlay + boîte centrée
   ==================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55); /* slate-900 / 55% */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: modal-fade-in 120ms ease-out;
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-box {
  background: #fff;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.35);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  padding: 20px 22px 16px;
  animation: modal-slide-in 140ms ease-out;
}
@keyframes modal-slide-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-1, #0f172a);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.modal-message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2, #334155);
  margin-bottom: 18px;
}
.modal-message p {
  margin: 0 0 6px 0;
}
.modal-message p:last-child {
  margin-bottom: 0;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

/* Pastille animée pour l'état "saving" du saved-indicator (remplace le ● émoji) */
.saving-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: saving-pulse 0.9s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes saving-pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* Alignement icône + texte dans les boutons "Ajouter / Créer" */
.add-row-btn,
.add-section-btn,
.add-phase-btn,
.add-stack-btn,
.version-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.add-row-btn .icon,
.add-section-btn .icon,
.add-phase-btn .icon,
.add-stack-btn .icon,
.version-create-btn .icon {
  flex-shrink: 0;
}

/* ====================================================
   Responsive — onglet Chiffrage
   Breakpoints :
     - 1100 px : KPI grid passe de 4 → 2 colonnes
     - 900  px : CTA bar empilée, tjm-controls empilés, phase-head empilé,
                 commit-selector en colonne
     - 600  px : KPI grid en 1 colonne
   ==================================================== */

@media (max-width: 1100px) {
  /* KPIs : 4 → 2 colonnes */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  /* CTA Régie / Forfait : empilées verticalement */
  .cta-bar {
    grid-template-columns: 1fr;
  }

  /* Phase head : passe en colonne pour que les totaux ne soient pas écrasés */
  .phase-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .phase-head-left {
    width: 100%;
    /* Permet au bloc title/desc (3e enfant) de passer sous le caret+label */
    flex-wrap: wrap;
  }
  .phase-head-left > div {
    flex-basis: 100%;
    width: 100%;
    margin-top: 4px;
  }
  /* Totaux alignés à droite (et non répartis), pour rester compacts en mobile */
  .phase-totals {
    width: 100%;
    justify-content: flex-end;
  }

  /* TJM controls : passe en colonne, dividers horizontaux, inputs pleine largeur */
  .tjm-controls {
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }
  .tjm-controls .tjm-control {
    padding: 0;
    width: 100%;
  }
  .tjm-controls .tjm-control:first-child { padding-left: 0; }
  .tjm-controls .tjm-control input {
    width: 100%;
    box-sizing: border-box;
  }
  .tjm-divider {
    width: 100%;
    height: 1px;
    margin: 0;
  }

  /* Commit selector : titre + hint en haut, chips empilés en colonne dessous */
  .commit-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .commit-chips {
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
  }
  .commit-chips .commit-chip {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  /* Tabs-bar : on masque les labels et on ne garde que l'icône
     pour que les 4 tabs + l'indicateur de save tiennent sur une ligne. */
  .tab-btn {
    padding: 14px 12px;
  }
  .tab-btn-label {
    display: none;
  }
  .tab-btn-icon {
    font-size: 18px;
  }

  /* Sous-onglets de l'onglet Informations (Critiques) :
     6 tabs en grille 6 colonnes égales — pas de scroll, hauteur naturelle.
     Le compteur passe en badge superposé pour ne pas prendre de place
     horizontalement. */
  .crit-tabs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    flex-wrap: initial;
    overflow: visible;
  }
  .crit-tab {
    padding: 10px 4px;
    justify-content: center;
    min-width: 0;
    position: relative;
  }
  .crit-tab-label {
    display: none;
  }
  .crit-tab-icon {
    font-size: 18px;
  }
  /* Compteur en badge superposé en haut à droite de chaque tab —
     reste visible sans manger d'espace horizontal */
  .crit-tab-count {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    padding: 0 4px;
    min-width: 14px;
    transform-origin: top right;
  }
}

@media (max-width: 600px) {
  /* KPIs : 2 → 1 colonne sur mobile */
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  /* Lexique : 2 → 1 colonne, les cards prennent toute la largeur dispo */
  .lexique-grid {
    grid-template-columns: 1fr;
  }
  /* Toolbar de recherche : champ en pleine largeur, compteur + bouton ajouter
     se placent dessous grâce au flex-wrap déjà actif */
  .lex-search {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
}

/* ====================================================
   Toggle Édition / Lecture (admin uniquement, dans la topbar)
   ==================================================== */
.edit-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--r-full);
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit;
}
.edit-mode-toggle:hover { background: rgba(255,255,255,0.14); }
.edit-mode-toggle.is-edit {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}
.edit-mode-toggle.is-edit:hover { background: rgba(245, 158, 11, 0.28); }

/* ====================================================
   Topbar — bouton déconnexion responsive
   ==================================================== */
.topbar-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.2);
  color: #f1f5f9;
}

/* ====================================================
   Responsive — Topbar et Version-menu
   ==================================================== */
@media (max-width: 900px) {
  .topbar {
    padding: 12px 16px;
    gap: 10px;
  }
  /* Brand : on garde le logo + le nom court mais on masque le sous-titre · projet */
  .topbar .brand small {
    display: none;
  }
  /* Last-modified : on garde la date mais on masque le label "Dernière modification" */
  .last-modified-label {
    display: none;
  }
  /* Edit-mode toggle : icône seule */
  .edit-mode-toggle-label {
    display: none;
  }
  /* User-pill : on masque le nom utilisateur, on ne garde que le rôle */
  .user-pill-name {
    display: none;
  }
  /* Logout : icône seule */
  .topbar-logout-label {
    display: none;
  }
  /* Version trigger : label tronqué plus court */
  .version-trigger-label {
    max-width: 120px;
  }
}

@media (max-width: 600px) {
  /* Last-modified entièrement masqué : trop d'info pour un petit écran */
  .last-modified-badge {
    display: none;
  }
  /* Version-trigger : on masque le label complètement, garde juste l'id (vN) */
  .version-trigger-label {
    display: none;
  }
}

/* Version-menu — adapter à l'écran pour ne pas déborder */
@media (max-width: 600px) {
  .version-menu {
    /* Position fixed sur la viewport au lieu d'absolute relative au picker —
       garantit que le menu reste centré horizontalement même quand le trigger
       est aligné à gauche dans la topbar. */
    position: fixed;
    top: 60px;                         /* sous la topbar (~52 px en mobile) */
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - 80px);    /* limite verticale, scroll interne si besoin */
    overflow-y: auto;
  }
  .version-item-row {
    gap: 6px;
  }
  .version-item-label {
    font-size: 12px;
  }
  .version-item-meta {
    font-size: 10px;
  }
}

/* ============ Onglet Ressources ============ */
.resources-dropzone {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  margin: 16px 0;
  border: 2px dashed var(--line-2);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.resources-dropzone:hover,
.resources-dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
  outline: none;
}
.resources-dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
  border-style: solid;
}
.resources-dropzone.uploading {
  pointer-events: none;
  opacity: 0.7;
}
.resources-dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.resources-dropzone-title {
  font-size: 14px;
  font-weight: 600;
}
.resources-dropzone-hint {
  font-size: 12px;
  color: var(--ink-3);
}

.resources-errors {
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--warning-soft);
  border: 1px solid var(--warning-bd);
  border-left: 3px solid var(--warning);
  border-radius: var(--r-sm);
  color: #78350f;
  font-size: 13px;
}
.resources-errors-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 4px;
}
.resources-errors ul {
  margin: 4px 0 0 0;
  padding-left: 22px;
}

.resources-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.resources-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}
.resources-empty.resources-error {
  background: var(--danger-soft);
  border-color: var(--danger-bd);
  color: #991b1b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.resource-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.resource-row.clickable {
  cursor: pointer;
}
.resource-row.clickable:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: var(--shadow-xs);
}
.resource-row.clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.resource-icon {
  color: var(--ink-3);
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}
.resource-row.clickable:hover .resource-icon {
  color: var(--primary);
}

.resource-meta {
  flex: 1;
  min-width: 0;
}
.resource-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.resource-sub {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.resource-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ============ Poignée de drag des lignes du chiffrage ============ */
.drag-handle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: grab;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: var(--r-sm);
  user-select: none;
  -webkit-user-select: none;
  color: var(--ink);
}
.drag-handle:hover {
  background: var(--bg-3);
}
.drag-handle:active {
  cursor: grabbing;
  background: var(--primary-soft);
}
.drag-handle-icon {
  color: var(--ink-4);
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}
.drag-handle:hover .drag-handle-icon {
  color: var(--primary);
}
.drag-handle-id {
  font-family: var(--font-mono);
}
