/* ============================================================
   Compta — recettes d'interface sur les jetons « Cosmos »
   (colors.css, typography.css, spacing.css, effects.css).
   Aucune couleur, taille ou ombre en dur hors jetons : un manque
   se comble en ajoutant un jeton, pas une valeur ad hoc.
   ============================================================ */

:root {
  --sidebar-w: 15.5rem;
  --topbar-h: 3.5rem;
  --page-max: 92rem;
  --money-in: var(--emerald-700);
  --money-out: var(--rose-700);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-body);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text-strong); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); margin: 0; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p { margin: 0; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.icon { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--space-2); top: -3rem; z-index: var(--z-toast); background: var(--white); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.skip-link:focus { top: var(--space-2); }
.boot, .boot-error { padding: var(--space-10); text-align: center; color: var(--text-muted); }

/* ── Utilitaires ─────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-strong { color: var(--text-strong); font-weight: var(--weight-semibold); }
.text-xs { font-size: var(--text-xs); }
.text-danger { color: var(--status-danger-fg); }
.text-success { color: var(--status-success-fg); }
.text-warning { color: var(--status-warn-fg); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.95em; }
.money-in { color: var(--money-in); }
.money-out { color: var(--money-out); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.divider { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-4) 0; }
.hide-desktop { display: none !important; }

/* ── Coquille ─────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100vh; z-index: var(--z-sidebar); }
.sidebar-inner { height: 100%; display: flex; flex-direction: column; background: var(--gradient-sidebar); color: var(--text-dark-body); padding: var(--space-4) var(--space-3); overflow-y: auto; }
.sidebar-brand, .login-brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-5); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: var(--radius-lg); background: var(--gradient-aurora); color: var(--white); }
.brand-name { font-family: var(--font-display); font-weight: var(--weight-bold); font-size: var(--text-lg); color: var(--text-dark-strong); letter-spacing: var(--tracking-tight); }
.login-brand .brand-name { color: var(--text-strong); }
.nav-list, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: var(--space-2-5); width: 100%; padding: var(--space-2) var(--space-2-5); border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-dark-body); font-weight: var(--weight-medium); cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--surface-nav-elevated); color: var(--text-dark-strong); text-decoration: none; }
.nav-item.is-active, .nav-item.is-active-parent { color: var(--text-dark-strong); }
.nav-item.is-active { background: var(--space-800); box-shadow: inset 3px 0 0 var(--iris-400); }
.nav-chevron { margin-left: auto; transition: transform var(--dur-fast) var(--ease-std); }
.nav-group.is-open .nav-chevron { transform: rotate(180deg); }
.nav-sub { margin: 2px 0 var(--space-1) var(--space-8); display: flex; flex-direction: column; gap: 1px; }
.nav-subitem { display: block; padding: var(--space-1-5) var(--space-2-5); border-radius: var(--radius-md); color: var(--text-dark-muted); font-size: var(--text-sm); }
.nav-subitem:hover { color: var(--text-dark-strong); background: var(--surface-nav-elevated); text-decoration: none; }
.nav-subitem.is-active { color: var(--white); background: var(--space-800); font-weight: var(--weight-semibold); }
.sidebar-foot { margin-top: auto; padding: var(--space-4) var(--space-2) 0; border-top: 1px solid var(--border-dark); display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-xs); color: var(--text-dark-muted); }
.sidebar-company { color: var(--text-dark-strong); font-weight: var(--weight-semibold); }
.sidebar-date { display: inline-flex; align-items: center; gap: var(--space-1-5); }
.sidebar-scrim { display: none; }

.shell-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-6); background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); border-bottom: 1px solid var(--border-subtle); }
.topbar-menu { display: none; }
.topbar-search { flex: 0 1 30rem; display: flex; align-items: center; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-card); color: var(--text-muted); cursor: pointer; text-align: left; }
.topbar-search span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-search:hover { border-color: var(--border-strong); }
kbd { font-family: var(--font-mono); font-size: var(--text-2xs); padding: 1px var(--space-1-5); border: 1px solid var(--border-default); border-radius: var(--radius-xs); background: var(--surface-sunken); color: var(--text-muted); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: var(--space-2-5); }
.topbar-user-text { display: flex; flex-direction: column; line-height: var(--leading-snug); font-size: var(--text-xs); }
.topbar-user-text strong { color: var(--text-strong); font-size: var(--text-sm); }
.avatar { width: 2rem; height: 2rem; border-radius: var(--radius-full); display: inline-flex; align-items: center; justify-content: center; background: var(--iris-100); color: var(--iris-700); font-weight: var(--weight-bold); }
.main { flex: 1; outline: none; }
.page { max-width: var(--page-max); margin: 0 auto; padding: var(--space-6) var(--space-6) var(--space-16); display: flex; flex-direction: column; gap: var(--space-5); }

/* ── Connexion ────────────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); background: var(--gradient-hero); }
.login-card { width: 100%; max-width: 24rem; background: var(--surface-card); border-radius: var(--radius-2xl); box-shadow: var(--shadow-xl); padding: var(--space-8); display: flex; flex-direction: column; gap: var(--space-4); }
.login-title { font-size: var(--text-xl); }

/* ── En-tête de page ──────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-heading { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.page-back { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-medium); }
.page-title-row { display: flex; align-items: center; gap: var(--space-2-5); flex-wrap: wrap; }
.page-title { font-size: var(--text-xl); font-weight: var(--weight-bold); }
.page-subtitle { color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ── Boutons ──────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-md); padding: 0 1.05rem; border: 1px solid transparent; border-radius: var(--radius-lg); font-weight: var(--weight-semibold); font-size: var(--text-sm); line-height: 1; white-space: nowrap; cursor: pointer; user-select: none; text-decoration: none; transition: background var(--dur-fast) var(--ease-std), box-shadow var(--dur-fast) var(--ease-std), transform var(--dur-fast); }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-sm { height: var(--control-sm); padding: 0 var(--space-3); font-size: var(--text-xs); gap: var(--space-1-5); border-radius: var(--radius-md); }
.btn-lg { height: var(--control-lg); padding: 0 1.4rem; }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-md); padding: 0; }
.btn-primary { background: var(--color-primary); color: var(--text-on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--surface-card); color: var(--slate-700); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--slate-50); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--iris-700); }
.btn-ghost:hover:not(:disabled) { background: var(--iris-50); }
.btn-danger { background: var(--rose-600); color: var(--white); box-shadow: var(--shadow-sm); }
.btn-danger:hover:not(:disabled) { background: var(--rose-700); }
.btn-success { background: var(--emerald-600); color: var(--white); box-shadow: var(--shadow-sm); }
.btn-success:hover:not(:disabled) { background: var(--emerald-700); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--control-md); height: var(--control-md); border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-sunken); color: var(--text-strong); }
.icon-btn-sm { width: var(--control-sm); height: var(--control-sm); }

/* Menu « … » (details/summary) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: var(--z-dropdown); min-width: 15rem; padding: var(--space-1); background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-2) var(--space-2-5); border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-body); text-align: left; cursor: pointer; font-size: var(--text-sm); }
.menu-item:hover { background: var(--surface-sunken); text-decoration: none; }
.menu-item-danger { color: var(--status-danger-fg); }

/* ── Champs ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--space-1-5); min-width: 0; }
.field-inline { flex-direction: row; align-items: center; gap: var(--space-2); }
.field-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-body); }
.req { color: var(--rose-600); }
.field-hint { font-size: var(--text-xs); color: var(--text-muted); }
.field-error { font-size: var(--text-xs); color: var(--status-danger-fg); font-weight: var(--weight-medium); }
.input { width: 100%; min-width: 0; height: var(--control-md); padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-xs); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.input:hover { border-color: var(--slate-400); }
.input:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--ring-focus); }
.input[aria-invalid="true"], .has-error > .input { border-color: var(--rose-500); }
.input[aria-invalid="true"]:focus { box-shadow: var(--ring-danger); }
.input:disabled, .input[readonly] { background: var(--surface-sunken); color: var(--text-muted); }
.input::placeholder { color: var(--text-subtle); }
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
.input-mono { font-family: var(--font-mono); }
.input-plain { border-color: transparent; box-shadow: none; background: transparent; }
.input-plain:hover { border-color: var(--border-default); }
.textarea { height: auto; padding: var(--space-2) var(--space-3); resize: vertical; }
.select { appearance: none; padding-right: var(--space-8); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--space-2-5) center; }
.field-inline .select { width: auto; }
.checkbox { width: 1rem; height: 1rem; accent-color: var(--color-primary); cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.field-check { gap: var(--space-1); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--space-4); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.segmented { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-1-5); }
.segmented-items { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: var(--radius-lg); background: var(--surface-sunken); }
.segment { position: relative; display: inline-flex; align-items: center; padding: var(--space-1-5) var(--space-3); border-radius: var(--radius-md); cursor: pointer; font-weight: var(--weight-medium); color: var(--text-muted); }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment.is-active { background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-xs); }
.segment:focus-within { outline: 2px solid var(--border-focus); }

/* Sélecteur avec recherche */
.combo { position: relative; display: block; min-width: 0; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: var(--z-dropdown); max-height: 18rem; overflow-y: auto; margin: 0; padding: var(--space-1); list-style: none; background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); min-width: 16rem; }
.combo-option { display: flex; flex-direction: column; padding: var(--space-1-5) var(--space-2); border-radius: var(--radius-md); cursor: pointer; }
.combo-option.is-active, .combo-option:hover { background: var(--iris-50); }
.combo-label { color: var(--text-strong); font-weight: var(--weight-medium); }
.combo-sub { font-size: var(--text-xs); color: var(--text-muted); }
.combo-empty { padding: var(--space-2); color: var(--text-muted); }

