/* ═══════════════════════════════════════════════════════════════════════
   Composants
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: .5px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 22px 24px;
  transition: transform .3s var(--ease-bounce), box-shadow .3s ease, border-color .3s ease;
}
.card.is-flat { padding: 0; overflow: hidden; }
.card.is-tight { padding: 16px 18px; }
.card.hoverable:hover { transform: translateY(-4px); box-shadow: var(--shadow-card); border-color: var(--border); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
}
.card-title { font-size: 14px; font-weight: 500; color: var(--text-dark); }
.card-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.card-pad { padding: 22px 24px; }
.card-footer { border-top: .5px solid var(--border-light); padding-top: 14px; margin-top: 16px; }

.chip {
  font-size: 11.5px; font-weight: 500; background: var(--accent-light);
  color: var(--accent-text); padding: 4px 12px; border-radius: 999px;
  transition: background .2s ease, transform .2s ease; white-space: nowrap;
}
.card:hover .chip { background: var(--accent-wash); transform: scale(1.03); }
.chip.is-neutral { background: var(--gray-100); color: var(--text-mid); }
.chip.is-warn { background: var(--warn-bg); color: var(--warn-text); }
.chip.is-alert { background: var(--alert-bg); color: var(--alert-text); }

/* ── KPI ─────────────────────────────────────────────────────── */
.kpi {
  background: var(--bg-card); border: .5px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 20px 22px;
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease-bounce), box-shadow .3s ease, border-color .3s ease;
}
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-card); border-color: var(--border); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.kpi-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--accent-light);
  transition: transform .25s var(--ease-bounce);
}
.kpi:hover .kpi-icon { transform: scale(1.1) rotate(-3deg); }
.kpi-icon svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 1.8; }
.kpi-icon.is-warn { background: var(--warn-bg); } .kpi-icon.is-warn svg { stroke: var(--warn-dot); }
.kpi-icon.is-alert { background: var(--alert-bg); } .kpi-icon.is-alert svg { stroke: var(--alert-dot); }
.kpi-icon.is-neutral { background: var(--gray-100); } .kpi-icon.is-neutral svg { stroke: var(--gray-500); }
.kpi-right { text-align: right; min-width: 0; }
.kpi-value { font-size: 24px; font-weight: 500; letter-spacing: -.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 400; color: var(--text-light); }
.kpi-unit { font-size: 12.5px; color: var(--text-light); margin-top: 2px; }
.kpi-unit.is-up { color: var(--accent); font-weight: 500; }
.kpi-unit.is-down { color: var(--alert-text); font-weight: 500; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-mid); margin-top: 12px; }
.kpi-spark { margin-top: 12px; padding: 0 2px; position: relative; }
.kpi-spark svg { width: 100%; height: 48px; display: block; overflow: visible; }

/* ── Boutons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13.5px; font-weight: 500; padding: 9px 16px;
  border-radius: var(--radius-sm); background: var(--bg-card);
  border: .5px solid var(--border); color: var(--text-dark);
  transition: background .2s, border-color .2s, box-shadow .2s, transform .2s var(--ease-bounce);
  white-space: nowrap;
}
.btn:hover { border-color: var(--gray-300); box-shadow: var(--shadow-light); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.btn.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.is-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: var(--shadow-accent); }
.btn.is-ghost { background: transparent; border-color: transparent; color: var(--text-mid); }
.btn.is-ghost:hover { background: var(--gray-100); color: var(--text-dark); box-shadow: none; }
.btn.is-danger { color: var(--alert-text); border-color: var(--alert-bg); background: var(--alert-bg); }
.btn.is-danger:hover { background: #FBE6E6; border-color: var(--alert-dot); }
.btn.sm { font-size: 12.5px; padding: 6px 12px; border-radius: var(--radius-xs); }
.btn.xs { font-size: 11.5px; padding: 4px 9px; border-radius: var(--radius-xs); }
.btn.icon { padding: 8px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.link-action {
  font-size: 12.5px; font-weight: 500; color: var(--accent);
  display: inline-flex; align-items: center; gap: 4px;
  transition: opacity .15s, transform .15s;
}
.link-action:hover { opacity: .78; transform: translateX(3px); }

/* ── Recherche ───────────────────────────────────────────────── */
.search-box {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-card); border: .5px solid var(--border);
  border-radius: var(--radius-md); padding: 9px 16px;
  font-size: 13.5px; color: var(--text-light); min-width: 240px;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:hover, .search-box:focus-within { border-color: var(--gray-300); box-shadow: var(--shadow-light); }
