/* =====================================================================
   Gesti-Pharma — feuille de style unique (thème clair / sombre)
   ===================================================================== */
:root {
  --primary: #0f766e;
  --primary-600: color-mix(in srgb, var(--primary) 88%, #000);
  --primary-soft: color-mix(in srgb, var(--primary) 12%, transparent);
  --primary-softer: color-mix(in srgb, var(--primary) 6%, transparent);
  --accent: #6366f1;
  --success: #16a34a; --success-soft: #16a34a1f;
  --warning: #d97706; --warning-soft: #d977061f;
  --danger:  #dc2626; --danger-soft:  #dc26261f;
  --info:    #0284c7; --info-soft:    #0284c71f;
  --violet:  #7c3aed; --violet-soft:  #7c3aed1f;

  --bg: #f3f6f9;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, var(--primary-softer), transparent 60%), #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e3e8ef;
  --border-strong: #cfd7e2;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --sidebar-bg: #0b1f24;
  --sidebar-text: #b9c9cc;
  --sidebar-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 24px -8px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sidebar-w: 268px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1117; --bg-grad: radial-gradient(1200px 600px at 100% -10%, var(--primary-soft), transparent 60%), #0b1117;
    --surface: #111a22; --surface-2: #0f171e; --surface-3: #18232d; --border: #1f2c38; --border-strong: #2b3b49;
    --text: #e6edf3; --text-2: #b3c1cd; --muted: #8b9aa8; --sidebar-bg: #081116;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 28px -10px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1117; --bg-grad: radial-gradient(1200px 600px at 100% -10%, var(--primary-soft), transparent 60%), #0b1117;
  --surface: #111a22; --surface-2: #0f171e; --surface-3: #18232d; --border: #1f2c38; --border-strong: #2b3b49;
  --text: #e6edf3; --text-2: #b3c1cd; --muted: #8b9aa8; --sidebar-bg: #081116;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 28px -10px rgba(0,0,0,.6); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg-grad); background-attachment: fixed; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 .8em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, .mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
::selection { background: var(--primary-soft); }

/* ---------- Mise en page ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg);
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--primary) 22%, transparent), transparent 40%);
  color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 40; transition: width .2s ease, transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 18px 14px 14px 18px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; min-width: 0; flex: 1; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 58px; height: 58px; object-fit: contain; border-radius: 14px; background: #fff; padding: 4px; flex: none; box-shadow: 0 6px 18px -8px rgba(0,0,0,.6); }
.sidebar-brand:has(.brand-logo) { padding-top: 16px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.06); margin-bottom: 6px; }
.sidebar-brand:has(.brand-logo) .brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: .01em; white-space: normal; line-height: 1.2; }
body.sidebar-mini .brand-logo { width: 46px; height: 46px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 50%, #22d3ee)); font-size: 20px; color: #fff; box-shadow: 0 6px 18px -6px var(--primary); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11.5px; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-pin { background: transparent; border: 0; color: var(--sidebar-text); cursor: pointer; padding: 6px; border-radius: 8px; }
.sidebar-pin:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--sidebar-text); font-weight: 500; font-size: 13.5px; margin: 1px 0; position: relative; }
.nav-link i { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 55%, transparent), color-mix(in srgb, var(--primary) 18%, transparent)); color: var(--sidebar-active); font-weight: 600; }
.nav-link.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #5eead4; }
.nav-top { margin-bottom: 4px; }
.nav-group { margin-top: 8px; }
.nav-group-title { width: 100%; display: flex; justify-content: space-between; align-items: center; background: none; border: 0; cursor: pointer;
  color: #6f8a8f; font: 700 10.5px var(--font); text-transform: uppercase; letter-spacing: .09em; padding: 8px 12px 4px; }
.nav-group-title i { font-size: 9px; transition: transform .2s; }
.nav-group:not(.open) .nav-group-title i { transform: rotate(-90deg); }
.nav-group-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s ease; }
.nav-group-items > * { min-height: 0; }
.nav-group:not(.open) .nav-group-items { display: none; }
.sidebar-foot { padding: 10px 18px 14px; font-size: 11px; color: #5b7478; border-top: 1px solid rgba(255,255,255,.06); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; transition: margin .2s ease; }
body.sidebar-mini .sidebar { width: 74px; }
body.sidebar-mini .main { margin-left: 74px; }
body.sidebar-mini .brand-text, body.sidebar-mini .nav-link span, body.sidebar-mini .nav-group-title span, body.sidebar-mini .sidebar-foot, body.sidebar-mini .nav-group-title i { display: none; }
body.sidebar-mini .nav-group:not(.open) .nav-group-items { display: grid; }
body.sidebar-mini .nav-link { justify-content: center; padding: 10px; }
body.sidebar-mini .sidebar-brand { flex-direction: column; padding: 14px 8px; }
body.sidebar-mini .sidebar-pin i { transform: rotate(180deg); }
.sidebar-backdrop { display: none; }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 12px 26px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--border); }
.topbar-burger { display: none; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 24px 26px 40px; flex: 1; width: 100%; max-width: 1680px; margin: 0 auto; }
.content-plein { padding: 0; max-width: none; }
.app-footer a.signature, .login-foot a.signature { color: var(--primary); font-weight: 700; }
.app-footer { padding: 14px 26px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); text-align: center; }

/* Recherche globale / scan */
.global-search { position: relative; flex: 1; max-width: 560px; }
.global-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search input, .global-search input[type=search] { width: 100%; padding: 10px 44px 10px 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; box-shadow: var(--shadow-sm); }
.global-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.scan-indicator { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--success); font-size: 16px; }
.scan-indicator.flash { animation: scanflash .6s ease; }
@keyframes scanflash { 0% { color: var(--primary); transform: translateY(-50%) scale(1.5); } 100% { transform: translateY(-50%) scale(1); } }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; display: none; z-index: 50; }
.search-results.open { display: block; }
.search-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); cursor: pointer; }
.search-item:last-child { border-bottom: 0; }
.search-item:hover, .search-item.active { background: var(--primary-softer); text-decoration: none; }
.search-item .si-main { flex: 1; min-width: 0; }
.search-item .si-main strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item .si-main small { color: var(--muted); }
.search-item .si-side { text-align: right; font-size: 12.5px; white-space: nowrap; }
.search-empty { padding: 16px; color: var(--muted); text-align: center; }

