/* =========================================================
   PRIMA INVEST ERP — APP SHELL & COMPONENTS
   Base : design system Akiwi (couche composants reprise à
   l'identique — mêmes classes, même API) + couche ERP.
   ========================================================= */

/* ---------- App layout : sidebar + subnav + content ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.app--with-subnav { grid-template-columns: var(--sidebar-width) var(--subnav-width) 1fr; }
.app--collapsed   { grid-template-columns: var(--sidebar-width-collapsed) 1fr; }
.app > main { min-width: 0; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar__brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.sidebar__brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0F172A 0%, #334155 100%);
  color: white;
  display: grid; place-items: center;
  font-weight: var(--weight-bold);
  font-size: 13px;
  letter-spacing: -0.02em;
  position: relative;
  flex-shrink: 0;
}
.sidebar__brand-mark::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 4px; right: 4px;
  height: 2px;
  background: var(--color-signature-500);
  border-radius: 999px;
}
.sidebar__brand-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-tight);
}
.sidebar__brand-sub {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  margin-left: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-family: var(--font-mono);
}
.sidebar__search { padding: 12px; border-bottom: 1px solid var(--color-border); }
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__group-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  padding: 12px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: background var(--duration-fast);
}
.nav-item:hover { background: var(--color-surface-hover); color: var(--color-text); text-decoration: none; }
.nav-item--active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-sm);
}
.nav-item--active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--color-primary-600);
}
.nav-item__icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--color-text-subtle); }
.nav-item--active .nav-item__icon { color: var(--color-primary-600); }
.nav-item__badge {
  margin-left: auto;
  font-size: var(--text-xs);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.nav-item--active .nav-item__badge { background: var(--color-primary-100); color: var(--color-primary-700); }
[data-theme="dark"] .nav-item--active .nav-item__badge { background: rgba(10, 110, 136, 0.30); color: var(--color-primary-300); }
.nav-item__badge--alert { background: var(--color-danger-bg); color: var(--color-danger-fg); }

.sidebar__footer {
  border-top: 1px solid var(--color-border);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.user-chip { flex: 1; display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: var(--radius-md); cursor: pointer; }
.user-chip:hover { background: var(--color-surface-hover); }
.user-chip__avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
  color: white;
  display: grid; place-items: center;
  font-size: 11px; font-weight: var(--weight-semibold);
}
.user-chip__name { font-size: var(--text-base); font-weight: var(--weight-medium); line-height: 1.2; }
.user-chip__role { font-size: var(--text-xs); color: var(--color-text-subtle); }

/* ---------- SUBNAV ---------- */
.subnav {
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  height: 100vh; position: sticky; top: 0;
  overflow-y: auto; display: flex; flex-direction: column;
}
.subnav__header { padding: 14px 16px 8px; border-bottom: 1px solid var(--color-border); }
.subnav__title { font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); display: flex; align-items: center; gap: 8px; }
.subnav__sub { font-size: var(--text-xs); color: var(--color-text-subtle); margin-top: 2px; }
.subnav__body { padding: 8px; flex: 1; }
.subnav__actions { padding: 10px 12px; border-top: 1px solid var(--color-border); }

/* ---------- TOPBAR ---------- */
.topbar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar__breadcrumb { display: flex; align-items: center; gap: 8px; font-size: var(--text-base); color: var(--color-text-muted); }
.topbar__breadcrumb-current { color: var(--color-text); font-weight: var(--weight-medium); }
.topbar__breadcrumb-sep { color: var(--color-text-disabled); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1; height: 30px;
  border: 1px solid transparent;
  background: transparent; color: var(--color-text);
  cursor: pointer; transition: all var(--duration-fast);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn[disabled], .btn--disabled { opacity: .5; pointer-events: none; }

.btn--primary { background: var(--color-primary-600); color: var(--color-text-on-primary); border-color: var(--color-primary-600); box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--color-primary-700); border-color: var(--color-primary-700); color: white; }
.btn--secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--color-surface-hover); border-color: var(--color-text-subtle); color: var(--color-text); }
.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover { background: var(--color-bg-subtle); color: var(--color-text); }
.btn--danger { background: var(--color-danger-solid); color: white; border-color: var(--color-danger-solid); }
.btn--danger:hover { background: var(--color-danger-fg); color: white; }
.btn--success { background: var(--color-success-solid); color: white; border-color: var(--color-success-solid); }
.btn--success:hover { filter: brightness(0.92); color: white; }