.search-box svg { width: 16px; height: 16px; stroke: var(--text-light); fill: none; stroke-width: 1.5; flex-shrink: 0; }
.search-box input { border: none; outline: none; background: none; flex: 1; color: var(--text-dark); min-width: 0; }
.search-box input::placeholder { color: var(--text-light); }
.search-box kbd {
  font-size: 10.5px; font-family: var(--font); color: var(--text-light);
  background: var(--gray-100); border-radius: 6px; padding: 2px 6px; border: .5px solid var(--border);
}

/* ── Tableaux ────────────────────────────────────────────────── */
.table { width: 100%; font-size: 13.5px; }
.table th {
  font-size: 11.5px; font-weight: 500; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .5px; text-align: left;
  padding: 10px 12px 10px 0; border-bottom: .5px solid var(--border); white-space: nowrap;
}
.table th.u-right { text-align: right; }
.table td { padding: 13px 12px 13px 0; border-bottom: .5px solid var(--border-light); vertical-align: middle; }
.table td.u-right { text-align: right; }
/* Seule la dernière colonne colle au bord : sinon les colonnes alignées
   à droite se touchent et les valeurs se chevauchent. */
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .2s ease; }
.table tbody tr.is-linked { cursor: pointer; }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:hover td:first-child { color: var(--accent-dark); }
.table td:first-child, .table th:first-child { padding-left: 4px; }
.table .cell-main { font-weight: 500; }
.table .cell-sub { font-size: 11.5px; color: var(--text-light); margin-top: 2px; }
.table tbody tr { animation: rowSlide .4s ease both; }
.table tbody tr:nth-child(1) { animation-delay: .04s; } .table tbody tr:nth-child(2) { animation-delay: .08s; }
.table tbody tr:nth-child(3) { animation-delay: .12s; } .table tbody tr:nth-child(4) { animation-delay: .16s; }
.table tbody tr:nth-child(5) { animation-delay: .20s; } .table tbody tr:nth-child(6) { animation-delay: .24s; }
.table tbody tr:nth-child(7) { animation-delay: .28s; } .table tbody tr:nth-child(8) { animation-delay: .32s; }
.table tbody tr:nth-child(n+9) { animation-delay: .36s; }
.table tfoot td { padding: 14px 12px 4px 0; border-top: .5px solid var(--border); font-weight: 500; border-bottom: none; }

.table-scroll { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }

/* ── Badges de statut ────────────────────────────────────────── */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--gray-100); color: var(--gray-600);
  transition: transform .2s var(--ease-bounce), box-shadow .2s;
}
tr:hover .status { transform: scale(1.04); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gray-400); flex-shrink: 0; }
.status.is-active { background: var(--accent-light); color: var(--accent-text); }
.status.is-active .status-dot { background: var(--accent); animation: pulseDot 2.4s ease-in-out infinite; }
.status.is-pending { background: var(--warn-bg); color: var(--warn-text); }
.status.is-pending .status-dot { background: var(--warn-dot); }
.status.is-alert { background: var(--alert-bg); color: var(--alert-text); }
.status.is-alert .status-dot { background: var(--alert-dot); }
.status.is-info { background: var(--info-bg); color: var(--info-text); }
.status.is-info .status-dot { background: var(--info-dot); }
.status.is-done { background: var(--gray-100); color: var(--gray-600); }

/* ── Barre de progression ────────────────────────────────────── */
.progress-cell { display: flex; align-items: center; gap: 10px; }
.progress-track { width: 64px; height: 4px; background: var(--gray-100); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.progress-track.wide { width: 100%; }
.progress-track.tall { height: 6px; }
.progress-fill {
  height: 100%; border-radius: 3px; background: var(--accent);
  animation: progressGrow .8s var(--ease-out) both; transition: width .35s var(--ease-out), background .2s;
}
.progress-fill.is-done { background: var(--gray-300); }
.progress-fill.is-empty { background: var(--gray-200); }
.progress-fill.is-alert { background: var(--alert-dot); }
.progress-pct { font-size: 12.5px; color: var(--text-mid); min-width: 34px; font-variant-numeric: tabular-nums; }
.progress-pct.is-empty { color: var(--text-light); }

/* ── Barre budget vs réalisé ─────────────────────────────────── */
.budget-bar { position: relative; height: 22px; background: var(--gray-100); border-radius: var(--radius-xs); overflow: hidden; }
.budget-bar-fill {
  position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .85;
  border-radius: var(--radius-xs); transform-origin: left;
  animation: barGrow .8s var(--ease-out) both; transition: width .4s var(--ease-out);
}
.budget-bar-fill.is-over { background: var(--alert-dot); }
.budget-bar-marker {
  position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--gray-700);
  border-radius: 2px; z-index: 2;
}
.budget-bar-marker::after {
  content: attr(data-label); position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; color: var(--text-light); white-space: nowrap;
}

