/* ==========================================================================
   SAM Print v2 — feuille de style unique
   Charte SAM Informatique : Montserrat, dégradé orange → rouge (écusson),
   barre latérale sombre, contenu clair. CSP : aucune règle inline.
   Sommaire :
     1. Polices        2. Variables        3. Base / reset
     4. Mise en page   5. Barre latérale   6. Barre haute / en-tête de page
     7. Utilitaires    8. Cartes / KPI     9. Boutons
    10. Tableaux      11. Formulaires     12. Badges / pastilles
    13. Jauges        14. Onglets / flash 15. États vides, timeline, sparkline
    16. Pagination    17. Modale / toast  18. Authentification
    19. Pages d'erreur 20. Charte (styleguide) 21. Responsive  22. Impression
    23. Largeurs .pct-N (générées)
   ========================================================================== */

/* 1. Polices ------------------------------------------------------------- */
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/montserrat-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/montserrat-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/montserrat-latin-700-normal.woff2") format("woff2"); }

/* 2. Variables ----------------------------------------------------------- */
:root {
  /* Palette SAM (exacte) */
  --sam-orange: #FF9900;
  --sam-orange-2: #FF6F00;
  --sam-orange-3: #F08232;
  --sam-pink: #F13E53;
  --sam-red: #D40728;
  --sam-bordeaux: #A11A2E;
  --sam-black: #000;
  --sam-dark: #262626;
  --sam-grey: #888787;
  --sam-white: #FFF;

  --sam-gradient: linear-gradient(90deg, var(--sam-orange) 0%, var(--sam-orange-2) 38%, var(--sam-red) 78%, var(--sam-bordeaux) 100%);
  --sam-gradient-v: linear-gradient(180deg, var(--sam-orange) 0%, var(--sam-orange-2) 45%, var(--sam-red) 80%, var(--sam-bordeaux) 100%);
  --sam-gradient-warm: linear-gradient(135deg, var(--sam-orange) 0%, var(--sam-orange-2) 100%);

  /* Surfaces & texte */
  --bg: #F6F5F3;
  --surface: #FFF;
  --surface-2: #FAF9F7;
  --surface-hover: #FFF7EC;
  --border: #E6E3DF;
  --border-strong: #D3CFCA;
  --text: #1C1C1C;
  --text-2: #4A4848;
  --muted: #6B6969;          /* AA sur blanc (5,4:1) — #888787 réservé aux éléments non textuels */
  --sidebar-bg: var(--sam-dark);
  --sidebar-text: #CFCCC8;
  --sidebar-muted: #9A9794;

  /* Sémantique */
  --ok: #1E8A4C;  --ok-bg: #E7F5EC;  --ok-text: #146B39;
  --warn: var(--sam-orange); --warn-strong: var(--sam-orange-2); --warn-bg: #FFF2DE; --warn-text: #8A4300;
  --alert: var(--sam-red); --alert-bg: #FDE8EB; --alert-text: #A3061F;
  --crit: var(--sam-bordeaux);
  --info: #2D5F8B; --info-bg: #E8F0F8; --info-text: #234C70;
  --neutral-bg: #EFEDEA; --neutral-text: #4A4848;

  /* Encres */
  --ink-k: #111;
  --ink-c: #00A3E0;
  --ink-m: #E4007C;
  --ink-y: #FFE100;
  --ink-bac: #6E6D6D;
  --ink-kit: var(--sam-bordeaux);

  /* Divers */
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(38, 38, 38, .06);
  --shadow: 0 1px 2px rgba(38, 38, 38, .05), 0 4px 14px rgba(38, 38, 38, .06);
  --shadow-lg: 0 12px 40px rgba(20, 20, 20, .18);
  --focus-ring: 0 0 0 3px rgba(255, 111, 0, .35);
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --gutter: 32px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* 3. Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "tnum" 0;
}
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; color: var(--sam-dark); letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }
p { margin: 0 0 1em; }
a { color: #B8420A; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--sam-red); }
img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: #fff; }
::selection { background: rgba(255, 153, 0, .3); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--sam-dark); outline-offset: 2px; border-radius: 4px; }
.sidebar :focus-visible { outline-color: var(--sam-orange); }

.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