.btn--sm { height: 26px; padding: 4px 9px; font-size: var(--text-sm); }
.btn--sm svg { width: 13px; height: 13px; }
.btn--lg { height: 38px; padding: 8px 16px; font-size: var(--text-md); }
.btn--lg svg { width: 16px; height: 16px; }
.btn--icon { width: 30px; padding: 0; }
.btn--icon.btn--sm { width: 26px; }
.btn--icon.btn--lg { width: 38px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); margin-left: 0; }
.btn-group .btn:last-child  { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }

/* ---------- INPUTS ---------- */
.input, .textarea, .select {
  width: 100%; height: 32px; padding: 6px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  font-family: inherit;
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-disabled); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--color-primary-600); box-shadow: var(--shadow-focus); }
.textarea { height: auto; min-height: 72px; padding: 8px 10px; line-height: var(--leading-base); resize: vertical; }
.select { padding-right: 26px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text); display: flex; align-items: center; gap: 6px; }
.field__hint { font-size: var(--text-sm); color: var(--color-text-subtle); }
.field__error { font-size: var(--text-sm); color: var(--color-danger-fg); }

.input-group {
  display: flex; align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 0 8px; height: 32px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.input-group:focus-within { border-color: var(--color-primary-600); box-shadow: var(--shadow-focus); }
.input-group svg { width: 14px; height: 14px; color: var(--color-text-subtle); flex-shrink: 0; }
.input-group .input { border: none; padding: 0 6px; height: auto; background: transparent; box-shadow: none !important; }
.input-group .input:focus { box-shadow: none; }

.kbd {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 5px;
  border: 1px solid var(--color-border-strong); border-bottom-width: 2px;
  border-radius: var(--radius-xs); background: var(--color-bg-subtle);
  color: var(--color-text-muted); line-height: 1;
}

/* ---------- BADGES & TAGS ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  padding: 2px 7px; border-radius: var(--radius-full);
  background: var(--color-neutral-bg); color: var(--color-neutral-fg);
  border: 1px solid var(--color-neutral-border);
  line-height: 1.4; white-space: nowrap;
}
.badge--success { background: var(--color-success-bg); color: var(--color-success-fg); border-color: var(--color-success-border); }
.badge--info    { background: var(--color-info-bg);    color: var(--color-info-fg);    border-color: var(--color-info-border); }
.badge--warn    { background: var(--color-warn-bg);    color: var(--color-warn-fg);    border-color: var(--color-warn-border); }
.badge--danger  { background: var(--color-danger-bg);  color: var(--color-danger-fg);  border-color: var(--color-danger-border); }
.badge--primary { background: var(--color-primary-100); color: var(--color-primary-700); border-color: var(--color-primary-200); }
[data-theme="dark"] .badge--primary { background: rgba(10, 110, 136, 0.24); color: var(--color-primary-300); border-color: rgba(10, 110, 136, 0.38); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge--square { border-radius: var(--radius-sm); }

/* ---------- CARDS ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card__header { padding: 14px 16px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card__header > :first-child { flex: 1 1 220px; min-width: 0; }
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.card__sub { font-size: var(--text-sm); color: var(--color-text-subtle); }
.card__body { padding: 16px; }
.card__footer { padding: 12px 16px; border-top: 1px solid var(--color-border); background: var(--color-bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.metric { padding: 16px; }
.metric__label { font-size: var(--text-sm); color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }
.metric__value { font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric__delta { font-size: var(--text-sm); font-weight: var(--weight-medium); display: inline-flex; align-items: center; gap: 3px; margin-top: 6px; }
.metric__delta--up   { color: var(--color-success-fg); }
.metric__delta--down { color: var(--color-danger-fg); }
.metric__delta--flat { color: var(--color-text-subtle); }

/* ---------- TABLES ---------- */
.table-wrap { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-xs); }
.table-wrap--scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table thead th {
  text-align: left; font-weight: var(--weight-medium); font-size: var(--text-sm);
  color: var(--color-text-muted); background: var(--color-bg-subtle);
  padding: 8px 14px; border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
.table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--color-border); color: var(--color-text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-surface-hover); }
.table tbody tr[data-selected="true"] { background: var(--color-primary-50); }
[data-theme="dark"] .table tbody tr[data-selected="true"] { background: rgba(10, 110, 136, 0.14); }
.table td.col-actions { text-align: right; }
.table td.col-num, .table th.col-num { text-align: right; font-variant-numeric: tabular-nums; }
/* Densité ERP : tableaux opérationnels longs */
.table--dense thead th { padding: 6px 10px; }
.table--dense tbody td { padding: 7px 10px; }
.table--sticky thead th { position: sticky; top: var(--header-height); z-index: 2; }