/* ── Formulaires ─────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-mid); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--text-light); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; background: var(--bg-card); border: .5px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13.5px;
  color: var(--text-dark); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-300); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.input::placeholder, .textarea::placeholder { color: var(--text-light); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239C9A92' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.input.u-right { text-align: right; font-variant-numeric: tabular-nums; }
.field-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Édition inline dans un tableau */
.input-inline {
  border: .5px solid transparent; background: transparent; border-radius: var(--radius-xs);
  padding: 4px 8px; font-size: 13.5px; width: 100%; text-align: right;
  font-variant-numeric: tabular-nums; outline: none;
  transition: background .15s, border-color .15s;
}
.input-inline:hover { background: var(--gray-50); border-color: var(--border); }
.input-inline:focus { background: var(--bg-card); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* Curseur (coefficient, avancement) */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: var(--gray-100); border-radius: 3px; outline: none; cursor: pointer; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--accent); cursor: grab;
  box-shadow: var(--shadow-light); transition: transform .18s var(--ease-bounce), box-shadow .18s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.18); box-shadow: var(--shadow-accent); }
.slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.06); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--bg-card);
  border: 2px solid var(--accent); cursor: grab; }

/* ── Onglets ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 3px; border-bottom: .5px solid var(--border); margin-bottom: 22px; }
.tab {
  padding: 9px 15px; font-size: 13.5px; color: var(--text-mid);
  border-bottom: 1.5px solid transparent; margin-bottom: -1px;
  transition: color .2s, border-color .2s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text-dark); }
.tab.active { color: var(--text-dark); font-weight: 500; border-bottom-color: var(--accent); }
.tab .nav-count { margin-left: 0; }

/* ── Bandeau d'alerte ────────────────────────────────────────── */
.banner {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 20px; border-radius: var(--radius-lg);
  background: var(--alert-bg); border: .5px solid #F5DADA;
  margin-bottom: 18px; animation: fadeSlideUp .5s var(--ease-out) both;
}
.banner.is-warn { background: var(--warn-bg); border-color: #F7E3C4; }
.banner.is-ok { background: var(--accent-light); border-color: #DFE7DE; }
.banner.is-info { background: var(--info-bg); border-color: #DCE4EC; }
.banner-icon { width: 32px; height: 32px; border-radius: var(--radius-xs); background: rgba(255,255,255,.65);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.banner-icon svg { width: 17px; height: 17px; fill: none; stroke-width: 1.8; stroke: var(--alert-text); }
.banner.is-warn .banner-icon svg { stroke: var(--warn-text); }
.banner.is-ok .banner-icon svg { stroke: var(--accent-text); }
.banner.is-info .banner-icon svg { stroke: var(--info-text); }
.banner-title { font-size: 13.5px; font-weight: 500; color: var(--alert-text); }
.banner.is-warn .banner-title { color: var(--warn-text); }
.banner.is-ok .banner-title { color: var(--accent-text); }
.banner.is-info .banner-title { color: var(--info-text); }
.banner-text { font-size: 12.5px; color: var(--text-mid); margin-top: 2px; line-height: 1.5; }

/* ── État vide ───────────────────────────────────────────────── */
.empty { text-align: center; padding: 44px 20px; }
.empty-icon { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--gray-100);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.empty-icon svg { width: 20px; height: 20px; stroke: var(--gray-400); fill: none; stroke-width: 1.5; }
.empty-title { font-size: 13.5px; font-weight: 500; color: var(--text-mid); }
.empty-text { font-size: 12.5px; color: var(--text-light); margin-top: 5px; }

/* ── Tooltip ─────────────────────────────────────────────────── */
.tip { position: absolute; background: var(--gray-800); color: #fff; font-size: 12px;
  padding: 6px 11px; border-radius: var(--radius-xs); box-shadow: var(--shadow-tooltip);
  pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 70; white-space: nowrap; }
.tip.show { opacity: 1; }

/* ── Toasts ──────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--gray-800); color: #fff; font-size: 13px;
  padding: 12px 17px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); animation: toastIn .34s var(--ease-bounce) both;
  max-width: 380px;
}
.toast.is-leaving { animation: toastOut .22s ease forwards; }
.toast svg { width: 16px; height: 16px; stroke: var(--accent-mid); fill: none; stroke-width: 1.8; flex-shrink: 0; }
.toast.is-alert svg { stroke: #E99393; }

/* ── Modale / panneau ────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(44,44,42,.22); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn .2s ease both; backdrop-filter: blur(2px);
}
.modal {
  background: var(--bg-card); border-radius: var(--radius-xl); width: 100%; max-width: 620px;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-pop);
  animation: popIn .3s var(--ease-bounce) both;
}
.modal.lg { max-width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 16px; border-bottom: .5px solid var(--border-light); }
.modal-title { font-size: 16px; font-weight: 500; letter-spacing: -.2px; }
.modal-body { padding: 22px 26px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 26px 22px; border-top: .5px solid var(--border-light); }

/* ── Palette de commandes (⌘K) ───────────────────────────────── */
.palette-overlay { position: fixed; inset: 0; background: rgba(44,44,42,.2); z-index: 95;
  display: flex; align-items: flex-start; justify-content: center; padding: 14vh 24px 24px;
  animation: fadeIn .16s ease both; backdrop-filter: blur(3px); }
.palette { background: var(--bg-card); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-pop); overflow: hidden; animation: popIn .26s var(--ease-bounce) both; }
.palette-input { display: flex; align-items: center; gap: 11px; padding: 16px 20px;
  border-bottom: .5px solid var(--border-light); }
.palette-input svg { width: 17px; height: 17px; stroke: var(--text-light); fill: none; stroke-width: 1.6; }
.palette-input input { flex: 1; border: none; outline: none; background: none; font-size: 15px; }
.palette-list { max-height: 54vh; overflow-y: auto; padding: 8px; }
.palette-section { font-size: 10.5px; font-weight: 500; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .6px; padding: 10px 12px 6px; }
.palette-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border-radius: var(--radius-xs); font-size: 13.5px; cursor: pointer; transition: background .12s; }
.palette-item:hover, .palette-item.active { background: var(--gray-50); }
.palette-item.active { background: var(--accent-light); color: var(--accent-text); }
.palette-item svg { width: 16px; height: 16px; stroke: var(--text-light); fill: none; stroke-width: 1.5; }
.palette-item.active svg { stroke: var(--accent); }
.palette-item .meta { margin-left: auto; font-size: 11.5px; color: var(--text-light); }

/* ── Liste de définitions (cascade financière) ───────────────── */
.dl { display: flex; flex-direction: column; gap: 1px; }
.dl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 8px 0; font-size: 13px; transition: background .15s; }
.dl-row:hover { background: var(--gray-50); }
.dl-row dt { color: var(--text-mid); }
.dl-row dd { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dl-row.is-sub dt, .dl-row.is-sub dd { font-size: 12.5px; color: var(--text-light); font-weight: 400; }
.dl-row.is-total { border-top: .5px solid var(--border); margin-top: 6px; padding-top: 12px; }
.dl-row.is-grand { border-top: 1px solid var(--gray-800); margin-top: 8px; padding-top: 13px; }
.dl-row.is-grand dt { color: var(--text-dark); font-weight: 500; }
.dl-row.is-grand dd { font-size: 17px; letter-spacing: -.3px; }
.dl-row.is-deduct dd { color: var(--alert-text); }
.dl-row.is-add dd { color: var(--accent-dark); }

/* ── Arborescence DPGF ───────────────────────────────────────── */
.tree-lot { border: .5px solid var(--border-light); border-radius: var(--radius-sm);
  margin-bottom: 10px; overflow: hidden; background: var(--bg-card); transition: border-color .2s, box-shadow .2s; }
.tree-lot:hover { border-color: var(--border); }
.tree-lot.is-open { box-shadow: var(--shadow-light); }
.tree-lot-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  cursor: pointer; transition: background .18s; }
.tree-lot-head:hover { background: var(--gray-50); }
.tree-caret { width: 15px; height: 15px; stroke: var(--text-light); fill: none; stroke-width: 1.8;
  transition: transform .25s var(--ease-bounce); flex-shrink: 0; }
.tree-lot.is-open .tree-caret { transform: rotate(90deg); }
.tree-code { font-size: 11.5px; font-weight: 500; color: var(--text-light);
  background: var(--gray-100); padding: 2px 8px; border-radius: 6px; flex-shrink: 0; }
.tree-label { font-size: 13.5px; font-weight: 500; flex: 1; min-width: 0; }
.tree-body { display: none; border-top: .5px solid var(--border-light); background: var(--gray-50); }
.tree-lot.is-open > .tree-body { display: block; animation: fadeIn .22s ease both; }
.tree-work { border-bottom: .5px solid var(--border-light); }
.tree-work:last-child { border-bottom: none; }
.tree-work-head { display: flex; align-items: center; gap: 11px; padding: 10px 16px 10px 32px;
  cursor: pointer; font-size: 13px; transition: background .15s; }
.tree-work-head:hover { background: var(--gray-100); }
.tree-work.is-open .tree-caret { transform: rotate(90deg); }
.tree-lines { display: none; padding: 4px 16px 10px 56px; background: var(--bg-card); }
.tree-work.is-open .tree-lines { display: block; animation: fadeIn .2s ease both; }
.tree-line { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 12.5px;
  color: var(--text-mid); border-bottom: .5px solid var(--border-light); }
.tree-line:last-child { border-bottom: none; }
.tree-cat { font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  padding: 2px 7px; border-radius: 5px; background: var(--gray-100); color: var(--text-light); flex-shrink: 0; }
.tree-cat.is-mo { background: var(--accent-light); color: var(--accent-text); }
.tree-cat.is-st { background: var(--info-bg); color: var(--info-text); }
.tree-amount { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500;
  color: var(--text-dark); white-space: nowrap; }

/* ── Planning hebdo ──────────────────────────────────────────── */
.planning { overflow-x: auto; }
.planning-grid { display: grid; grid-template-columns: 180px repeat(5, minmax(128px, 1fr)); gap: 1px;
  background: var(--border-light); border: .5px solid var(--border-light);
  border-radius: var(--radius-sm); overflow: hidden; min-width: 820px; }
.planning-cell { background: var(--bg-card); padding: 9px 11px; min-height: 60px; }
.planning-head { background: var(--gray-50); font-size: 11.5px; font-weight: 500;
  color: var(--text-light); text-transform: uppercase; letter-spacing: .5px;
  min-height: 0; padding: 10px 11px; }
.planning-head.is-today { color: var(--accent-text); background: var(--accent-light); }
.planning-worker { background: var(--gray-50); display: flex; align-items: center; gap: 9px; }
.planning-worker-name { font-size: 12.5px; font-weight: 500; line-height: 1.25; }
.planning-worker-trade { font-size: 10.5px; color: var(--text-light); }
.planning-cell.is-drop { transition: background .15s, box-shadow .15s; }
.planning-cell.is-drop.over { background: var(--accent-light); box-shadow: inset 0 0 0 1px var(--accent); }
.planning-chip {
  display: block; font-size: 11.5px; padding: 5px 9px; border-radius: var(--radius-xs);
  background: var(--accent-light); color: var(--accent-text); margin-bottom: 4px;
  cursor: grab; transition: transform .18s var(--ease-bounce), box-shadow .18s;
  border-left: 2px solid var(--accent); line-height: 1.3;
}
.planning-chip:hover { transform: translateX(2px); box-shadow: var(--shadow-light); }
.planning-chip.dragging { opacity: .4; cursor: grabbing; }
.planning-chip.is-alt { background: var(--gray-100); color: var(--text-mid); border-left-color: var(--gray-400); }

/* ── Gantt ───────────────────────────────────────────────────── */
.gantt { overflow-x: auto; padding-bottom: 6px; }
.gantt-inner { min-width: 760px; position: relative; }
.gantt-row { display: grid; grid-template-columns: 210px 1fr; align-items: center;
  gap: 14px; padding: 6px 0; transition: background .15s; border-radius: var(--radius-xs); }
.gantt-row:hover { background: var(--gray-50); }
.gantt-label { font-size: 12.5px; display: flex; align-items: center; gap: 9px; min-width: 0; }
.gantt-track { position: relative; height: 24px; }
.gantt-bar {
  position: absolute; top: 4px; height: 16px; border-radius: 6px;
  background: var(--accent-light); border: .5px solid var(--accent-mid);
  transform-origin: left; animation: ganttGrow .6s var(--ease-out) both;
  cursor: pointer; transition: box-shadow .2s, filter .2s;
}
.gantt-bar:hover { box-shadow: var(--shadow-light); filter: brightness(.97); }
.gantt-bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent);
  border-radius: 5px; opacity: .9; }