/* ── Cartes, sections ─────────────────────────────────────────── */
.card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); }
.card-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.card-title { font-size: var(--text-base); }
.section-title { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-muted); font-family: var(--font-sans); font-weight: var(--weight-semibold); }
.sheet { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--space-5); align-items: start; }
.sheet-side { display: flex; flex-direction: column; gap: var(--space-4); position: sticky; top: calc(var(--topbar-h) + var(--space-4)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }

/* Liste de définitions */
.dl { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.dl-row { display: flex; justify-content: space-between; gap: var(--space-3); }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; text-align: right; color: var(--text-strong); font-weight: var(--weight-medium); min-width: 0; overflow-wrap: anywhere; }

/* ── Badges, onglets ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: var(--space-1-5); padding: 3px 11px; border: 1px solid; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: var(--leading-snug); white-space: nowrap; }
.badge-dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; flex: none; }
.badge-neutral { background: var(--slate-100); color: var(--slate-600); border-color: var(--slate-200); }
.badge-info { background: var(--status-info-bg); color: var(--status-info-fg); border-color: var(--status-info-bd); }
.badge-success { background: var(--status-success-bg); color: var(--status-success-fg); border-color: var(--status-success-bd); }
.badge-warning { background: var(--status-warn-bg); color: var(--status-warn-fg); border-color: var(--status-warn-bd); }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger-fg); border-color: var(--status-danger-bd); }
.badge-primary { background: var(--iris-50); color: var(--iris-700); border-color: var(--iris-100); }
.badge-accent { background: var(--cyan-50); color: var(--cyan-600); border-color: var(--cyan-100); }

.tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; border-bottom: 1px solid var(--border-default); }
.tab { display: inline-flex; align-items: center; gap: var(--space-1-5); padding: var(--space-2) var(--space-3); border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--text-muted); font-weight: var(--weight-semibold); cursor: pointer; }
.tab:hover { color: var(--text-strong); }
.tab.is-active { color: var(--iris-700); border-bottom-color: var(--color-primary); }
.tab-count { min-width: 1.4rem; padding: 0 var(--space-1-5); border-radius: var(--radius-full); background: var(--surface-sunken); color: var(--text-muted); font-size: var(--text-2xs); text-align: center; line-height: 1.25rem; }
.tab.is-active .tab-count { background: var(--iris-100); color: var(--iris-700); }
.tab-count-danger { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.tab-count-warning { background: var(--status-warn-bg); color: var(--status-warn-fg); }

/* ── Barre d'outils de liste ──────────────────────────────────── */
.toolbar { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.toolbar .field { flex: 0 1 12rem; }
.toolbar .search { flex: 1 1 18rem; position: relative; }
.search .icon { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.search .input { padding-left: var(--space-10); }
.chips { display: flex; gap: var(--space-1-5); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-1-5) 2px var(--space-2-5); border-radius: var(--radius-full); background: var(--iris-50); color: var(--iris-700); font-size: var(--text-xs); font-weight: var(--weight-semibold); border: 1px solid var(--iris-100); }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0; display: inline-flex; }

/* ── Tableaux ─────────────────────────────────────────────────── */
.table-wrap { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); overflow-x: auto; box-shadow: var(--shadow-xs); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table th { position: sticky; top: 0; padding: var(--space-2-5) var(--space-3); background: var(--slate-50); border-bottom: 1px solid var(--border-default); color: var(--text-muted); font-size: var(--text-2xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-wide); text-align: left; white-space: nowrap; }
.table td { padding: var(--space-2-5) var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { background: var(--slate-50); font-weight: var(--weight-semibold); border-top: 1px solid var(--border-default); border-bottom: 0; }
.table-dense td { padding: var(--space-1-5) var(--space-3); }
.table tr.is-link { position: relative; cursor: pointer; }
.table tr.is-link:hover td { background: var(--slate-50); }
.table tr.is-selected td { background: var(--iris-50); }
.table .row-link { color: var(--text-strong); font-weight: var(--weight-semibold); }
.table .row-link::after { content: ''; position: absolute; inset: 0; }
.table tr.is-link td:has(input, button, a:not(.row-link), select, c-combo) { position: relative; z-index: 1; }
.table .col-select { width: 2.5rem; position: relative; z-index: 1; }
.table-sort { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.table-sort:hover { color: var(--text-strong); }
.table-sort-indicator { font-size: 0.6rem; color: var(--iris-600); }
th.text-right .table-sort { flex-direction: row-reverse; }
.table tr.is-late td:first-child { box-shadow: inset 3px 0 0 var(--rose-500); }
.table tr.is-muted td { color: var(--text-subtle); }
.empty-inline { padding: var(--space-8) var(--space-4); text-align: center; color: var(--text-muted); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); color: var(--text-muted); font-size: var(--text-xs); }
.pager-info { margin-right: auto; }

.selection-bar { position: sticky; bottom: var(--space-4); z-index: var(--z-sticky); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-2-5) var(--space-4); border-radius: var(--radius-xl); background: var(--space-900); color: var(--text-dark-body); box-shadow: var(--shadow-xl); }
.selection-count strong { color: var(--white); }
.selection-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.selection-bar .btn-ghost { color: var(--text-dark-body); }
.selection-bar .btn-ghost:hover { background: var(--space-800); }

/* ── Synthèse (KPI) ───────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-3); }
.kpi { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); color: var(--text-body); }
a.kpi:hover { text-decoration: none; border-color: var(--iris-200); box-shadow: var(--card-hover-shadow); transform: translateY(-1px); }
.kpi-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-muted); }
.kpi-value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--text-strong); letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: var(--text-xs); color: var(--text-muted); }
.kpi-danger { border-color: var(--rose-200); }
.kpi-danger .kpi-value { color: var(--rose-700); }
.kpi-warning { border-color: var(--amber-200); }
.kpi-warning .kpi-value { color: var(--amber-800); }
.kpi-success .kpi-value { color: var(--emerald-700); }
.kpi-dark { background: var(--gradient-hero); border-color: transparent; }
.kpi-dark .kpi-label, .kpi-dark .kpi-hint { color: var(--text-dark-muted); }
.kpi-dark .kpi-value { color: var(--white); }

/* ── Alertes, états ───────────────────────────────────────────── */
.alert { display: flex; gap: var(--space-2-5); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border: 1px solid; font-size: var(--text-sm); }
.alert-info { background: var(--sky-50); color: var(--sky-700); border-color: var(--sky-200); }
.alert-success { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
.alert-warning { background: var(--amber-50); color: var(--amber-800); border-color: var(--amber-200); }
.alert-danger { background: var(--rose-50); color: var(--rose-700); border-color: var(--rose-200); }
.empty { padding: var(--space-12) var(--space-6); text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.empty h1, .empty-title { font-size: var(--text-lg); }
.loading { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-6); color: var(--text-muted); }
.spinner { width: 1rem; height: 1rem; border-radius: var(--radius-full); border: 2px solid var(--border-strong); border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Frise chronologique */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.timeline-item { display: grid; grid-template-columns: 0.75rem 1fr; gap: var(--space-2-5); position: relative; }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 0.31rem; top: 0.9rem; bottom: calc(-1 * var(--space-3)); width: 1px; background: var(--border-default); }
.timeline-dot { width: 0.65rem; height: 0.65rem; border-radius: var(--radius-full); background: var(--iris-500); margin-top: 0.3rem; box-shadow: 0 0 0 3px var(--iris-100); }
.timeline-text { color: var(--text-strong); }
.timeline-meta { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Panneau latéral ──────────────────────────────────────────── */
.drawer-scrim { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; justify-content: flex-end; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--scrim); opacity: 0; transition: opacity var(--dur-base) var(--ease-std); cursor: default; }
.drawer-panel { position: relative; width: 100%; max-width: 30rem; height: 100%; display: flex; flex-direction: column; background: var(--surface-card); box-shadow: var(--shadow-2xl); transform: translateX(100%); transition: transform var(--dur-slow) var(--ease-out); }
.drawer-panel-wide { max-width: 46rem; }
.drawer-scrim.is-open .drawer-backdrop { opacity: 1; }
.drawer-scrim.is-open .drawer-panel { transform: none; }
.drawer-scrim.is-leaving .drawer-panel { transform: translateX(100%); }
.drawer-scrim.is-leaving .drawer-backdrop { opacity: 0; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-default); }
.drawer-header h2 { font-size: var(--text-lg); }
.drawer-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.drawer-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-default); background: var(--slate-50); }
body.has-drawer { overflow: hidden; }