/* ---------- TABS ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 12px; font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--color-text-muted); border: none; background: transparent; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); }
.tab[aria-selected="true"] { color: var(--color-text); border-bottom-color: var(--color-primary-600); }
.tab svg { width: 14px; height: 14px; }
.tab__count { font-size: var(--text-xs); padding: 1px 6px; border-radius: 999px; background: var(--color-bg-subtle); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab__count { background: var(--color-primary-100); color: var(--color-primary-700); }
[data-theme="dark"] .tab[aria-selected="true"] .tab__count { background: rgba(10, 110, 136, 0.28); color: var(--color-primary-300); }

.pill-tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--color-bg-subtle); border-radius: var(--radius-md); }
.pill-tab { padding: 5px 11px; border-radius: var(--radius-sm); background: transparent; border: none; cursor: pointer; font-size: var(--text-base); color: var(--color-text-muted); font-weight: var(--weight-medium); display: inline-flex; align-items: center; gap: 6px; }
.pill-tab[aria-selected="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-xs); }
.pill-tab svg { width: 13px; height: 13px; }

/* ---------- TREE ---------- */
.tree { display: flex; flex-direction: column; gap: 1px; }
.tree-item { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: var(--radius-sm); font-size: var(--text-base); color: var(--color-text); cursor: pointer; min-height: 26px; }
.tree-item:hover { background: var(--color-surface-hover); }
.tree-item[aria-current="page"] { background: var(--color-primary-50); color: var(--color-primary-700); font-weight: var(--weight-medium); }
[data-theme="dark"] .tree-item[aria-current="page"] { background: rgba(10, 110, 136, 0.16); color: var(--color-primary-300); }
.tree-chevron { width: 16px; height: 16px; display: grid; place-items: center; color: var(--color-text-subtle); border-radius: 3px; flex-shrink: 0; }
.tree-chevron:hover { background: var(--color-bg-subtle); }
.tree-chevron svg { width: 12px; height: 12px; }
.tree-chevron[data-open="true"] svg { transform: rotate(90deg); }
.tree-icon { width: 14px; height: 14px; color: var(--color-text-subtle); flex-shrink: 0; }
.tree-item[aria-current="page"] .tree-icon { color: var(--color-primary-600); }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { display: none; gap: 2px; }
.tree-item:hover .tree-actions { display: inline-flex; }
.tree-actions .btn { height: 20px; width: 20px; padding: 0; }
.tree-children { padding-left: 18px; border-left: 1px solid var(--color-border); margin-left: 11px; }
.tree-status { width: 6px; height: 6px; border-radius: 999px; flex-shrink: 0; margin-right: 2px; }
.tree-status--online  { background: var(--color-success-solid); }
.tree-status--offline { background: var(--color-text-disabled); }
.tree-status--draft   { background: var(--color-warn-solid); }