.gantt-bar.is-late { background: var(--alert-bg); border-color: var(--alert-dot); }
.gantt-bar.is-late .gantt-bar-fill { background: var(--alert-dot); }
.gantt-bar.is-done { background: var(--gray-100); border-color: var(--gray-300); }
.gantt-bar.is-done .gantt-bar-fill { background: var(--gray-300); }
.gantt-months { display: grid; grid-template-columns: 210px 1fr; gap: 14px;
  padding-bottom: 8px; border-bottom: .5px solid var(--border-light); margin-bottom: 8px; }
.gantt-scale { display: flex; position: relative; }
.gantt-month { font-size: 11px; color: var(--text-light); text-transform: uppercase;
  letter-spacing: .4px; border-left: .5px solid var(--border-light); padding-left: 6px; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent);
  opacity: .5; z-index: 3; pointer-events: none; }
.gantt-today::before { content: ''; position: absolute; top: -3px; left: -2.5px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ── Graphiques ──────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 200px; }
.chart-wrap.sm { height: 150px; }
.chart-wrap.lg { height: 268px; }
.donut-wrap { display: flex; align-items: center; gap: 26px; }
.donut-box { position: relative; flex-shrink: 0; }
.donut-box svg { width: 140px; height: 140px; transform: rotate(-90deg); }
.donut-ring { fill: none; stroke-width: 7; stroke-linecap: round;
  transition: stroke-width .25s var(--ease-bounce), filter .25s; cursor: pointer; }