/* ── Dialogues ────────────────────────────────────────────────── */
.dialog { border: 0; padding: 0; border-radius: var(--radius-2xl); box-shadow: var(--shadow-2xl); width: min(30rem, calc(100vw - 2rem)); background: var(--surface-card); color: var(--text-body); }
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.dialog-form { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.dialog-title { font-size: var(--text-lg); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
.palette { width: min(40rem, calc(100vw - 2rem)); margin-top: 12vh; }
.palette-input { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border-default); color: var(--text-muted); }
.palette-input .input { height: var(--control-lg); font-size: var(--text-base); }
.palette-list { list-style: none; margin: 0; padding: var(--space-2); max-height: 55vh; overflow-y: auto; }
.palette-item { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); color: var(--text-strong); }
.palette-item.is-active, .palette-item:hover { background: var(--iris-50); text-decoration: none; }
.palette-empty { padding: var(--space-4); color: var(--text-muted); text-align: center; }

/* ── Notifications ────────────────────────────────────────────── */
.toasts { position: fixed; z-index: var(--z-toast); bottom: var(--space-4); right: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); max-width: min(26rem, calc(100vw - 2rem)); }
.toast { display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border-radius: var(--radius-lg); background: var(--space-900); color: var(--text-dark-strong); box-shadow: var(--shadow-xl); animation: toast-in var(--dur-slow) var(--ease-out); }
.toast-text { flex: 1; }
.toast .icon-btn { color: var(--text-dark-muted); width: var(--control-sm); height: var(--control-sm); }
.toast .icon-btn:hover { background: var(--space-800); color: var(--white); }
.toast .toast-action { color: var(--cyan-300); }
.toast-success > .icon { color: var(--emerald-500); }
.toast-danger > .icon { color: var(--rose-500); }
.toast-warning > .icon { color: var(--amber-400); }
.toast-info > .icon { color: var(--sky-500); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all var(--dur-base); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Grille de lignes ─────────────────────────────────────────── */
.lines-grid { display: flex; flex-direction: column; gap: var(--space-3); }
.lines-table td { padding: var(--space-1-5) var(--space-2); }
.lines-table .input { height: var(--control-sm); padding: 0 var(--space-2); border-radius: var(--radius-md); box-shadow: none; }
.lines-table .select { padding-right: var(--space-6); background-position: right var(--space-1-5) center; }
.lines-table .col-handle { width: 1.5rem; color: var(--text-subtle); cursor: grab; padding-right: 0; }
.lines-table .col-product { width: 14rem; }
.lines-table .col-qty { width: 6rem; }
.lines-table .col-price { width: 8rem; }
.lines-table .col-disc { width: 6rem; }
.lines-table .col-tax { width: 6.5rem; }
.lines-table .col-account { width: 7rem; }
.lines-table .col-total { width: 8rem; font-weight: var(--weight-semibold); color: var(--text-strong); }
.lines-table .col-actions { width: 2.5rem; }
.lines-table tr.has-error td { background: var(--rose-50); }
.lines-table tr.is-dragging { opacity: 0.4; }
.line-section td { background: var(--slate-50); }
.line-section-input, .line-section-title { font-weight: var(--weight-bold); color: var(--text-strong); font-family: var(--font-display); }
.line-note-input, .line-note-text { font-style: italic; color: var(--text-muted); }
.line-actions { display: flex; justify-content: flex-end; }
.lines-toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.lines-account-toggle { margin-left: auto; }
.lines-totals { margin: 0 0 0 auto; width: min(100%, 22rem); display: flex; flex-direction: column; gap: var(--space-1-5); }
.tot-row { display: flex; justify-content: space-between; gap: var(--space-3); }
.tot-row dt { color: var(--text-muted); }
.tot-row dd { margin: 0; color: var(--text-strong); }
.tot-grand { padding-top: var(--space-2); border-top: 1px solid var(--border-default); }
.tot-grand dt, .tot-grand dd { color: var(--text-strong); font-weight: var(--weight-bold); font-size: var(--text-base); }
.tot-due dd { color: var(--iris-700); font-weight: var(--weight-bold); font-size: var(--text-lg); }

/* Jauges (reçu / facturé) */
.gauge { display: flex; align-items: center; gap: var(--space-2); min-width: 7rem; }
.gauge-bar { flex: 1; height: 6px; border-radius: var(--radius-full); background: var(--slate-150); overflow: hidden; }
.gauge-fill { height: 100%; border-radius: inherit; background: var(--gradient-aurora); }
.gauge-text { font-size: var(--text-2xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Impression ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-actions, .toasts, .lines-toolbar, .selection-bar { display: none !important; }
  .page { padding: 0; }
  body { background: var(--white); }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1279px) {
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .sheet-side { position: static; }
}

@media (max-width: 1023px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 767px) {
  .sidebar { position: fixed; left: 0; top: 0; width: 0; }
  .sidebar-inner { position: fixed; left: 0; top: 0; width: min(85vw, var(--sidebar-w)); transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease-out); z-index: var(--z-modal); }
  .sidebar-inner.is-mobile-open { transform: none; box-shadow: var(--shadow-2xl); }
  .sidebar-scrim { display: block; position: fixed; inset: 0; border: 0; background: var(--scrim); z-index: calc(var(--z-modal) - 1); }
  .topbar { padding: 0 var(--space-3); }
  .topbar-menu { display: inline-flex; }
  .topbar-search span, .topbar-search kbd, .topbar-user-text { display: none; }
  .topbar-search { flex: 0 0 auto; }
  .page { padding: var(--space-4) var(--space-4) var(--space-16); gap: var(--space-4); }
  .page-header { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn-primary { flex: 1; }
  .hide-mobile { display: none !important; }
  .hide-desktop { display: inline-flex !important; }
  .form-grid .span-2 { grid-column: auto; }
  .kpi-value { font-size: var(--text-xl); }
  .toolbar .field, .toolbar .search { flex: 1 1 100%; }

  /* Listes en cartes : chaque cellule affiche son libellé. */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { margin-bottom: var(--space-2-5); padding: var(--space-2) var(--space-3); background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); }
  .table td { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-1) 0; border: 0; text-align: right; min-width: 0; }
  .table td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-align: left; flex: none; }
  .table td.cell-primary { font-size: var(--text-base); }
  .table td.col-select { justify-content: flex-start; }
  .table td.col-select::before, .table tr.is-empty td::before { content: none; }
  .table tfoot, .table tfoot tr, .table tfoot td { display: block; }
  .lines-table td { flex-wrap: wrap; }
  .lines-table td > .input, .lines-table td > c-combo, .lines-table td > .select { flex: 1 1 10rem; max-width: 60%; }
  .lines-table .col-handle { display: none; }
  .lines-account-toggle { margin-left: 0; }
  .selection-bar { bottom: var(--space-2); }
  .drawer-panel, .drawer-panel-wide { max-width: 100%; }
  /* Libellé long (nom de fichier) : retour à la ligne plutôt que débordement. */
  .page .btn { max-width: 100%; }
  .page .btn > span { white-space: normal; overflow-wrap: anywhere; text-align: center; }
}