.sr-only { position: absolute !important; 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: 12px; top: -60px; z-index: 1000; background: var(--sam-dark); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: 12px; color: #fff; }

/* 4. Mise en page -------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }
.content { flex: 1; padding: 8px var(--gutter) 40px; outline: none; }
.page { display: flex; flex-direction: column; gap: 24px; }
.app-footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px var(--gutter); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
}

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > * { margin: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

/* 5. Barre latérale ------------------------------------------------------ */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid #1a1a1a;
}
.sidebar::before { /* liseré dégradé de l'écusson */
  content: ""; position: absolute; top: 0; right: -1px; bottom: 0; width: 3px;
  background: var(--sam-gradient-v);
}
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 20px 18px 18px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; min-width: 0; }
.brand:hover { color: #fff; }
.brand-logo { width: 31px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .01em; line-height: 1.2; }
.brand-name::after { content: ""; display: block; width: 28px; height: 3px; margin: 4px 0 3px; border-radius: 2px; background: var(--sam-gradient); }
.brand-tagline { font-size: 11px; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { display: none; margin-left: auto; background: none; border: 0; color: var(--sidebar-text); padding: 6px; border-radius: var(--radius-sm); cursor: pointer; }
.sidebar-close:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 20px; scrollbar-width: thin; scrollbar-color: #444 transparent; }
.nav-section + .nav-section { margin-top: 14px; }
.nav-group { padding: 8px 10px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background-color .15s, color .15s;
}
.nav-link .nav-icon { width: 19px; height: 19px; color: var(--sidebar-muted); transition: color .15s; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link:hover .nav-icon { color: #fff; }
.nav-link.active { background: linear-gradient(90deg, rgba(255, 111, 0, .2), rgba(255, 111, 0, .04)); color: #fff; font-weight: 600; }
.nav-link.active .nav-icon { color: var(--sam-orange); }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--sam-gradient-v); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 11px; color: var(--sidebar-muted); }
.sidebar-stripe { width: 14px; height: 14px; border-radius: 4px; background: var(--sam-gradient); flex: none; }
.sidebar-version { margin-left: auto; font-variant-numeric: tabular-nums; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .45); backdrop-filter: blur(1px); }

/* 6. Barre haute & en-tête de page -------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 var(--gutter);
  background: rgba(246, 245, 243, .88);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid transparent;
}
.topbar.is-scrolled { border-bottom-color: var(--border); background: rgba(255, 255, 255, .92); }
.topbar button.topbar-menu.btn-icon { display: none; }
.breadcrumb { min-width: 0; font-size: 12.5px; color: var(--muted); }
.breadcrumb ol { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; white-space: nowrap; overflow: hidden; }
.breadcrumb li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.breadcrumb li:last-child { overflow: hidden; }
.breadcrumb a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; padding: 2px 4px; border-radius: 4px; }
.breadcrumb a:hover { color: var(--sam-dark); background: rgba(0, 0, 0, .04); }
.breadcrumb [aria-current] { color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb-sep { width: 12px; height: 12px; color: #B5B2AE; }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu-trigger { display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border-radius: 999px; cursor: pointer; border: 1px solid transparent; transition: background-color .15s, border-color .15s; }
.user-menu-trigger:hover, .user-menu[open] .user-menu-trigger { background: #fff; border-color: var(--border); }
.user-menu-id { display: flex; flex-direction: column; line-height: 1.2; }
.user-menu-name { font-weight: 600; font-size: 13px; color: var(--sam-dark); }
.user-menu-role { font-size: 11.5px; color: var(--muted); }
.user-menu-caret { color: var(--muted); transition: transform .15s; }
.user-menu[open] .user-menu-caret { transform: rotate(180deg); }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 280px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 8px; animation: pop .14s var(--ease);
}
.user-menu-head { display: flex; gap: 12px; align-items: flex-start; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu-head > span:last-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.user-menu-head .small { overflow: hidden; text-overflow: ellipsis; }
.user-menu-head .badge { align-self: flex-start; margin-top: 4px; }
.user-menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: var(--radius-sm); font: inherit; font-weight: 500; color: var(--text); cursor: pointer; text-align: left; text-decoration: none; }
.user-menu-item:hover { background: var(--surface-hover); color: var(--sam-red); }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--sam-gradient-warm); color: #1a1a1a; font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.avatar-lg { width: 42px; height: 42px; font-size: 15px; }

.page-header { display: flex; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; padding: 18px var(--gutter) 22px; }
.page-heading { flex: 1 1 320px; min-width: 0; }
.page-title { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; color: var(--sam-dark); }
.page-title::after { content: ""; display: block; width: 44px; height: 4px; margin-top: 10px; border-radius: 2px; background: var(--sam-gradient); }
.page-subtitle { margin: 10px 0 0; color: var(--text-2); max-width: 75ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.flashes { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--gutter) 18px; }

/* 7. Utilitaires --------------------------------------------------------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num, .table td.right { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.text-ok { color: var(--ok-text); }
.text-warn { color: var(--warn-text); }
.text-alert { color: var(--alert-text); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }
.print-only { display: none; }

/* 8. Cartes & KPI -------------------------------------------------------- */
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--sam-dark); display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--sam-orange-2); }
.card-header > .card-title { flex: 1; min-width: 0; }
.card-body { flex: 1 1 auto; padding: 20px; }
.progress + p { margin-top: 8px; }
.card-body > :last-child { margin-bottom: 0; }
.card-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card > .table-wrap { border: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); box-shadow: none; }
.card > .table-wrap:first-child { border-radius: var(--radius-lg); }
.card-accent { position: relative; overflow: hidden; }
.card-accent::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--sam-gradient); }

.kpi {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 20px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none; overflow: hidden;
  transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--kpi-c, var(--info)); }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); color: var(--text); }
.kpi-head { display: flex; align-items: flex-start; gap: 12px; }
.kpi-label { flex: 1; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); line-height: 1.35; }
.kpi-icon-wrap { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--kpi-bg, var(--info-bg)); color: var(--kpi-c, var(--info)); flex: none; margin: -4px -4px 0 0; }
.kpi-icon { width: 19px; height: 19px; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; color: var(--sam-dark); font-variant-numeric: tabular-nums; }
.kpi-trend { font-size: 12.5px; color: var(--text-2); }
.kpi-go { position: absolute; right: 14px; bottom: 16px; width: 16px; height: 16px; color: var(--border-strong); transition: color .15s, transform .15s; }
a.kpi:hover .kpi-go { color: var(--sam-orange-2); transform: translateX(2px); }
.kpi-ok { --kpi-c: var(--ok); --kpi-bg: var(--ok-bg); }
.kpi-warn { --kpi-c: var(--sam-orange-2); --kpi-bg: var(--warn-bg); }
.kpi-alert { --kpi-c: var(--sam-red); --kpi-bg: var(--alert-bg); }
.kpi-alert .kpi-value { color: var(--sam-red); }
.kpi-info { --kpi-c: var(--sam-dark); --kpi-bg: var(--neutral-bg); }
.kpi-info::before { background: var(--sam-gradient-v); }