.donut-ring:hover { stroke-width: 11; filter: brightness(1.08); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
  animation: donutNum .4s ease both .55s; }
.donut-num { font-size: 22px; font-weight: 500; letter-spacing: -.4px; }
.donut-sub { font-size: 11px; color: var(--text-light); margin-top: 1px; }
.donut-legend { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 6px 9px;
  border-radius: var(--radius-xs); font-size: 13px; transition: background .15s, transform .15s; }
.legend-row:hover { background: var(--gray-50); transform: translateX(3px); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; transition: transform .2s; }
.legend-row:hover .legend-swatch { transform: scale(1.3); }
.legend-val { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ── Jauge demi-cercle (marge) ───────────────────────────────── */
.gauge { position: relative; width: 100%; max-width: 230px; margin: 0 auto; }
.gauge svg { width: 100%; display: block; overflow: visible; }
.gauge-track { fill: none; stroke: var(--gray-100); stroke-width: 9; stroke-linecap: round; }
.gauge-fill { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  animation: gaugeSweep 1s var(--ease-out) both .2s; transition: stroke-dashoffset .5s var(--ease-out), stroke .3s; }
.gauge-fill.is-warn { stroke: var(--warn-dot); }
.gauge-fill.is-alert { stroke: var(--alert-dot); }
.gauge-center { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; }
.gauge-value { font-size: 26px; font-weight: 500; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.gauge-label { font-size: 11.5px; color: var(--text-light); margin-top: 1px; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash-msg { display: flex; align-items: center; gap: 11px; padding: 12px 18px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px;
  background: var(--accent-light); color: var(--accent-text);
  animation: fadeSlideUp .4s var(--ease-out) both; }
.flash-msg.is-alert { background: var(--alert-bg); color: var(--alert-text); }
.flash-msg svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ── Divers ──────────────────────────────────────────────────── */
.meta-list { display: flex; flex-direction: column; gap: 13px; }
.meta-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; font-size: 13px; }
.meta-item dt { color: var(--text-light); font-size: 12.5px; }
.meta-item dd { font-weight: 500; text-align: right; }
.divider { height: .5px; background: var(--border-light); margin: 18px 0; }
.pill-group { display: inline-flex; background: var(--gray-100); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.pill-group a { font-size: 12.5px; padding: 5px 13px; border-radius: var(--radius-xs);
  color: var(--text-mid); transition: background .18s, color .18s; }
.pill-group a:hover { color: var(--text-dark); }
.pill-group a.active { background: var(--bg-card); color: var(--text-dark); font-weight: 500; box-shadow: var(--shadow-nav); }
.stat-inline { display: flex; align-items: baseline; gap: 7px; }
.stat-inline .v { font-size: 19px; font-weight: 500; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stat-inline .u { font-size: 12px; color: var(--text-light); }

/* ── Code couleur par chantier dans le planning ───────────────── */
/* Six teintes sourdes, dans l'esprit de la palette : on doit lire la
   répartition des équipes d'un coup d'œil sans casser l'harmonie. */
.planning-chip.c0 { background: var(--accent-light); color: var(--accent-text); border-left-color: var(--accent); }
.planning-chip.c1 { background: var(--info-bg);   color: var(--info-text);   border-left-color: var(--info-dot); }
.planning-chip.c2 { background: var(--warn-bg);   color: var(--warn-text);   border-left-color: var(--warn-dot); }
.planning-chip.c3 { background: #F1EDE7;          color: #7A6A55;            border-left-color: #B09A7A; }
.planning-chip.c4 { background: #EDEBF1;          color: #5D5570;            border-left-color: #9A91B0; }
.planning-chip.c5 { background: var(--gray-100);  color: var(--gray-600);    border-left-color: var(--gray-400); }
.planning-chip.c6 { background: #E9F0EF;          color: #3F5B58;            border-left-color: #76A09B; }
.planning-chip.c7 { background: #F4EDED;          color: #7A5252;            border-left-color: #BE8E8E; }

.swatch-c0 { background: var(--accent); }   .swatch-c1 { background: var(--info-dot); }
.swatch-c2 { background: var(--warn-dot); } .swatch-c3 { background: #B09A7A; }
.swatch-c4 { background: #9A91B0; }         .swatch-c5 { background: var(--gray-400); }
.swatch-c6 { background: #76A09B; }         .swatch-c7 { background: #BE8E8E; }

/* ── Ajout en ligne dans l'arborescence DPGF ──────────────────── */
.add-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-light);
  padding: 9px 16px; cursor: pointer; border-radius: var(--radius-xs);
  transition: background .15s, color .15s;
}
.add-row:hover { background: var(--gray-100); color: var(--accent-dark); }
.add-row svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.add-form {
  display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--bg-card);
  border-top: .5px solid var(--border-light);
  animation: fadeIn .2s ease both;
}
.add-form .field { margin: 0; }
.add-form .input, .add-form .select { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
.add-form .select { padding-right: 28px; }
.add-form label { font-size: 10.5px; margin-bottom: 3px; }
.tree-lines .add-row { padding: 7px 0; }

/* ── Tableaux larges ──────────────────────────────────────────
   Dans un conteneur à défilement, le tableau doit garder sa largeur
   minimale et défiler, pas se comprimer jusqu'à ce que les colonnes
   se chevauchent. */
.table-scroll .table { min-width: 880px; }
.table-scroll .table.is-wide { min-width: 1180px; }
.table th.u-right, .table td.u-right { white-space: nowrap; }
.table th { white-space: nowrap; }

/* Colonnes secondaires : masquées sur un écran de portable pour que le
   tableau tienne sans défilement horizontal pendant une démonstration. */
@media (max-width: 1499px) {
  .table .col-optional { display: none; }
}

/* ── Sparkline ────────────────────────────────────────────────── */
.kpi-spark svg.spark { width: 100%; height: 44px; display: block; overflow: visible; }
.spark-line {
  stroke-dasharray: 320; stroke-dashoffset: 320;
  animation: sparkDraw 1.1s var(--ease-out) .45s forwards;
  vector-effect: non-scaling-stroke; transition: stroke-width .2s;
}
.spark-area { opacity: 0; animation: sparkFill .7s ease .95s forwards; }
.spark-dot  { animation: dotPop .4s var(--ease-bounce) 1.35s forwards; }
.kpi:hover .spark-line { stroke-width: 2.2; }
.kpi:hover .spark-area { opacity: .11; }
.kpi:hover .spark-dot  { r: 5; transition: r .2s var(--ease-bounce); }

/* Les légendes de graphique ne doivent jamais passer à la ligne au milieu
   d'un libellé : la carte perd son alignement. */
.card-header .u-flex.u-gap-16 > .u-flex { white-space: nowrap; }