/* ---------- SCORE RING ---------- */
.score-ring {
  --size: 56px; --thickness: 6px;
  width: var(--size); height: var(--size); border-radius: 999px;
  background: conic-gradient(var(--ring-color, var(--color-primary-600)) calc(var(--score, 0) * 1%), var(--color-bg-subtle) 0);
  display: grid; place-items: center; position: relative;
}
.score-ring::after { content: ""; position: absolute; inset: var(--thickness); border-radius: 999px; background: var(--color-surface); }
.score-ring__value { position: relative; font-size: var(--text-md); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ---------- ALERTS ---------- */
.alert {
  display: flex; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-info-border); background: var(--color-info-bg); color: var(--color-info-fg);
  font-size: var(--text-base); align-items: flex-start;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert--warn   { background: var(--color-warn-bg);    color: var(--color-warn-fg);    border-color: var(--color-warn-border); }
.alert--danger { background: var(--color-danger-bg);  color: var(--color-danger-fg);  border-color: var(--color-danger-border); }
.alert--success{ background: var(--color-success-bg); color: var(--color-success-fg); border-color: var(--color-success-border); }
.alert__title { font-weight: var(--weight-semibold); margin-bottom: 2px; }

/* ---------- PAGE CONTAINER ---------- */
.page { padding: 20px 28px; max-width: var(--content-max); margin: 0 auto; width: 100%; }
.page--wide { max-width: var(--content-max-wide); }
.page__header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page__title-block { flex: 1; min-width: 0; }
.page__title { font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); line-height: 1.2; }
.page__sub { font-size: var(--text-base); color: var(--color-text-muted); margin-top: 4px; }
.page__actions { display: flex; gap: 8px; align-items: center; }

/* ---------- AVATARS ---------- */
.avatar { width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: white; background: var(--color-text-muted); flex-shrink: 0; }
.avatar--sm { width: 22px; height: 22px; font-size: 10px; }
.avatar--lg { width: 36px; height: 36px; font-size: var(--text-base); }
.avatar--xl { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid var(--color-surface); margin-left: -8px; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ---------- CHECKBOX / RADIO / SWITCH ---------- */
.checkbox {
  width: 16px; height: 16px; border-radius: var(--radius-xs);
  border: 1.5px solid var(--color-border-strong); background: var(--color-surface);
  display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.checkbox[data-checked="true"] { background: var(--color-primary-600); border-color: var(--color-primary-600); }
.checkbox[data-checked="true"]::after { content: ""; width: 8px; height: 5px; border-left: 2px solid white; border-bottom: 2px solid white; transform: rotate(-45deg) translate(1px, -1px); }
.checkbox[data-indeterminate="true"] { background: var(--color-primary-600); border-color: var(--color-primary-600); }
.checkbox[data-indeterminate="true"]::after { content: ""; width: 8px; height: 2px; background: white; }

/* Radio — absent d'Akiwi, ajouté ici (utilisé par les formulaires) */
.radio {
  width: 16px; height: 16px; border-radius: 999px;
  border: 1.5px solid var(--color-border-strong); background: var(--color-surface);
  display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.radio[data-checked="true"] { border-color: var(--color-primary-600); border-width: 5px; }

.switch { position: relative; width: 30px; height: 18px; background: var(--color-border-strong); border-radius: 999px; cursor: pointer; flex-shrink: 0; transition: background var(--duration-fast); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: white; border-radius: 999px; transition: transform var(--duration-fast); box-shadow: var(--shadow-xs); }
.switch[data-on="true"] { background: var(--color-primary-600); }
.switch[data-on="true"]::after { transform: translateX(12px); }

/* ---------- SIDE PANEL ---------- */
.panel-overlay { position: fixed; inset: 0; background: var(--color-overlay); z-index: var(--z-overlay); display: none; }
.panel-overlay[data-open="true"] { display: block; }
.side-panel--wide { width: 880px !important; }
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 640px; max-width: 92vw;
  background: var(--color-surface); border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-xl); z-index: var(--z-modal);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
}
.panel-overlay[data-open="true"] .side-panel { transform: translateX(0); }
.side-panel__head { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: flex-start; gap: 12px; flex-shrink: 0; }
.side-panel__title { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
.side-panel__sub { font-size: var(--text-sm); color: var(--color-text-subtle); margin-top: 2px; }
.side-panel__close { margin-left: auto; }
.side-panel__tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; overflow-x: auto; }
.side-panel__body { flex: 1; overflow-y: auto; padding: 20px; }
.side-panel__foot { padding: 12px 20px; border-top: 1px solid var(--color-border); background: var(--color-bg-subtle); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.tab-panel { display: none; }
.tab-panel[data-active="true"] { display: block; }

/* ---------- DIVIDERS / UTILS ---------- */
.divider { height: 1px; background: var(--color-border); margin: 16px 0; }
.divider--v { width: 1px; height: 100%; background: var(--color-border); }
.muted { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; }
.row.gap-1 { gap: 4px; } .row.gap-2 { gap: 8px; } .row.gap-3 { gap: 12px; } .row.gap-4 { gap: 16px; }
.col { display: flex; flex-direction: column; }
.col.gap-1 { gap: 4px; } .col.gap-2 { gap: 8px; } .col.gap-3 { gap: 12px; } .col.gap-4 { gap: 16px; }
.grow { flex: 1; }
.ml-auto { margin-left: auto; }
.wrap { flex-wrap: wrap; }

.section-title {
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: var(--color-text-subtle); margin: 24px 0 10px;
}
.empty { text-align: center; padding: 40px 24px; color: var(--color-text-muted); }
.empty__icon { width: 40px; height: 40px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--color-bg-subtle); border-radius: var(--radius-lg); color: var(--color-text-subtle); }
.empty__title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--color-text); margin-bottom: 4px; }

