/* ==========================================================================
   Custom Shop — Intranet
   Feuille de style principale. Les couleurs proviennent des variables
   générées depuis « Gestion de l'entreprise > Thème ».
   ========================================================================== */

:root {
  --primary: #c8a96a; --primary-contrast: #15120b;
  --bg: #0e1014; --surface: #161920; --surface-2: #1c2029; --border: #2a2f3a;
  --text: #e9e7e2; --text-muted: #939aa6;
  --success: #3fb68b; --danger: #e5534b; --warning: #d9a441; --info: #5b9bd5;

  --primary-soft: color-mix(in srgb, var(--primary) 14%, transparent);
  --primary-line: color-mix(in srgb, var(--primary) 40%, transparent);
  --success-soft: color-mix(in srgb, var(--success) 14%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 14%, transparent);
  --warning-soft: color-mix(in srgb, var(--warning) 16%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 14%, transparent);
  --hover: color-mix(in srgb, var(--text) 6%, transparent);

  --radius: 14px; --radius-sm: 9px; --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px -12px rgba(0,0,0,.25);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Playfair Display", Georgia, serif;
  --topbar-h: 64px;
  --t: .18s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 400 14.5px/1.55 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
code, kbd { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); padding: .08em .4em; border-radius: 5px; }
::selection { background: var(--primary-soft); }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-xl { width: 44px; height: 44px; }
.muted { color: var(--text-muted); }
.small { font-size: .85em; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; }
.hidden, [hidden] { display: none !important; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: .5rem } .mt-2 { margin-top: 1rem } .mt-3 { margin-top: 1.5rem }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: .5rem } .mb-2 { margin-bottom: 1rem } .mb-3 { margin-bottom: 1.5rem }
.flex { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.grow { flex: 1; }
.only-light { display: none; }
[data-theme="light"] .only-light { display: inline-flex; }
[data-theme="light"] .only-dark { display: none; }

/* --- Barre supérieure -------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { height: 100%; max-width: 1440px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #000)); color: var(--primary-contrast); }
.brand-name { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .01em; }
.mainnav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.mainnav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; white-space: nowrap; transition: color var(--t), background var(--t);
}
.mainnav a:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.mainnav a.active { color: var(--primary); background: var(--primary-soft); }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn.nav-toggle { display: none; }
.nav-backdrop { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t); padding: 0; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.icon-btn.disabled { opacity: .35; pointer-events: none; }
.icon-btn.sm { width: 32px; height: 32px; }

.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit;
}
.user-chip:hover { border-color: var(--primary-line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .8rem; background: var(--primary-soft); color: var(--primary); letter-spacing: .03em; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-meta strong { font-size: .86rem; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: .74rem; color: var(--text-muted); }
.user-chip .chev { width: 16px; height: 16px; color: var(--text-muted); }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 6px; opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity var(--t), transform var(--t);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: var(--radius-xs); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--hover); text-decoration: none; }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }

/* --- Contenu ----------------------------------------------------------- */
.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 20px 40px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.85rem; font-weight: 600; letter-spacing: 0; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.site-footer { display: flex; justify-content: space-between; gap: 1rem; max-width: 1440px; width: 100%; margin: 0 auto; padding: 18px 20px 28px; font-size: .8rem; color: var(--text-muted); border-top: 1px solid var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.02rem; display: flex; align-items: center; gap: 10px; }
.card-head h2 .icon, .card-head h3 .icon { color: var(--primary); }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 20px; }
.section-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); font-weight: 600; margin: 0 0 12px; }

.grid { display: grid; gap: 16px; }
.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)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }

/* --- Statistiques ------------------------------------------------------ */
.stat { display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; position: relative; overflow: hidden; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.stat-icon .icon { width: 20px; height: 20px; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-hint { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.stat.highlight { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 20%, var(--surface)), var(--surface) 70%); border-color: var(--primary-line); }
.stat.highlight .stat-value { color: var(--primary); }
.stat.tone-success .stat-icon { background: var(--success-soft); color: var(--success); }
.stat.tone-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat.tone-info .stat-icon { background: var(--info-soft); color: var(--info); }
.stat.tone-warning .stat-icon { background: var(--warning-soft); color: var(--warning); }

/* --- Boutons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: 500 .9rem/1 var(--font); cursor: pointer; white-space: nowrap; transition: background var(--t), border-color var(--t), color var(--t), transform .08s, box-shadow var(--t);
  text-decoration: none; user-select: none;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.loading { opacity: .6; cursor: not-allowed; }
.btn.loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #fff); border-color: color-mix(in srgb, var(--primary) 88%, #fff); box-shadow: 0 6px 18px -8px var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); border-color: transparent; }
.btn-outline { background: transparent; border-color: var(--primary-line); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-sm { height: 32px; padding: 0 11px; font-size: .82rem; border-radius: var(--radius-xs); gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: .78rem; border-radius: var(--radius-xs); gap: 5px; }
.btn-xs .icon { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Formulaires ------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .82rem; font-weight: 500; color: var(--text-muted); }
.field .hint { font-size: .78rem; color: var(--text-muted); }
.req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 13px; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color var(--t), box-shadow var(--t), background var(--t);
  appearance: none; -webkit-appearance: none;
}
textarea.input { height: auto; min-height: 100px; padding: 11px 13px; resize: vertical; line-height: 1.5; }
select.input { padding-right: 38px; cursor: pointer; 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='%23939aa6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:hover { border-color: color-mix(in srgb, var(--text) 22%, var(--border)); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--surface); }
.input::placeholder { color: color-mix(in srgb, var(--text-muted) 70%, transparent); }
.input-sm { height: 34px; font-size: .86rem; padding: 0 10px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; background: var(--surface); color: var(--text-muted); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .88rem; white-space: nowrap; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; height: auto; border-left: 0; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; z-index: 1; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.plate-input { text-transform: uppercase; letter-spacing: .12em; font-family: ui-monospace, Menlo, monospace; font-weight: 600; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: .9rem; }
.check input { appearance: none; -webkit-appearance: none; width: 19px; height: 19px; margin: 0; border: 1.5px solid color-mix(in srgb, var(--text) 30%, var(--border)); border-radius: 5px; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; transition: var(--t); flex: none; }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { content: ""; width: 5px; height: 10px; border: solid var(--primary-contrast); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:focus-visible { box-shadow: 0 0 0 3px var(--primary-soft); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.perm-grid .check { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); cursor: pointer; font-size: .86rem; transition: var(--t); }
.choice span:hover { border-color: var(--primary-line); }
.choice input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 500; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.choice small { opacity: .75; }

/* --- Onglets ----------------------------------------------------------- */
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab-list::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 11px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); font: 500 .9rem var(--font); cursor: pointer; white-space: nowrap; transition: var(--t); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; animation: fade .2s ease; }
.tab-panel.active { display: block; }
.tabs-pill .tab-list { border: 1px solid var(--border); background: var(--surface-2); padding: 4px; border-radius: 12px; display: inline-flex; max-width: 100%; }
.tabs-pill .tab { border: 0; border-radius: 9px; margin: 0; padding: 9px 16px; }
.tabs-pill .tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.tabs-vertical { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.tabs-vertical > .tab-list { flex-direction: column; border: 0; margin: 0; position: sticky; top: calc(var(--topbar-h) + 20px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.tabs-vertical > .tab-list .tab { border: 0; border-radius: var(--radius-sm); margin: 0; justify-content: flex-start; padding: 10px 12px; }
.tabs-vertical > .tab-list .tab.active { background: var(--primary-soft); }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* --- Tableaux ---------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--t); }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.is-muted td { opacity: .55; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 22px; }
.card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: 22px; }
.cell-title { font-weight: 500; }
.cell-sub { display: block; font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* --- Badges ------------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badge-custom { background: color-mix(in srgb, #a78bfa 15%, transparent); color: #a78bfa; border-color: transparent; }
.badge-sale { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-repair { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-muted { opacity: .8; }
[data-theme="light"] .badge-custom { color: #7c3aed; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); margin: 2px 4px 2px 0; white-space: nowrap; }
.chip .icon { width: 12px; height: 12px; }
.chip-vip { color: var(--primary); border-color: var(--primary-line); }
.chip-partner { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.level-pill { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; font-size: .78rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); }

/* --- Alertes ----------------------------------------------------------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); font-size: .9rem; margin-bottom: 16px; }
.alert .icon { margin-top: 1px; }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert-info .icon { color: var(--info); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.alert-warning .icon { color: var(--warning); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-danger .icon { color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.alert-success .icon { color: var(--success); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon-xl { color: var(--primary); opacity: .8; margin-bottom: 12px; }
.empty-state h2 { color: var(--text); }
.empty { padding: 30px 20px; text-align: center; color: var(--text-muted); font-size: .9rem; }

/* --- Modales ----------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; visibility: hidden; opacity: 0; transition: opacity var(--t), visibility var(--t); overflow-y: auto; }
.modal.open { visibility: visible; opacity: 1; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 6, 9, .62); backdrop-filter: blur(3px); }
.modal-dialog { position: relative; width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); transform: translateY(12px) scale(.98); transition: transform var(--t); margin-bottom: 6vh; }
.modal.open .modal-dialog { transform: none; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1100px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
body.modal-open { overflow: hidden; }
.radio-badge { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); margin-bottom: 18px; }
.radio-badge span { color: var(--text-muted); font-size: .85rem; }
.radio-badge strong { font-size: 1.1rem; letter-spacing: .03em; }
.copy-box { position: relative; }
.copy-box textarea { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; min-height: 220px; }

/* --- Toasts ------------------------------------------------------------ */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: .9rem; animation: toast-in .25s ease; border-left: 3px solid var(--primary); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.hide { opacity: 0; transform: translateX(20px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --- Pagination & périodes -------------------------------------------- */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: grid; place-items: center; padding: 0 8px; border-radius: var(--radius-xs); color: var(--text-muted); font-size: .86rem; border: 1px solid transparent; }
.pagination a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.pagination .current { background: var(--primary-soft); color: var(--primary); font-weight: 600; border-color: var(--primary-line); }
.pagination .disabled { opacity: .35; }
.period-nav { display: flex; align-items: center; gap: 6px; }
.period-nav select { min-width: 240px; height: 38px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- Combobox (recherche d'articles) ----------------------------------- */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; display: none; }
.combo.open .combo-list { display: block; }
.combo-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 8px 10px 4px; font-weight: 600; }
.combo-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-xs); cursor: pointer; }
.combo-item:hover, .combo-item.active { background: var(--primary-soft); }
.combo-item .ref { font-family: ui-monospace, Menlo, monospace; font-size: .76rem; color: var(--text-muted); }
.combo-item mark { background: color-mix(in srgb, var(--primary) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.combo-item .price { font-weight: 600; white-space: nowrap; font-size: .86rem; }
.combo-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: .86rem; }

.cart-lines { display: flex; flex-direction: column; gap: 8px; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px 36px; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.cart-line .name { font-weight: 500; min-width: 0; }
.cart-line .name small { display: block; color: var(--text-muted); font-family: ui-monospace, Menlo, monospace; font-size: .74rem; }
.cart-line .line-total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.qty { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; background: var(--surface); }
.qty button { width: 30px; height: 34px; border: 0; background: none; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.qty button:hover { background: var(--hover); color: var(--text); }
.qty input { width: 44px; height: 34px; border: 0; background: none; text-align: center; color: var(--text); font: inherit; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.qty input:focus { outline: none; }

/* --- Récapitulatif de saisie ------------------------------------------ */
.summary { border: 1px dashed var(--primary-line); border-radius: var(--radius-sm); padding: 14px 16px; background: color-mix(in srgb, var(--primary) 5%, transparent); }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: .9rem; }
.summary-row span:first-child { color: var(--text-muted); }
.summary-row strong, .summary-row span:last-child { font-variant-numeric: tabular-nums; }
.summary-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 1.05rem; }
.summary-row.total span:last-child { color: var(--primary); font-weight: 700; }
.summary-row.salary span:last-child { color: var(--success); font-weight: 600; }

/* --- Contenu riche (éditeur) ------------------------------------------ */
.rich-content { line-height: 1.65; overflow-wrap: anywhere; }
.rich-content img { border-radius: 8px; }
.rich-content table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.rich-content td, .rich-content th { border: 1px solid var(--border); padding: 6px 10px; }
.rich-content blockquote { margin: 1em 0; padding: .5em 1em; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.rich-content > :last-child { margin-bottom: 0; }

.editor { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.editor-toolbar button, .editor-toolbar select, .editor-toolbar label.color { height: 32px; min-width: 32px; padding: 0 7px; border: 0; border-radius: 6px; background: none; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font: 600 .85rem var(--font); }
.editor-toolbar button:hover, .editor-toolbar label.color:hover { background: var(--hover); color: var(--text); }
.editor-toolbar button.active { background: var(--primary-soft); color: var(--primary); }
.editor-toolbar select { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 4px 4px; }
.editor-toolbar label.color input { width: 0; height: 0; opacity: 0; position: absolute; }
.editor-toolbar label.color { position: relative; }
.editor-toolbar label.color i { display: block; width: 14px; height: 3px; border-radius: 2px; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); }
.editor-area { min-height: 220px; max-height: 560px; overflow-y: auto; padding: 16px 18px; outline: none; background: var(--surface-2); }
.editor-area:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.editor-area img { cursor: pointer; }
.editor-area img.selected { outline: 2px solid var(--primary); outline-offset: 2px; }
.editor-source { width: 100%; min-height: 260px; border: 0; padding: 16px; font: .82rem/1.55 ui-monospace, Menlo, monospace; color: var(--text); background: var(--surface-2); resize: vertical; outline: none; }
.editor-tall .editor-area { min-height: 480px; max-height: 900px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list button { font-family: ui-monospace, Menlo, monospace; font-size: .76rem; padding: 5px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--primary); cursor: pointer; }
.tag-list button:hover { border-color: var(--primary); }

/* --- Thème (couleurs) -------------------------------------------------- */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.color-field { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.color-field input[type="color"] { width: 38px; height: 32px; border: 1px solid var(--border); border-radius: 7px; background: none; padding: 2px; cursor: pointer; flex: none; }
.color-field .lbl { flex: 1; font-size: .84rem; }
.color-field code { font-size: .74rem; }

/* --- Graphique --------------------------------------------------------- */
.chart-box { position: relative; height: 340px; }

/* --- Logo -------------------------------------------------------------- */
.logo-preview { width: 120px; height: 120px; border-radius: var(--radius); border: 1px dashed var(--border); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; flex: none; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* --- Pages d'authentification ---------------------------------------- */
body.auth { background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 60%),
  var(--bg); }
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px 32px; }
.auth-card.wide { max-width: 720px; }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand img { max-height: 84px; width: auto; margin: 0 auto 14px; display: block; }
.auth-brand .brand-mark { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px; }
.auth-brand .brand-mark .icon { width: 28px; height: 28px; }
.auth-brand h1 { font-family: var(--font-display); font-size: 1.7rem; margin: 0 0 4px; }
.auth-brand p { color: var(--text-muted); margin: 0; font-size: .92rem; }
.auth-card form .field + .field { margin-top: 14px; }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.strength { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 6px; }
.strength i { display: block; height: 100%; width: 0; background: var(--danger); transition: width var(--t), background var(--t); }

.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.steps span.on { background: var(--primary); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: .9rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 500; }

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 1420px) {
  .user-meta { display: none; }
  .user-chip { padding: 3px; }
  .user-chip .chev { display: none; }
  .mainnav a { padding: 8px 10px; font-size: .88rem; gap: 7px; }
  .topbar-inner { gap: 12px; }
}
@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .icon-btn.nav-toggle { display: inline-grid; }
  .mainnav {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 280px; flex-direction: column; gap: 4px; padding: 16px;
    background: var(--surface); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform var(--t); z-index: 55; overflow-y: auto;
  }
  .mainnav a { padding: 12px 14px; }
  body.nav-open .mainnav { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.45); z-index: 54; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .tabs-vertical { grid-template-columns: minmax(0, 1fr); }
  .tabs-vertical > .tab-list { flex-direction: row; position: static; overflow-x: auto; }
}
@media (max-width: 760px) {
  html { font-size: 15px; }
  .container { padding: 20px 14px 32px; }
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .brand-name { font-size: 1rem; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-value { font-size: 1.2rem; }
  .page-head h1 { font-size: 1.5rem; }
  .card-body { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 16px; }
  .card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: 16px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-dialog { max-width: none !important; border-radius: 18px 18px 0 0; margin: 0; max-height: 94vh; overflow-y: auto; }
  .modal-footer { border-radius: 0; position: sticky; bottom: 0; }
  .cart-line { grid-template-columns: minmax(0, 1fr) auto 36px; }
  .cart-line .line-total { grid-column: 1 / 2; text-align: left; }
  .period-nav { width: 100%; }
  .period-nav select { min-width: 0; flex: 1; }
  .page-actions { width: 100%; }
  .auth-card { padding: 28px 20px; }
  .site-footer { flex-direction: column; gap: 4px; text-align: center; }
  .table { font-size: .84rem; }
  .hide-sm { display: none !important; }
}
@media (max-width: 480px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 .stat-icon, .grid-5 .stat-icon { display: none; }
  .grid-5 > .stat:last-child:nth-child(odd), .grid-3 > .stat.highlight { grid-column: 1 / -1; }
  .stat-label { font-size: .7rem; letter-spacing: .04em; }
  .stat-hint { font-size: .74rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .site-footer, .page-actions, .btn, .toasts { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* Compléments */
.tab:hover { text-decoration: none; }
.tab .badge { margin-left: 2px; padding: 1px 7px; }
.card-head .tabs-pill .tab-list { margin: 0; }
.dropdown-menu .icon { color: var(--text-muted); }
.dropdown-menu .text-danger .icon { color: var(--danger); }
.table .dropdown-menu { text-align: left; }
.modal .table td { padding: 10px 12px; }
.modal .input-group .addon { padding: 0 9px; }
.dropdown-head { display: flex; flex-direction: column; padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head strong { font-size: .9rem; }
.dropdown-head small { color: var(--text-muted); font-size: .78rem; }
.grid > *, .tab-panels, .tab-panel { min-width: 0; }
@media (max-width: 480px) {
  .topbar-inner { gap: 4px; padding: 0 8px; }
  .topbar-actions { gap: 0; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-logo { height: 30px; max-width: 80px; }
  .brand-name { font-size: .95rem; max-width: 34vw; }
  .avatar { width: 30px; height: 30px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 1.15rem; }
  .grid { gap: 10px; }
  .tabs-pill .tab { padding: 8px 10px; }
  .tabs-pill .tab .icon { display: none; }
}
.grid > .card + .card, .grid > .card { margin-top: 0; }
.table-wrap .dropdown-menu { display: none; position: fixed; }
.table-wrap .dropdown.open .dropdown-menu { display: block; }
.summary-row.vault span:last-child { font-weight: 600; color: var(--text); }