/* 9. Boutons ------------------------------------------------------------- */
.btn {
  --btn-bg: #fff; --btn-fg: var(--sam-dark); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 16px;
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd); border-radius: 8px;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s, filter .15s;
}
.btn:hover { color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--sam-dark); outline-offset: 2px; box-shadow: var(--focus-ring); }
.btn .icon { width: 17px; height: 17px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { --btn-fg: #1A1A1A; --btn-bd: transparent; background: var(--sam-gradient-warm); box-shadow: 0 1px 2px rgba(255, 111, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-primary:hover { filter: brightness(1.04) saturate(1.05); box-shadow: 0 3px 10px rgba(255, 111, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-secondary { --btn-bg: #fff; --btn-fg: var(--sam-dark); --btn-bd: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { --btn-bd: var(--sam-grey); background: var(--surface-2); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: rgba(38, 38, 38, .06); --btn-fg: var(--sam-dark); }
.btn-danger { --btn-bg: var(--sam-red); --btn-fg: #fff; --btn-bd: var(--sam-red); }
.btn-danger:hover { --btn-bg: var(--sam-bordeaux); --btn-bd: var(--sam-bordeaux); --btn-fg: #fff; }
.btn-dark { --btn-bg: var(--sam-dark); --btn-fg: #fff; --btn-bd: var(--sam-dark); }
.btn-dark:hover { --btn-bg: #000; --btn-fg: #fff; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 7px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-icon { min-width: 38px; padding: 8px; gap: 0; }
.btn-icon.btn-sm { min-width: 30px; padding: 4px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
button.btn-icon:not(.btn) { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--text-2); }
button.btn-icon:not(.btn):hover { background: rgba(0, 0, 0, .06); color: var(--sam-dark); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: #B8420A; text-decoration: underline; cursor: pointer; }

/* 10. Tableaux ----------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
.table thead th.right, .table td.right { text-align: right; }
.table thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.table thead th a:hover { color: var(--sam-dark); }
.table thead th[aria-sort] { color: var(--sam-dark); }
.table tbody tr { transition: background-color .1s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td a:not(.btn) { color: var(--sam-dark); font-weight: 600; text-decoration: none; }
.table td a:not(.btn):hover { color: var(--sam-red); text-decoration: underline; }
.table td .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.table tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table td.mono, .table td .mono { white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table td.actions .btn + .btn, .table td.actions form { margin-left: 4px; }
.table td.actions form { display: inline; }
.table-compact th, .table-compact td { padding: 7px 10px; }
.table-compact { font-size: 13px; }
.table tr.is-alert { background: #FFF6F7; }
.table tr.is-alert:hover { background: #FDEDEF; }
.table tr.is-alert > td:first-child { box-shadow: inset 4px 0 0 var(--sam-red); }
.table tr.is-warn { background: #FFFAF2; }
.table tr.is-warn:hover { background: #FFF3E1; }
.table tr.is-warn > td:first-child { box-shadow: inset 4px 0 0 var(--sam-orange); }
.table tr.is-muted td { color: var(--muted); }
.table tr.filter-empty td { text-align: center; color: var(--muted); padding: 28px; }
.table-wrap > .table thead th:first-child { border-top-left-radius: var(--radius-lg); }
.table-wrap > .table thead th:last-child { border-top-right-radius: var(--radius-lg); }
.card > .table-wrap .table thead th { border-radius: 0; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card > .toolbar { margin: 0; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.toolbar .field { margin: 0; }
.toolbar input, .toolbar select { min-height: 36px; width: auto; }
.toolbar select { max-width: 260px; }
.toolbar .search-input { position: relative; flex: 1 1 240px; max-width: 360px; }
.search-input { position: relative; display: block; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input input, .search-input input[type] { padding-left: 36px; width: 100%; }
.toolbar-count { font-size: 12.5px; color: var(--muted); margin-left: auto; }

/* 11. Formulaires -------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 18px; max-width: 880px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .field-full, .form-grid .form-actions, .form-grid fieldset { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--sam-dark); }
.field > label .req, .req { color: var(--sam-red); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--alert-text); font-weight: 500; display: flex; align-items: center; gap: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="tel"], input[type="url"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"],
input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  font: inherit; font-size: 14px; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select {
  padding-right: 34px;
  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='%236B6969' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
select[multiple] { background-image: none; padding-right: 12px; min-height: 120px; }
input:hover, select:hover, textarea:hover { border-color: var(--sam-grey); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sam-orange-2); box-shadow: var(--focus-ring); }
input::placeholder, textarea::placeholder { color: #8F8C89; }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.field.has-error input, .field.has-error select, .field.has-error textarea, input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--sam-red); background: #FFFBFB; }
.field.has-error input:focus { box-shadow: 0 0 0 3px rgba(212, 7, 40, .2); }
.form-actions input, .form-actions select { width: auto; }
.input-sm, input.input-sm, select.input-sm { width: auto; min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 7px; }
select.input-sm { padding-right: 30px; background-position: right 8px center; }
input[type="checkbox"], input[type="radio"] {
  appearance: none; width: 18px; height: 18px; margin: 0; flex: none;
  border: 1.5px solid var(--sam-grey); background: #fff; display: inline-grid; place-content: center; cursor: pointer;
  transition: background-color .12s, border-color .12s; vertical-align: -4px;
}
input[type="checkbox"] { border-radius: 5px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform .12s; background: #1a1a1a; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
input[type="radio"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; transform: scale(0); transition: transform .12s; background: #1a1a1a; }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--sam-orange); border-color: var(--sam-orange-2); }
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--sam-dark); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; font-size: 13.5px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input[type="checkbox"] { width: 36px; height: 20px; border-radius: 999px; background: #D3CFCA; border: 0; place-content: center start; padding: 2px; }
.switch input[type="checkbox"]::before { width: 16px; height: 16px; border-radius: 50%; background: #fff; clip-path: none; transform: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s var(--ease); }
.switch input[type="checkbox"]:checked { background: var(--sam-orange-2); }
.switch input[type="checkbox"]:checked::before { transform: translateX(16px); }
input[type="file"] { font: inherit; font-size: 13px; max-width: 100%; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; font-size: 13px; margin-right: 12px; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--sam-dark); cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--surface-2); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 18px; margin: 0; }
legend { padding: 0 6px; font-weight: 700; font-size: 13px; color: var(--sam-dark); }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.form-actions .spacer { flex: 1; }
.input-group { display: flex; align-items: stretch; }
.input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); text-align: center; color: var(--text-2); transition: border-color .15s, background-color .15s; }
.dropzone .icon { width: 30px; height: 30px; color: var(--sam-orange-2); }
.dropzone.is-over { border-color: var(--sam-orange-2); background: var(--surface-hover); }

/* 12. Badges & pastilles -------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.35; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-text);
  border: 1px solid transparent;
}
.badge .icon { width: 13px; height: 13px; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-warn.badge-dot::before { background: var(--sam-orange-2); }
.badge-alert { background: var(--alert-bg); color: var(--alert-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-kfs { background: #fff; color: var(--sam-dark); border-color: var(--border-strong); letter-spacing: .04em; }
.badge-kfs::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--sam-red); }
.badge-ers { background: #fff; color: #1F3F8F; border-color: #BCCBEA; letter-spacing: .04em; }
.badge-ers::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: #1F3F8F; }
.badge-solid { background: var(--sam-dark); color: #fff; }
.badge-brand { background: var(--sam-gradient-warm); color: #1a1a1a; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--sam-red); color: #fff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.slot {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 22px; padding: 0 6px;
  border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .03em; line-height: 1;
  background: var(--neutral-bg); color: var(--sam-dark);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
  flex: none;
}
.slot-k { background: var(--ink-k); color: #fff; }
.slot-c { background: var(--ink-c); color: #062A3A; }
.slot-m { background: var(--ink-m); color: #fff; }
.slot-y { background: var(--ink-y); color: #3A3000; box-shadow: inset 0 0 0 1px rgba(160, 130, 0, .35); }
.slot-bac { background: var(--ink-bac); color: #fff; }
.slot-kit { background: var(--ink-kit); color: #fff; }
.slot-tam { background: #fff; color: var(--sam-bordeaux); box-shadow: inset 0 0 0 1.5px var(--sam-bordeaux); }

/* 13. Jauges --------------------------------------------------------------- */
.gauge { --g-c: var(--ok); display: flex; align-items: center; gap: 12px; min-width: 0; }
.gauge-bar {
  position: relative; flex: 1 1 auto; min-width: 70px; height: 10px;
  background: #ECEAE7; border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
}
.gauge-fill {
  position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%);
  border-radius: 999px; background: var(--g-c);
  transition: width .5s var(--ease);
}
.gauge-seuil {
  position: absolute; top: -4px; bottom: -4px; left: var(--pct, 0%);
  width: 2px; margin-left: -1px; border-radius: 1px;
  background: var(--sam-dark);
}
.gauge-seuil::after { /* petit repère triangulaire au-dessus du trait */
  content: ""; position: absolute; top: -4px; left: -3px;
  border: 4px solid transparent; border-bottom: 0; border-top: 4px solid var(--sam-dark);
}
.gauge-val { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 48px; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--sam-dark); white-space: nowrap; }
.gauge-flag { width: 14px; height: 14px; }
.gauge-stock { flex: none; }
.gauge-stock .icon { width: 12px; height: 12px; }
.gauge-ok { --g-c: var(--ok); }
.gauge-bientot { --g-c: var(--sam-orange); }
.gauge-alerte { --g-c: var(--sam-red); }
.gauge-alerte .gauge-val { color: var(--alert-text); }
.gauge-critique { --g-c: var(--sam-bordeaux); }
.gauge-critique .gauge-fill { background: repeating-linear-gradient(-45deg, var(--sam-bordeaux) 0 4px, var(--sam-red) 4px 8px); min-width: 4px; }
.gauge-critique .gauge-val { color: var(--sam-bordeaux); }
.gauge-critique .gauge-bar { background: #F7E3E6; }
.gauge-inconnu .gauge-bar { background: repeating-linear-gradient(-45deg, #ECEAE7 0 5px, #F6F5F3 5px 10px); }
.gauge-inconnu .gauge-fill { display: none; }
.gauge-inconnu .gauge-val { color: var(--muted); font-weight: 500; }
.gauge-compact { gap: 8px; }
.gauge-compact .slot { min-width: 30px; height: 18px; font-size: 10px; border-radius: 5px; }
.gauge-compact .gauge-bar { height: 6px; min-width: 50px; }
.gauge-compact .gauge-seuil { top: -3px; bottom: -3px; }
.gauge-compact .gauge-seuil::after { display: none; }
.gauge-compact .gauge-val { min-width: 40px; font-size: 12px; }
.gauge-compact .gauge-flag { width: 12px; height: 12px; }
.gauge-compact .gauge-stock { padding: 1px 7px; font-size: 10.5px; }

.levels { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@supports (grid-template-columns: subgrid) {
  .levels { display: grid; grid-template-columns: auto minmax(70px, 1fr) auto auto; column-gap: 12px; row-gap: 12px; }
  .levels > .gauge { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; }
  .levels > .gauge > .gauge-stock { justify-self: start; }
  .levels-compact { column-gap: 8px; row-gap: 6px; grid-template-columns: auto minmax(50px, 1fr) auto auto; }
  .levels > .levels-empty { grid-column: 1 / -1; }
}
.levels-compact { gap: 6px; min-width: 200px; }
.levels-empty { display: inline-flex; align-items: center; gap: 6px; }

.progress { position: relative; height: 8px; border-radius: 999px; background: #ECEAE7; overflow: hidden; }
.progress-fill { position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%); background: var(--sam-gradient); border-radius: 999px; transition: width .5s var(--ease); }

/* 14. Onglets & flash ------------------------------------------------------ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-strong); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px 12px; margin-bottom: -1px;
  color: var(--text-2); font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap;
  border-radius: 8px 8px 0 0; border: 0; background: none; cursor: pointer; font-family: inherit;
}
.tab .icon { width: 16px; height: 16px; }
.tab .count { background: var(--neutral-bg); color: var(--text-2); }
.tab:hover { color: var(--sam-dark); background: rgba(0, 0, 0, .03); }
.tab.active, .tab[aria-selected="true"] { color: var(--sam-dark); }
.tab.active::after, .tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--sam-gradient); }
.tab.active .count { background: var(--sam-red); color: #fff; }
.tab-panel:focus-visible { outline: none; }

.flash {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--fl-c, var(--info));
  box-shadow: var(--shadow-sm); font-weight: 500;
  animation: slide-in .25s var(--ease);
}
.flash-icon { color: var(--fl-c, var(--info)); margin-top: 1px; }
.flash-msg { flex: 1; min-width: 0; }
.flash-close { border: 0; background: none; padding: 4px; margin: -3px -4px -3px 0; border-radius: 5px; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; }
.flash-close:hover { background: rgba(0, 0, 0, .06); color: var(--sam-dark); }
.flash-success { --fl-c: var(--ok); background: #F7FCF9; }
.flash-error { --fl-c: var(--sam-red); background: #FFF8F9; }
.flash-warning { --fl-c: var(--sam-orange-2); background: #FFFBF4; }
.flash-info { --fl-c: var(--info); background: #F7FAFD; }
.flash.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .3s, transform .3s; }

.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.callout > .icon { color: var(--sam-orange-2); margin-top: 1px; }

/* 15. État vide, timeline, sparkline -------------------------------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 48px 24px; }
.empty-icon { display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 12px; border-radius: 20px; color: var(--sam-orange-2); background: radial-gradient(120% 120% at 30% 20%, #FFF4E3 0%, #FDE3D6 60%, #FAD6DA 100%); box-shadow: inset 0 0 0 1px rgba(255, 111, 0, .12); }
.empty-title { margin: 0; font-size: 1.05rem; }
.empty-text { margin: 4px 0 0; max-width: 46ch; color: var(--muted); }
.empty-action { margin-top: 16px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline-item { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 2px; width: 2px; background: var(--border); border-radius: 1px; }
.timeline-dot { --tl-c: var(--sam-grey); position: relative; display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: #fff; color: var(--tl-c); box-shadow: inset 0 0 0 2px var(--tl-c); }
.timeline-body { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; min-width: 0; }
.timeline-msg { font-weight: 500; color: var(--text); }
.timeline-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.timeline-user::before { content: "·"; margin-right: 8px; }
.timeline-creation .timeline-dot { --tl-c: var(--sam-orange-2); }
.timeline-statut .timeline-dot, .timeline-info .timeline-dot, .timeline-livraison .timeline-dot { --tl-c: var(--info); }
.timeline-livree .timeline-dot, .timeline-ok .timeline-dot, .timeline-pose .timeline-dot { --tl-c: var(--ok); }
.timeline-alerte .timeline-dot, .timeline-erreur .timeline-dot { --tl-c: var(--sam-red); }
.timeline-warn .timeline-dot, .timeline-import .timeline-dot { --tl-c: var(--sam-orange-2); }
.timeline-empty { padding: 6px 0; }

.sparkline { color: var(--sam-orange-2); overflow: visible; }
.sparkline-area { fill: rgba(255, 111, 0, .1); stroke: none; }
.sparkline.is-down { color: var(--sam-red); }
.sparkline.is-down .sparkline-area { fill: rgba(212, 7, 40, .08); }

/* 16. Pagination ----------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; padding: 16px 0 0; }
.pagination a, .pagination span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; font-weight: 600; font-size: 13px; text-decoration: none; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pagination a:hover { background: #fff; color: var(--sam-dark); box-shadow: inset 0 0 0 1px var(--border-strong); }
.pagination .active { background: var(--sam-dark); color: #fff; }
.pagination .disabled { color: #C4C1BD; }
.pagination .page-gap { min-width: 20px; padding: 0; color: var(--muted); }
.card-footer .pagination { padding: 0; margin: 0 auto; }

/* 17. Modale, toast, menus ------------------------------------------------- */
dialog.modal {
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: var(--radius-lg);
  background: #fff; color: var(--text); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal-lg { width: min(720px, calc(100vw - 32px)); }
dialog.modal[open] { animation: pop .18s var(--ease); }
dialog.modal::backdrop { background: rgba(20, 20, 20, .5); backdrop-filter: blur(2px); }
.modal-stripe { display: block; height: 4px; background: var(--sam-gradient); }
.modal-body { display: flex; gap: 16px; padding: 24px 24px 8px; }
.modal-body-plain { display: block; padding: 20px 24px 8px; overflow-y: auto; max-height: calc(100vh - 220px); }
.modal-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--warn-bg); color: var(--sam-orange-2); }
.modal-icon .icon { width: 22px; height: 22px; }
.modal-danger .modal-icon { background: var(--alert-bg); color: var(--sam-red); }
.modal-title { margin: 2px 0 6px; font-size: 1.05rem; }
.modal-text { margin: 0; color: var(--text-2); white-space: pre-line; }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 18px 24px 0; }
.modal-header .modal-title { flex: 1; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 18px 24px 22px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toasts .flash { box-shadow: var(--shadow-lg); }

.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease); }
.dropdown-menu a, .dropdown-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: var(--radius-sm); font: inherit; color: var(--text); text-decoration: none; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-hover); color: var(--sam-dark); }

.spinner { display: inline-block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid #F0E6DA; border-top-color: var(--sam-orange-2); border-right-color: var(--sam-red); animation: spin .8s linear infinite; }
.is-loading { position: relative; pointer-events: none; opacity: .7; }

@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* 18. Authentification ---------------------------------------------------- */
body.auth { background: #fff; }
.auth-shell { display: grid; grid-template-columns: minmax(380px, 46%) 1fr; min-height: 100vh; }
.auth-hero {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  padding: 56px 56px 36px; overflow: hidden; color: #fff;
  background:
    radial-gradient(90% 60% at 100% 0%, rgba(255, 111, 0, .32) 0%, rgba(255, 111, 0, 0) 60%),
    radial-gradient(80% 60% at 0% 100%, rgba(161, 26, 46, .55) 0%, rgba(161, 26, 46, 0) 65%),
    var(--sam-dark);
}
.auth-hero::after { content: ""; position: absolute; inset: 0 0 0 auto; width: 5px; background: var(--sam-gradient-v); }
.auth-hero-inner { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; flex: 1; max-width: 440px; margin: 0 auto; width: 100%; }
.auth-logo { width: 124px; height: auto; margin-bottom: 30px; filter: drop-shadow(0 12px 28px rgba(0, 0, 0, .45)); }
.auth-kicker { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--sam-orange); }
.auth-title { margin: 0; font-size: 44px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; }
.auth-tagline { margin: 10px 0 0; font-size: 17px; color: #DAD7D3; font-weight: 500; }
.auth-features { list-style: none; margin: 36px 0 0; padding: 26px 0 0; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid rgba(255, 255, 255, .12); width: 100%; }
.auth-features li { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #E6E3E0; }
.auth-features .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .07); color: var(--sam-orange); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.auth-hero-foot { position: relative; margin: 32px 0 0; font-size: 12px; color: var(--sidebar-muted); text-align: center; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px 24px; background: linear-gradient(180deg, #fff 0%, var(--bg) 100%); }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.auth-card-brand { display: none; align-items: center; gap: 14px; margin-bottom: 8px; }
.auth-card-brand > span { display: flex; flex-direction: column; }
.auth-card-brand strong { font-size: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-form h1 { margin: 0 0 4px; font-size: 1.75rem; letter-spacing: -.02em; }
.auth-form h1::after { content: "Connectez-vous avec votre adresse SAM Informatique."; display: block; margin-top: 8px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.auth-form > label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 600; color: var(--sam-dark); }
.auth-form input { min-height: 46px; font-size: 15px; padding: 10px 14px; border-radius: 10px; }
.auth-form .btn { min-height: 48px; font-size: 15px; margin-top: 6px; border-radius: 10px; }
.auth-form .btn::after { content: ""; width: 18px; height: 18px; background: currentColor; clip-path: polygon(0 45%, 70% 45%, 45% 18%, 54% 10%, 100% 50%, 54% 90%, 45% 82%, 70% 55%, 0 55%); }
.auth-foot { margin: 40px 0 0; text-align: center; }

/* 19. Pages d'erreur & autonomes ------------------------------------------ */
.error-page { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; max-width: 560px; margin: 0 auto; }
.error-page h2 { margin: 0 0 8px; font-size: 1.4rem; }
.error-code { font-size: 96px; line-height: 1; font-weight: 700; letter-spacing: -.04em; background: var(--sam-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; opacity: .9; margin-bottom: 8px; }
.error-page .empty-icon { display: none; }
.error-actions { justify-content: center; margin-top: 12px; }
body.standalone { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.standalone-card { position: relative; width: min(560px, 100%); padding: 44px 40px 36px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); text-align: center; overflow: hidden; }
.standalone-card h1 { margin: 14px 0 10px; font-size: 1.5rem; }
.standalone-stripe { position: absolute; inset: 0 0 auto; height: 5px; background: var(--sam-gradient); }
.error-trace { text-align: left; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-size: 12px; margin-top: 20px; }

/* 20. Charte graphique (styleguide) --------------------------------------- */
.sg-nav { position: sticky; top: calc(var(--topbar-h) + 8px); display: flex; flex-direction: column; gap: 2px; }
.sg-nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 500; }
.sg-nav a:hover { background: #fff; color: var(--sam-dark); }
.sg-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; align-items: start; }
.sg-section { scroll-margin-top: calc(var(--topbar-h) + 12px); }
.sg-section > * + * { margin-top: 16px; }
.sg-section > h2 + * { margin-top: 0; }
.sg-section > h2 { flex-wrap: wrap; display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.sg-section > h2 code { font-size: 12px; font-weight: 500; color: var(--muted); }
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.sg-swatch { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; font-size: 12px; }
.sg-swatch-color { height: 64px; }
.sg-swatch-meta { padding: 8px 10px; display: flex; flex-direction: column; }
.sg-swatch-meta strong { font-size: 12.5px; }
.sg-swatch-meta code { background: none; padding: 0; color: var(--muted); }
.sw-orange { background: var(--sam-orange); } .sw-orange-2 { background: var(--sam-orange-2); } .sw-orange-3 { background: var(--sam-orange-3); }
.sw-pink { background: var(--sam-pink); } .sw-red { background: var(--sam-red); } .sw-bordeaux { background: var(--sam-bordeaux); }
.sw-black { background: var(--sam-black); } .sw-dark { background: var(--sam-dark); } .sw-grey { background: var(--sam-grey); }
.sw-white { background: var(--sam-white); border-bottom: 1px solid var(--border); } .sw-gradient { background: var(--sam-gradient); }
.sg-demo { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sg-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.sg-icon { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; font-size: 11.5px; color: var(--text-2); }
.sg-icon .icon { width: 24px; height: 24px; color: var(--sam-dark); }
.sg-type > * { margin: 0 0 6px; }
.sg-code { display: block; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--sam-dark); color: #F3F1EE; font-size: 12px; white-space: pre-wrap; overflow-x: auto; }
.sg-machine { display: flex; flex-direction: column; gap: 2px; }
.sg-gauge-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* 21. Responsive ----------------------------------------------------------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1500px) {
  .sg-layout { grid-template-columns: minmax(0, 1fr); }
  .sg-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sg-nav a { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; }
}
@media (max-width: 1080px) {
  :root { --gutter: 24px; }
  .sg-layout { grid-template-columns: minmax(0, 1fr); }
  .sg-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 960px) {
  :root { --gutter: 20px; }
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s var(--ease), visibility .25s; visibility: hidden; box-shadow: none; width: min(300px, 86vw); }
  .sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .sidebar-close { display: inline-grid; place-items: center; }
  .topbar button.topbar-menu.btn-icon { display: inline-grid; place-items: center; margin-left: -8px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card-brand { display: flex; }
  .auth-main { justify-content: flex-start; padding-top: 12vh; }
}
@media (max-width: 720px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  body { font-size: 14px; }
  .hide-mobile { display: none !important; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .page-header { padding-top: 10px; padding-bottom: 16px; align-items: stretch; flex-direction: column; }
  .page-heading { flex: none; }
  .page-title { font-size: 1.35rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .kpi { padding: 14px 14px 14px 16px; }
  .kpi-value { font-size: 1.55rem; }
  .kpi-icon-wrap { width: 30px; height: 30px; border-radius: 8px; }
  .kpi-icon { width: 16px; height: 16px; }
  .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
  .card-footer, .card > .toolbar { padding-left: 16px; padding-right: 16px; }
  .toolbar > * { flex: 1 1 100%; max-width: none; }
  .toolbar .search-input { max-width: none; }
  .toolbar select { max-width: none; width: 100%; }
  .toolbar-count { margin-left: 0; }
  .table th, .table td { padding: 10px 12px; }
  .gauge { gap: 8px; }
  .gauge-stock { font-size: 10.5px; padding: 2px 7px; }
  .breadcrumb li:not(:first-child):not(:last-child) { display: none; }
  .modal-actions .btn { flex: 1 1 auto; }
  .app-footer { flex-direction: column; gap: 2px; }
  .user-menu-trigger { padding: 3px; }
  .error-code { font-size: 72px; }
  .auth-form h1 { font-size: 1.5rem; }
  .tabs { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
}
@media (max-width: 400px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* 22. Impression (bons de livraison, listes) ------------------------------- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  :root { --gutter: 0; }
  body, body.auth { background: #fff; color: #000; font-size: 11pt; }
  .no-print, .sidebar, .sidebar-backdrop, .topbar, .flashes, .app-footer, .page-actions, .toolbar, .pagination, .btn, .tabs, .toasts, dialog { display: none !important; }
  .print-only { display: block !important; }
  span.print-only, .print-inline { display: inline !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .page-header { padding: 0 0 10pt; }
  .page-title { font-size: 18pt; }
  .page-title::after { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card, .kpi, .table-wrap { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .table-wrap { overflow: visible; border: 0; }
  .table { font-size: 10pt; }
  .table thead th { position: static; background: #eee; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table tr { break-inside: avoid; }
  .table tbody tr:hover { background: none; }
  .slot, .gauge-fill, .badge, .sam-print-header { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
  .sam-print-header { display: flex !important; align-items: center; gap: 12pt; padding-bottom: 8pt; margin-bottom: 12pt; border-bottom: 2pt solid #FF6F00; }
  .signature-box { border: 1px solid #999; min-height: 28mm; padding: 6pt; }
}
.sam-print-header { display: none; }
.signature-box { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); min-height: 90px; padding: 10px; color: var(--muted); font-size: 12px; }

/* 23. Largeurs .pct-0 … .pct-100 (jauges, barres) — CSP sans attribut style */
.pct-0{--pct:0%} .pct-1{--pct:1%} .pct-2{--pct:2%} .pct-3{--pct:3%} .pct-4{--pct:4%} .pct-5{--pct:5%} .pct-6{--pct:6%} .pct-7{--pct:7%} .pct-8{--pct:8%} .pct-9{--pct:9%} .pct-10{--pct:10%} .pct-11{--pct:11%} .pct-12{--pct:12%} .pct-13{--pct:13%} .pct-14{--pct:14%} .pct-15{--pct:15%} .pct-16{--pct:16%} .pct-17{--pct:17%} .pct-18{--pct:18%} .pct-19{--pct:19%} .pct-20{--pct:20%} .pct-21{--pct:21%} .pct-22{--pct:22%} .pct-23{--pct:23%} .pct-24{--pct:24%} .pct-25{--pct:25%} .pct-26{--pct:26%} .pct-27{--pct:27%} .pct-28{--pct:28%} .pct-29{--pct:29%} .pct-30{--pct:30%} .pct-31{--pct:31%} .pct-32{--pct:32%} .pct-33{--pct:33%} .pct-34{--pct:34%} .pct-35{--pct:35%} .pct-36{--pct:36%} .pct-37{--pct:37%} .pct-38{--pct:38%} .pct-39{--pct:39%} .pct-40{--pct:40%} .pct-41{--pct:41%} .pct-42{--pct:42%} .pct-43{--pct:43%} .pct-44{--pct:44%} .pct-45{--pct:45%} .pct-46{--pct:46%} .pct-47{--pct:47%} .pct-48{--pct:48%} .pct-49{--pct:49%} .pct-50{--pct:50%} .pct-51{--pct:51%} .pct-52{--pct:52%} .pct-53{--pct:53%} .pct-54{--pct:54%} .pct-55{--pct:55%} .pct-56{--pct:56%} .pct-57{--pct:57%} .pct-58{--pct:58%} .pct-59{--pct:59%} .pct-60{--pct:60%} .pct-61{--pct:61%} .pct-62{--pct:62%} .pct-63{--pct:63%} .pct-64{--pct:64%} .pct-65{--pct:65%} .pct-66{--pct:66%} .pct-67{--pct:67%} .pct-68{--pct:68%} .pct-69{--pct:69%} .pct-70{--pct:70%} .pct-71{--pct:71%} .pct-72{--pct:72%} .pct-73{--pct:73%} .pct-74{--pct:74%} .pct-75{--pct:75%} .pct-76{--pct:76%} .pct-77{--pct:77%} .pct-78{--pct:78%} .pct-79{--pct:79%} .pct-80{--pct:80%} .pct-81{--pct:81%} .pct-82{--pct:82%} .pct-83{--pct:83%} .pct-84{--pct:84%} .pct-85{--pct:85%} .pct-86{--pct:86%} .pct-87{--pct:87%} .pct-88{--pct:88%} .pct-89{--pct:89%} .pct-90{--pct:90%} .pct-91{--pct:91%} .pct-92{--pct:92%} .pct-93{--pct:93%} .pct-94{--pct:94%} .pct-95{--pct:95%} .pct-96{--pct:96%} .pct-97{--pct:97%} .pct-98{--pct:98%} .pct-99{--pct:99%} .pct-100{--pct:100%}

/* Finition bêta 4 : ligne de regroupement (année) dans un tableau */
.table tr.table-section th { background: var(--surface-2); color: var(--text); font-weight: 600; text-align: left; font-size: 13px; border-top: 2px solid var(--border-strong); }

/* Catalogue bêta 4.2 : recherche « Compatibilités » (suggestions), fiches modèle / consommable */
.compat-search { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.compat-search-field { position: relative; flex: 1 1 320px; max-width: 640px; }
.compat-search-field input[type="search"] { font-size: 15px; min-height: 42px; }
.suggest-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto; }
.suggest-list li a { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; padding: 7px 9px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.suggest-list li.is-active a, .suggest-list li a:hover { background: var(--surface-hover); }
.suggest-type { grid-row: span 2; align-self: center; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.suggest-type.suggest-modele { background: #FFF1DD; color: #8A4B00; }
.suggest-label { font-weight: 600; }
.suggest-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compat-fiche .card-header { gap: 10px; flex-wrap: wrap; }
.compat-alias { padding-top: 0; }
.compat-table tr.is-alternative td { color: var(--muted); }
.compat-table tr.is-alternative td a { color: inherit; }
.compat-table tr.is-prefere td { background: #FFFBF4; }
.compat-ajout { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.compat-ajout .field { margin: 0; min-width: 180px; }
.inline-form { display: inline; }
.dl-inline { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl-inline dt { color: var(--muted); }
.dl-inline dd { margin: 0; }
.compat-clients { padding-top: 0; padding-bottom: 6px; }
.compat-clients .icon { width: 14px; height: 14px; vertical-align: -2px; color: var(--muted); }
[data-copy] { color: var(--muted); }
[data-copy].is-copied { color: var(--ok-text, #1E7B34); }
.list-plain { list-style: none; margin: 0; }
.list-plain li { padding: 3px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.text-danger { color: var(--alert-text, #B42318); }
@media (max-width: 640px) { .compat-search .btn { width: 100%; } .dl-inline { grid-template-columns: 1fr; } }

/* 30. Catégories de gestion (bêta 4.3) : couleur du badge choisie dans Paramètres → Catégories ------------------- */
.badge-cat { border-color: transparent; }
.badge-cat-orange { background: #FFF1DE; color: #8A4B00; }
.badge-cat-rouge { background: #FDE3E6; color: #A1122A; }
.badge-cat-bordeaux { background: #F5E1E4; color: #7A1222; }
.badge-cat-bleu { background: #E3EBFA; color: #1F3F8F; }
.badge-cat-vert { background: #E2F4E8; color: #1D6B3A; }
.badge-cat-violet { background: #EEE6FA; color: #5B2E9E; }
.badge-cat-jaune { background: #FFF7CC; color: #6B5600; }
.badge-cat-gris { background: #EEEDEB; color: #4A4848; }
.col-check { width: 34px; text-align: center; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.bulk-bar .field-inline { display: flex; align-items: center; gap: 6px; }
.contrat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; }
.contrat-grid .stack { gap: 2px; }