/* =========================================================
   COUCHE ERP — composants propres à Prima Invest
   ========================================================= */

/* ---------- 1. STEP TRACK : la checklist 12 étapes ---------- */
/* Reprend la logique du fichier Excel (vert = OK, vide = à faire)
   mais en 12 jalons ordonnés et lisibles d'un coup d'œil.       */
.steps { display: inline-flex; align-items: center; gap: 3px; }
.step {
  width: 14px; height: 18px; border-radius: 3px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  display: inline-block; position: relative; cursor: help;
  transition: transform var(--duration-fast);
}
.step:hover { transform: translateY(-1px); }
.step[data-state="done"]    { background: var(--color-success-solid); border-color: var(--color-success-solid); }
.step[data-state="current"] { background: var(--color-primary-100); border-color: var(--color-primary-600); box-shadow: inset 0 0 0 1px var(--color-primary-600); }
.step[data-state="blocked"] { background: var(--color-danger-solid); border-color: var(--color-danger-solid); }
.step[data-state="late"]    { background: var(--color-warn-solid);   border-color: var(--color-warn-solid); }
.step[data-state="na"]      { background: repeating-linear-gradient(45deg, var(--color-bg-subtle), var(--color-bg-subtle) 2px, var(--color-border) 2px, var(--color-border) 3px); }
[data-theme="dark"] .step[data-state="current"] { background: rgba(10,110,136,.35); }
.steps__count { font-size: var(--text-xs); color: var(--color-text-subtle); font-variant-numeric: tabular-nums; margin-left: 6px; white-space: nowrap; }

/* Légende des étapes */
.step-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; font-size: var(--text-sm); color: var(--color-text-muted); }
.step-legend__item { display: inline-flex; align-items: center; gap: 6px; }

/* Version verticale détaillée (fiche commande) */
.step-list { display: flex; flex-direction: column; }
.step-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.step-row:last-child { border-bottom: none; }
.step-row__mark {
  width: 22px; height: 22px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--color-bg-subtle); color: var(--color-text-subtle);
  border: 1px solid var(--color-border);
  font-size: 10px; font-weight: var(--weight-bold);
}
.step-row__mark svg { width: 12px; height: 12px; }
.step-row[data-state="done"] .step-row__mark    { background: var(--color-success-bg); color: var(--color-success-fg); border-color: var(--color-success-border); }
.step-row[data-state="current"] .step-row__mark { background: var(--color-primary-100); color: var(--color-primary-700); border-color: var(--color-primary-300); }
.step-row[data-state="blocked"] .step-row__mark { background: var(--color-danger-bg); color: var(--color-danger-fg); border-color: var(--color-danger-border); }
.step-row__label { font-size: var(--text-base); font-weight: var(--weight-medium); }
.step-row__meta { font-size: var(--text-sm); color: var(--color-text-subtle); }
.step-row__owner { margin-left: auto; }