/* Utilisateur, menus déroulants */
.user-chip { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; color: var(--text); font: inherit; box-shadow: var(--shadow-sm); }
.user-chip-text { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-chip-text strong { font-size: 13px; }
.user-chip-text small { font-size: 11px; color: var(--muted); }
.user-chip > i { font-size: 10px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-lg { width: 52px; height: 52px; }
.avatar-xl { width: 112px; height: 112px; font-size: 38px !important; }
.avatar-initiales { display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-weight: 700; font-size: 13px; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; animation: pop .14s ease; }
.dropdown-menu a, .dropdown-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-btn:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu i { width: 16px; text-align: center; color: var(--muted); }
.dropdown-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 12px; }
.dropdown-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.dropdown-user { display: flex; gap: 12px; align-items: center; padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-user small { display: block; color: var(--muted); }
.dropdown-alertes { min-width: 320px; }
.dot-count { position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--bg); }
.inline-form { display: inline; margin: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- En-tête de page ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-subtitle { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb i.fa-chevron-right { font-size: 9px; opacity: .6; }

/* ---------- Cartes & grilles ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.card-header h2 > i { color: var(--primary); width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); font-size: 14px; }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.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-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.spacer { flex: 1; }

/* ---------- Indicateurs ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--text); transition: transform .15s, box-shadow .15s; }
a.stat:hover { transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow-lg); }
.stat::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--c-soft, var(--primary-softer)); }
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; flex: none; color: #fff; background: linear-gradient(135deg, var(--c, var(--primary)), color-mix(in srgb, var(--c, var(--primary)) 60%, #fff)); box-shadow: 0 8px 18px -8px var(--c, var(--primary)); position: relative; z-index: 1; }
.stat-body { display: flex; flex-direction: column; min-width: 0; position: relative; z-index: 1; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat-primary { --c: var(--primary); --c-soft: var(--primary-softer); }
.stat-success { --c: var(--success); --c-soft: var(--success-soft); }
.stat-warning { --c: var(--warning); --c-soft: var(--warning-soft); }
.stat-danger  { --c: var(--danger);  --c-soft: var(--danger-soft); }
.stat-info    { --c: var(--info);    --c-soft: var(--info-soft); }
.stat-violet  { --c: var(--violet);  --c-soft: var(--violet-soft); }
.trend { font-weight: 700; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.trend.up { color: var(--success); background: var(--success-soft); }
.trend.down { color: var(--danger); background: var(--danger-soft); }
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 360px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { text-align: left; font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--primary-softer); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .actions .btn, .table .actions form { margin-left: 4px; }
.table tfoot td { font-weight: 800; background: var(--surface-2); border-top: 2px solid var(--border); border-bottom: 0; }
.table-compact td, .table-compact th { padding: 7px 10px; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { display: block; font-size: 12px; color: var(--muted); }
tr.row-danger td { background: var(--danger-soft); }
tr.row-warning td { background: var(--warning-soft); }
tr.row-muted td { opacity: .55; }
tr.row-success td { background: var(--success-soft); }
.thumb { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; background: var(--surface-3); display: inline-grid; place-items: center; color: var(--muted); flex: none; }

/* ---------- Filtres & formulaires ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 220px; }
.filters label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.s12 { grid-column: span 12; } .field.s9 { grid-column: span 9; } .field.s8 { grid-column: span 8; } .field.s6 { grid-column: span 6; }
.field.s4 { grid-column: span 4; } .field.s3 { grid-column: span 3; } .field.s2 { grid-column: span 2; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.req { color: var(--danger); margin-left: 2px; }
.hint { font-size: 12px; color: var(--muted); }
.form-section { grid-column: span 12; display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--primary); margin-top: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=tel], input[type=url], input[type=month], select, textarea, .input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[readonly], input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--text-2); }
input.num, .num-input { text-align: right; font-variant-numeric: tabular-nums; }
input[type=color] { width: 56px; height: 38px; padding: 3px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); }
.input-group { display: flex; }
.input-group > input, .input-group > select { 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-strong); border-left: 0; background: var(--surface-3); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted); font-weight: 600; white-space: nowrap; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon > input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }
.file-drop { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 16px; display: flex; gap: 14px; align-items: center; background: var(--surface-2); }
.file-drop img { max-height: 70px; max-width: 160px; border-radius: 8px; background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 / 14px 14px; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: all .15s; text-decoration: none !important; line-height: 1.3; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 92%, #fff), var(--primary)); border-color: var(--primary-600); color: #fff; box-shadow: 0 6px 16px -8px var(--primary); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: color-mix(in srgb, var(--success) 85%, #000); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.btn-soft-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-soft-danger:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; position: relative; box-shadow: var(--shadow-sm); }
.btn-icon:hover { color: var(--primary); border-color: var(--primary); }
.btn-icon.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }

/* ---------- Badges & divers ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-violet  { background: var(--violet-soft);  color: var(--violet); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-muted   { background: transparent; color: var(--muted); border: 1px dashed var(--border-strong); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; background: var(--surface-3); font-size: 12.5px; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 16px; border: 0; background: none; font: 600 13.5px var(--font); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: var(--surface-3); border-radius: 999px; padding: 0 7px; font-size: 11px; }
[data-tab-panel]:not(.active) { display: none; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a, .segmented button, .segmented label { padding: 6px 14px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; border: 0; background: none; cursor: pointer; }
.segmented .active, .segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.segmented a:hover { text-decoration: none; }
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-icon { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 22px; display: grid; place-items: center; font-size: 30px; background: var(--primary-soft); color: var(--primary); }
.empty-state h2 { color: var(--text); }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); margin-bottom: 16px; }
.callout > i { color: var(--info); font-size: 18px; margin-top: 1px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); } .callout.success > i { color: var(--success); }
.callout.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); } .callout.warning > i { color: var(--warning); }
.callout.danger  { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }  .callout.danger > i { color: var(--danger); }
.dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 500; }
.kv-total { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.kv-total.grand { font-size: 18px; font-weight: 800; border-bottom: 0; padding-top: 12px; color: var(--primary); }
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 50%, #22d3ee)); border-radius: 999px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 18px; }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline li.danger::before { border-color: var(--danger); } .timeline li.warning::before { border-color: var(--warning); } .timeline li.success::before { border-color: var(--success); }
.timeline time { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .strong { font-weight: 700; } .nowrap { white-space: nowrap; }
.danger-text { color: var(--danger) !important; } .success-text { color: var(--success) !important; } .warning-text { color: var(--warning) !important; } .primary-text { color: var(--primary) !important; }
.text-right { text-align: right; } .text-center { text-align: center; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; } .flex-wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.pagination { display: flex; gap: 4px; align-items: center; padding: 14px 20px; flex-wrap: wrap; }
.pagination a { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--border); color: var(--text-2); font-weight: 600; background: var(--surface); padding: 0 8px; }
.pagination a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-info { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lignes-table input, .lignes-table select { padding: 7px 9px; font-size: 13px; }
.lignes-table td { padding: 6px 8px; }
.scan-bar { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; background: linear-gradient(90deg, var(--primary-soft), transparent); border: 1px dashed color-mix(in srgb, var(--primary) 40%, transparent); margin-bottom: 14px; }
.scan-bar i { color: var(--primary); font-size: 22px; }
.scan-bar input { flex: 1; font-size: 15px; }
.kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; font-family: ui-monospace, monospace; background: var(--surface-2); }

/* ---------- Fenêtres modernes (GP.dialog) ---------- */
body.gp-modal-ouverte { overflow: hidden; }
.gp-modal-fond { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(8, 15, 25, .5); backdrop-filter: blur(5px); opacity: 0; transition: opacity .18s ease; }
.gp-modal-fond.visible { opacity: 1; }
.gp-modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 28px 26px 22px; text-align: center; transform: translateY(12px) scale(.96); transition: transform .22s cubic-bezier(.2,.9,.3,1.2); border: 1px solid var(--border); max-height: calc(100vh - 32px); overflow-y: auto; }
.gp-modal-fond.visible .gp-modal { transform: none; }
.gp-modal.large { max-width: 720px; text-align: left; }
.gp-modal.xl { max-width: 980px; text-align: left; }
.gp-modal-icone { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: var(--primary-soft); color: var(--primary); position: relative; }
.gp-modal-icone::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid currentColor; opacity: .15; }
.gp-modal-danger .gp-modal-icone { background: var(--danger-soft); color: var(--danger); }
.gp-modal-warning .gp-modal-icone, .gp-modal-logout .gp-modal-icone { background: var(--warning-soft); color: var(--warning); }
.gp-modal-success .gp-modal-icone { background: var(--success-soft); color: var(--success); }
.gp-modal-info .gp-modal-icone { background: var(--info-soft); color: var(--info); }
.gp-modal h2 { font-size: 19px; margin-bottom: 8px; }
.gp-modal-message { color: var(--text-2); margin-bottom: 4px; }
.gp-modal-champ { text-align: left; margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.gp-modal-champ label { font-weight: 600; font-size: 13px; }
.gp-modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }
.gp-modal-actions .btn { min-width: 120px; }
.gp-modal.large .gp-modal-actions, .gp-modal.xl .gp-modal-actions { justify-content: flex-end; }
.gp-modal-head { display: flex; align-items: center; gap: 12px; margin: -4px 0 18px; }
.gp-modal-head h2 { margin: 0; flex: 1; }
.gp-modal-close { background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; width: 34px; height: 34px; border-radius: 9px; }
.gp-modal-close:hover { background: var(--surface-3); color: var(--text); }
.gp-modal-fond.shake .gp-modal { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Toasts */
.gp-toasts { position: fixed; top: 18px; right: 18px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 36px)); pointer-events: none; }
.gp-toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toastin .3s cubic-bezier(.2,.9,.3,1.2); position: relative; overflow: hidden; }
.gp-toast.out { animation: toastout .25s forwards; }
.gp-toast > i { font-size: 18px; margin-top: 1px; }
.gp-toast .gp-toast-msg { flex: 1; font-weight: 500; }
.gp-toast button { background: none; border: 0; color: var(--muted); cursor: pointer; }
.gp-toast::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; background: currentColor; animation: toastbar var(--duree, 5s) linear forwards; opacity: .5; }
.gp-toast.success { color: var(--success); } .gp-toast.error { color: var(--danger); } .gp-toast.warning { color: var(--warning); } .gp-toast.info { color: var(--info); }
.gp-toast .gp-toast-msg { color: var(--text); }
@keyframes toastin { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(40px); } }
@keyframes toastbar { from { width: 100%; } to { width: 0; } }
.gp-loader { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; background: rgba(8,15,25,.35); backdrop-filter: blur(2px); }
.gp-loader > div { background: var(--surface); padding: 22px 28px; border-radius: 16px; box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; font-weight: 600; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Aperçu produit scanné (pop-up global) */
.scan-produit { display: flex; gap: 16px; align-items: flex-start; text-align: left; }
.scan-produit .thumb { width: 84px; height: 84px; font-size: 30px; }
.scan-produit h3 { font-size: 17px; margin: 0 0 4px; }

/* ---------- Page de connexion (carte centrée sur l'image de fond) ---------- */
.login-body { background: var(--bg); }
.login-scene { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 32px 16px;
  background: radial-gradient(900px 500px at 15% 10%, color-mix(in srgb, var(--primary) 35%, transparent), transparent 60%),
              radial-gradient(800px 500px at 90% 90%, color-mix(in srgb, #22d3ee 25%, transparent), transparent 60%),
              linear-gradient(135deg, #e8f3f1, #f4f7fa); background-size: cover; background-position: center; }
.login-scene.has-image { background-color: #0b1f24; }
.login-voile { position: absolute; inset: 0; background: rgba(240, 246, 248, .55); backdrop-filter: blur(1.5px); }
.login-scene:not(.has-image) .login-voile { display: none; }
.login-box { position: relative; z-index: 1; width: 100%; max-width: 460px; background: var(--surface); border-radius: 22px; padding: 38px 40px 26px;
  box-shadow: 0 30px 80px -20px rgba(8, 30, 40, .45); border: 1px solid var(--border); animation: pop .35s ease; }
.login-entete { text-align: center; margin-bottom: 18px; }
.login-logo-grand { display: block; margin: 0 auto 14px; max-height: 120px; max-width: 240px; object-fit: contain; }
.login-mark { width: 84px; height: 84px; font-size: 38px; border-radius: 22px; margin: 0 auto 14px; }
.login-entete h1 { font-size: 26px; font-weight: 800; letter-spacing: .01em; margin: 0 0 4px; color: var(--text); }
.login-entete p { color: var(--muted); margin: 0; }
.login-message { text-align: center; color: var(--text-2); font-size: 13.5px; margin: 0 0 18px; }
.login-box .field { margin-bottom: 16px; }
.login-box .input-icon > input { padding-top: 12px; padding-bottom: 12px; background: var(--surface-2); }
.login-rester { margin: 2px 0 20px; }
.pwd-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; }
.login-retour-site { display: block; text-align: center; margin-top: 16px; font-size: 13px; font-weight: 600; }
.login-foot { margin-top: 22px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
@media (max-width: 520px) { .login-box { padding: 28px 22px 20px; } .login-logo-grand { max-height: 96px; } }

/* ---------- Documents imprimables ---------- */
.doc { background: #fff; color: #111; max-width: 900px; margin: 0 auto; padding: 36px 40px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 3px solid var(--primary); padding-bottom: 18px; margin-bottom: 22px; }
.doc-head img { max-height: 70px; }
.doc-title { font-size: 22px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.doc th { background: #f1f5f9; color: #334155; text-align: left; padding: 8px 10px; font-size: 11.5px; text-transform: uppercase; border-bottom: 2px solid #cbd5e1; }
.doc td { padding: 7px 10px; border-bottom: 1px solid #e2e8f0; }
.doc .num { text-align: right; white-space: nowrap; }
.doc-totaux { margin-left: auto; width: 320px; }
.doc-foot { margin-top: 30px; padding-top: 12px; border-top: 1px solid #e2e8f0; font-size: 11px; color: #64748b; text-align: center; }
.ticket { width: 80mm; max-width: 100%; margin: 0 auto; background: #fff; color: #000; font: 12px/1.35 'Courier New', ui-monospace, monospace; padding: 4mm; }
.ticket .t-center { text-align: center; } .ticket .t-right { text-align: right; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.ticket table { width: 100%; border-collapse: collapse; }
.ticket td { padding: 1px 0; vertical-align: top; }
.ticket .t-big { font-size: 16px; font-weight: 700; }
.ticket img.t-logo { max-height: 50px; display: block; margin: 0 auto 4px; filter: grayscale(1); }
.print-only { display: none; }

@media print {
  @page { margin: 10mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .app-footer, .no-print, .page-actions, .toolbar, .filters, .gp-toasts, .pagination { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  .card, .doc { box-shadow: none !important; border: 0 !important; }
  .print-only { display: block; }
  .table th { position: static; }
  body.impression-ticket .content > *:not(.ticket) { display: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: 280px !important; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .main, body.sidebar-mini .main { margin-left: 0; }
  .topbar-burger { display: inline-grid; }
  .sidebar-pin { display: none; }
  .grid-3, .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .user-chip-text, .topbar-pos span { display: none; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .field, .field.s2, .field.s3, .field.s4, .field.s6, .field.s8, .field.s9 { grid-column: span 12; }
  .page-header { align-items: flex-start; }
  h1 { font-size: 20px; }
  .doc { padding: 18px; }
  .filters .f { min-width: 100%; }
}