/* ---------- 2. LIGNE DE GROUPE (semaine) ---------- */
/* Équivalent des bandeaux "WEEK 33" du fichier Excel. */
.table tbody tr.group-row td {
  background: var(--color-primary-50);
  border-bottom: 1px solid var(--color-primary-200);
  border-top: 1px solid var(--color-primary-200);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: var(--color-primary-800); padding: 6px 10px;
}
[data-theme="dark"] .table tbody tr.group-row td { background: rgba(10,110,136,.18); color: var(--color-primary-300); border-color: rgba(10,110,136,.35); }
.table tbody tr.group-row:hover td { background: var(--color-primary-50); }
[data-theme="dark"] .table tbody tr.group-row:hover td { background: rgba(10,110,136,.18); }
.group-row__stat { font-weight: var(--weight-regular); text-transform: none; letter-spacing: 0; color: var(--color-text-subtle); margin-left: 10px; }

/* ---------- 3. LIGNE DE COMMANDE ---------- */
.order-row { cursor: pointer; }
.order-row.is-active td { box-shadow: inset 0 0 0 2px var(--color-primary-400); }
.order-row[data-flag="blocked"] td:first-child { box-shadow: inset 3px 0 0 var(--color-danger-solid); }
.order-row[data-flag="late"]    td:first-child { box-shadow: inset 3px 0 0 var(--color-warn-solid); }
.order-row[data-flag="ready"]   td:first-child { box-shadow: inset 3px 0 0 var(--color-success-solid); }
.order-ref { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.order-sub { font-size: var(--text-xs); color: var(--color-text-subtle); }

/* ---------- 4. CHIP produit / conteneur ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: var(--text-xs);
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  color: var(--color-text-muted); padding: 1px 6px; border-radius: var(--radius-sm);
  white-space: nowrap;
}
.chip__dot { width: 6px; height: 6px; border-radius: 999px; flex-shrink: 0; }

/* ---------- 5. BARRE DE FILTRES ---------- */
.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.filterbar .input-group { width: 240px; }
.filterbar .select { width: auto; min-width: 130px; }

/* ---------- 6. LISTE DÉFINITION (fiche) ---------- */
.deflist { display: grid; grid-template-columns: 132px 1fr; gap: 6px 12px; font-size: var(--text-base); align-items: baseline; }
.deflist dt { color: var(--color-text-subtle); font-size: var(--text-sm); }
.deflist dd { margin: 0; color: var(--color-text); }

/* ---------- 7. EN-TÊTE DE PÔLE ---------- */
.pole-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pole-dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }
.pole-dot--falco     { background: var(--color-pole-falco); }
.pole-dot--client    { background: var(--color-pole-client); }
.pole-dot--stock     { background: var(--color-pole-stock); }
.pole-dot--transport { background: var(--color-pole-transport); }
.pole-head__title { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-subtle); }

/* ---------- 8. GRILLE DE PALETTES (spécification) ---------- */
.pallet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 6px; }
.pallet {
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); padding: 7px 8px; cursor: pointer;
  transition: all var(--duration-fast); position: relative; text-align: left;
}
.pallet:hover { border-color: var(--color-primary-400); background: var(--color-surface-hover); }
.pallet__id { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.pallet__ext { font-family: var(--font-mono); font-size: 10px; color: var(--color-text-subtle); display: block; margin-top: 1px; }
.pallet[data-state="selected"] { border-color: var(--color-primary-600); background: var(--color-primary-50); box-shadow: inset 0 0 0 1px var(--color-primary-600); }
[data-theme="dark"] .pallet[data-state="selected"] { background: rgba(10,110,136,.18); }
.pallet[data-state="reserved"] { background: var(--color-bg-subtle); color: var(--color-text-disabled); cursor: not-allowed; border-style: dashed; }
.pallet[data-state="reserved"] .pallet__id { color: var(--color-text-disabled); }
.pallet[data-state="damaged"] { border-color: var(--color-danger-border); background: var(--color-danger-bg); }
.pallet[data-state="damaged"] .pallet__id { color: var(--color-danger-fg); }
.pallet__tag { position: absolute; top: 5px; right: 5px; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-disabled); }

/* ---------- 9. DOCUMENT (ordre de collecte, CMR, BL) ---------- */
.doc { background: #0F172A; border-radius: var(--radius-lg); padding: 16px; }
.doc__sheet { background: white; color: #0F172A; border-radius: var(--radius-md); padding: 26px 24px; font-size: 12px; line-height: 1.5; }
.doc__top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #0F172A; }
.doc__brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.doc__brand span { display: block; font-weight: 400; font-size: 10px; color: #64748B; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }
.doc__type { font-weight: 800; font-size: 14px; letter-spacing: 0.06em; text-align: right; }
.doc__type span { display: block; font-weight: 500; font-size: 10px; color: #64748B; letter-spacing: 0; margin-top: 2px; font-family: var(--font-mono); }
.doc__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.doc__block { font-size: 10.5px; }
.doc__block h4 { margin: 0 0 4px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: #64748B; font-weight: 700; }
.doc__block p { margin: 0; }
.doc table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-top: 4px; }
.doc th { text-align: left; border-bottom: 1.5px solid #0F172A; padding-bottom: 4px; font-weight: 700; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.doc td { padding: 5px 0; border-bottom: 1px solid #E2E8F0; }
.doc__note { margin-top: 14px; padding: 8px 10px; background: #F1F5F9; border-left: 3px solid #F59E0B; font-size: 10.5px; }
.doc__sign { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; font-size: 9px; color: #64748B; }
.doc__sign div { border-top: 1px solid #94A3B8; padding-top: 4px; }

/* ---------- 10. TIMELINE ---------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--color-border); }
.tl-item { position: relative; padding: 0 0 14px 0; }
.tl-item::before {
  content: ""; position: absolute; left: -16px; top: 5px;
  width: 9px; height: 9px; border-radius: 999px;
  background: var(--color-surface); border: 2px solid var(--color-border-strong);
}
.tl-item[data-kind="falco"]::before     { border-color: var(--color-pole-falco); }
.tl-item[data-kind="client"]::before    { border-color: var(--color-pole-client); }
.tl-item[data-kind="stock"]::before     { border-color: var(--color-pole-stock); }
.tl-item[data-kind="transport"]::before { border-color: var(--color-pole-transport); }
.tl-item__title { font-size: var(--text-base); font-weight: var(--weight-medium); }
.tl-item__meta { font-size: var(--text-sm); color: var(--color-text-subtle); }

/* ---------- 11. MATRICE TARIFAIRE ---------- */
.matrix td.rate { font-variant-numeric: tabular-nums; text-align: right; font-family: var(--font-mono); font-size: var(--text-sm); }
.matrix td.rate--none { color: var(--color-text-disabled); }
.matrix th.corner { background: var(--color-surface); }
.matrix tbody th { text-align: left; font-weight: var(--weight-medium); font-size: var(--text-sm); padding: 7px 10px; border-bottom: 1px solid var(--color-border); background: var(--color-bg-subtle); white-space: nowrap; }

/* ---------- 12. JAUGE ---------- */
.meter { height: 6px; border-radius: 999px; background: var(--color-bg-subtle); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 999px; background: var(--color-primary-600); }
.meter__fill--success { background: var(--color-success-solid); }
.meter__fill--warn { background: var(--color-warn-solid); }
.meter__fill--danger { background: var(--color-danger-solid); }

/* ---------- 13. KPI ROW ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* ---------- 14. SPLIT (tableau + détail) ---------- */
.split { display: grid; grid-template-columns: 1fr 420px; gap: 16px; align-items: start; }
.split--wide-detail { grid-template-columns: 1fr 520px; }
.sticky-detail { position: sticky; top: calc(var(--header-height) + 16px); display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 1400px) {
  .split, .split--wide-detail { grid-template-columns: 1fr; }
  .sticky-detail { position: static; }
}
