/* =====================================================================
   Koubia Gestion — feuille de style (thèmes clair / sombre, responsive)
   ===================================================================== */
:root {
  --primary: #0f766e; --primary-rgb: 15,118,110; --primary-dark: #0b5c56; --primary-soft: rgba(15,118,110,.12);
  --accent: #f59e0b; --accent-soft: rgba(245,158,11,.15);
  --bg: #f1f5f9; --surface: #ffffff; --surface-2: #f8fafc; --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
  --red: #dc2626; --red-soft: #fee2e2; --green: #16a34a; --green-soft: #dcfce7; --amber: #d97706; --amber-soft: #fef3c7; --blue: #2563eb; --blue-soft: #dbeafe;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.06); --shadow-lg: 0 20px 50px rgba(15,23,42,.18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --fs: 15px;
  --side: 256px; --top: 60px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2e; --surface-2: #0f1729; --text: #e2e8f0; --muted: #94a3b8; --border: #1e293b;
  --red-soft: rgba(220,38,38,.18); --green-soft: rgba(22,163,74,.18); --amber-soft: rgba(217,119,6,.2); --blue-soft: rgba(37,99,235,.2);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; -webkit-font-smoothing: antialiased; }
body.no-scroll { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: .4rem 0; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; font-size: .85em; }
kbd { font-size: .7rem; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--surface); font-family: inherit; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .pad { padding: 16px; }
.neg { color: var(--red); font-weight: 600; } .pos { color: var(--green); font-weight: 600; } .warn-txt { color: var(--amber); font-weight: 600; }
.nowrap { white-space: nowrap; } .right { text-align: right; }
.ic { flex-shrink: 0; vertical-align: middle; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------- Splash / chargement ---------- */
.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px; color: var(--muted); }
.splash h2 { color: var(--text); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); }
.loading .spinner { width: 20px; height: 20px; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger-ghost { color: var(--red); background: transparent; border-color: transparent; }
.btn-danger-ghost:hover { background: var(--red-soft); border-color: var(--red-soft); }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .84rem; }
.btn-lg { padding: 12px 20px; font-size: 1rem; min-height: 48px; }
.btn-xl { padding: 14px 20px; font-size: 1.08rem; min-height: 56px; }
.btn-block { width: 100%; }
.btn kbd { background: rgba(255,255,255,.2); color: inherit; border-color: rgba(255,255,255,.35); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; position: relative; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn.lg { width: 48px; height: 48px; border: 1px solid var(--border); background: var(--surface); }
.dot { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Mise en page ---------- */
.layout { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40; transition: transform .25s ease; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: var(--top); border-bottom: 1px solid var(--border); }
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; }
.brand strong { display: block; font-size: .95rem; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.brand small { color: var(--muted); font-size: .75rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem; flex-shrink: 0; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.nav-group { margin-top: 10px; }
.nav-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 6px 10px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--text); font-size: .9rem; font-weight: 500; }
.nav-link .ic { color: var(--muted); }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-link.active .ic { color: var(--primary); }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; }
.sidebar-foot span { font-weight: 700; color: var(--text); }
.sidebar-backdrop { display: none; }
.main { margin-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.searchbar { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; text-align: left; }
.searchbar span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .88rem; }
.top-ctx { display: flex; gap: 8px; margin-left: auto; }
.ctx-select { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); }
.ctx-select select { border: 0; background: transparent; color: var(--text); font-weight: 600; font-size: .86rem; max-width: 150px; outline: none; cursor: pointer; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font-size: .78rem; font-weight: 650; cursor: pointer; }
.sync-pill.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, var(--border)); }
.sync-pill.pending { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); background: var(--amber-soft); }
.sync-pill.busy { color: var(--blue); }
.sync-pill.off { color: var(--red); background: var(--red-soft); border-color: transparent; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-weight: 700; font-size: .82rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.sm { width: 32px; height: 32px; font-size: .75rem; cursor: default; }
.content { padding: 22px 24px 40px; flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; }
.banner { display: flex; align-items: center; gap: 8px; padding: 8px 24px; font-size: .86rem; font-weight: 500; }
.banner a { font-weight: 700; text-decoration: underline; }
.banner-offline { background: #1e293b; color: #f8fafc; }
.banner-trial { background: var(--accent-soft); color: var(--text); }
.banner-warn { background: var(--amber-soft); color: var(--text); }
.bottomnav { display: none; }
.only-sm { display: none !important; }

/* ---------- En-têtes, cartes, onglets ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head .card-title { margin: 0; }
.danger-card { border-color: var(--red); background: var(--red-soft); }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card, .grid-2 > div > .card { margin-bottom: 16px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 14px 0 8px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .92rem; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv strong { text-align: right; }
.pre { background: var(--surface-2); border: 1px solid var(--border); padding: 10px; border-radius: 8px; overflow: auto; font-size: .8rem; max-height: 260px; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 3px; color: var(--text); position: relative; min-width: 0; }
.kpi small { color: var(--muted); font-weight: 600; font-size: .8rem; }
.kpi strong { font-size: 1.25rem; font-weight: 750; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi.big { padding: 16px 18px; }
.kpi.big strong { font-size: 1.4rem; }
.kpi.warn { border-left: 3px solid var(--amber); } .kpi.danger { border-left: 3px solid var(--red); } .kpi.ok { border-left: 3px solid var(--green); }
.kpi-ic { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.kpi-ic.acc { background: var(--accent-soft); color: var(--accent); } .kpi-ic.red { background: var(--red-soft); color: var(--red); } .kpi-ic.amb { background: var(--amber-soft); color: var(--amber); }
.trend { font-size: .78rem; font-weight: 700; } .trend.up { color: var(--green); } .trend.down { color: var(--red); }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-grid .card { margin: 0; }
.span-2 { grid-column: span 2; }
.chart-box { position: relative; height: 290px; } .chart-box.sm { height: 240px; }
.bar-row { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; margin-bottom: 4px; }
.bar-label span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label small { color: var(--muted); white-space: nowrap; }
.bar { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: .9rem; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { color: var(--primary); }

/* ---------- Tableaux ---------- */
.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.tools-right { display: flex; gap: 6px; align-items: center; }
.search-in { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--muted); flex: 1; min-width: 200px; max-width: 420px; }
.search-in input { border: 0; outline: none; background: transparent; flex: 1; height: 100%; min-width: 0; color: var(--text); }
.search-in.big { height: 48px; max-width: none; font-size: 1rem; background: var(--surface); }
.search-in:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; background: var(--surface-2); }
.table th.right, .table td.right { text-align: right; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table tfoot td { background: var(--surface-2); font-weight: 600; }
.table td.actions { white-space: nowrap; width: 1%; }
.table .strong-row td { font-weight: 700; background: var(--surface-2); }
.empty-cell { text-align: center; color: var(--muted); padding: 30px 10px !important; }
.table-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: .85rem; }
.pager { display: flex; align-items: center; gap: 8px; }
.prod-cell { display: flex; align-items: center; gap: 10px; }
.prod-cell img, .pinit { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.pinit { background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: middle; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); } .badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); } .badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); } .badge-teal { background: var(--primary-soft); color: var(--primary); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px 16px; }
.filters .field { margin: 0; flex: 1 1 160px; max-width: 240px; }
.filters .btns { display: flex; flex-direction: row; gap: 6px; flex: 0 0 auto; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state h3 { color: var(--text); }
.empty-state .ic { color: var(--primary); opacity: .6; }

/* ---------- Formulaires ---------- */
.form-grid { display: flex; flex-wrap: wrap; gap: 0 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; flex: 1 1 100%; min-width: 0; }
.field.half { flex: 1 1 calc(50% - 14px); min-width: 180px; }
.field.third { flex: 1 1 calc(33% - 14px); min-width: 140px; }
.field > span { font-size: .82rem; font-weight: 650; color: var(--text); }
.field.check { flex-direction: row; align-items: center; gap: 9px; cursor: pointer; }
.field.check > span { font-weight: 500; font-size: .9rem; }
.field input:not([type=checkbox]):not([type=color]):not([type=file]), .field select, .field textarea, .in-select, .in-sm-select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); min-height: 42px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus, .in-sm:focus, .in-md:focus, .in-price:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input[readonly] { background: var(--surface-2); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.help { color: var(--muted); font-size: .76rem; }
.req { color: var(--red); }
.form-section { flex: 1 1 100%; margin: 10px 0 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); }
.form-error { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: .88rem; font-weight: 600; margin: 6px 0; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.checklist { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 0; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: .9rem; cursor: pointer; padding: 3px 0; }
.color-in { display: flex; align-items: center; gap: 10px; }
.color-in input { width: 48px; height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); cursor: pointer; }
.img-in { display: flex; align-items: center; gap: 12px; }
.img-prev { width: 72px; height: 72px; border: 1px dashed var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; background: var(--surface-2); flex-shrink: 0; }
.img-prev img { width: 100%; height: 100%; object-fit: contain; }
.img-in input[type=file] { font-size: .8rem; max-width: 210px; }
.pw { display: flex; align-items: center; position: relative; }
.pw input { padding-right: 42px !important; }
.pw .icon-btn { position: absolute; right: 3px; }
.in-sm, .in-md, .in-price { padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); outline: none; text-align: right; }
.in-sm { width: 76px; } .in-md { width: 120px; } .in-price { width: 110px; padding: 3px 6px; font-size: .86rem; }
.in-select { width: auto; min-height: 36px; padding: 6px 10px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 650; color: var(--muted); cursor: pointer; font-size: .9rem; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg.sm button { padding: 5px 10px; font-size: .82rem; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: thin; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 13px; border-radius: 20px; font-size: .84rem; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--text); }
.chip small { color: var(--muted); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.on small { color: rgba(255,255,255,.8); }

/* ---------- Modales & toasts ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .18s; }
.modal-wrap.show { opacity: 1; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; transform: translateY(10px) scale(.98); transition: transform .18s; }
.modal-wrap.show .modal { transform: none; }
.modal-sm { max-width: 420px; } .modal-md { max-width: 600px; } .modal-lg { max-width: 920px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h3 { font-size: 1.08rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg); border-left: 4px solid var(--blue); font-size: .9rem; font-weight: 500; transform: translateX(120%); transition: transform .25s; cursor: pointer; }
.toast.show { transform: none; }
.toast-success { border-left-color: var(--green); } .toast-success .ic { color: var(--green); }
.toast-error { border-left-color: var(--red); } .toast-error .ic { color: var(--red); }
.toast-warning { border-left-color: var(--amber); } .toast-warning .ic { color: var(--amber); }
.toast-info .ic { color: var(--blue); }
.menu-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; border: 0; background: transparent; text-align: left; color: var(--text); font-weight: 550; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--red); }

/* ---------- Recherche (palette) ---------- */
.palette-list { max-height: 55vh; overflow-y: auto; margin: 12px 0 6px; display: flex; flex-direction: column; gap: 2px; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.pal-item span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pal-item small { color: var(--muted); font-size: .8rem; }
.pal-item em { font-style: normal; font-size: .72rem; color: var(--muted); border: 1px solid var(--border); padding: 1px 7px; border-radius: 10px; }
.pal-item.sel, .pal-item:hover { background: var(--primary-soft); }
.pal-item .ic { color: var(--primary); }
.pick-list { max-height: 55vh; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.pick-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; text-align: left; cursor: pointer; width: 100%; color: var(--text); }
.pick-item:hover { background: var(--surface-2); }
.pick-item span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pick-item small { color: var(--muted); }
.pick-item em { font-style: normal; font-weight: 700; font-size: .86rem; }
.pick-item img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }

/* ---------- Notifications ---------- */
.notif-list { display: flex; flex-direction: column; gap: 6px; }
.notif { display: flex; gap: 12px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); color: var(--text); align-items: flex-start; }
.notif p { margin: 2px 0; color: var(--muted); font-size: .88rem; }
.notif small { color: var(--muted); font-size: .76rem; }
.notif.unread { background: var(--surface-2); border-left: 3px solid var(--primary); }
.notif.lvl-red .ic { color: var(--red); } .notif.lvl-amber .ic { color: var(--amber); } .notif.lvl-blue .ic { color: var(--blue); }

/* ---------- Point de vente ---------- */
body.pos-mode .content { max-width: none; padding: 14px; }
.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) 410px; gap: 14px; height: calc(100vh - var(--top) - 28px); }
.pos-products { display: flex; flex-direction: column; min-height: 0; }
.pos-search { display: flex; gap: 8px; margin-bottom: 10px; }
.pgrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; align-content: start; padding: 2px 2px 20px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer; transition: border-color .12s, transform .08s, box-shadow .12s; color: var(--text); min-width: 0; }
.pcard:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.pcard:active { transform: scale(.97); }
.pcard.out { opacity: .55; }
.pimg { aspect-ratio: 4/3; border-radius: 8px; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 4px; }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pimg span { font-weight: 800; color: var(--primary); font-size: 1.3rem; opacity: .7; }
.pcard strong { font-size: .86rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.1em; }
.pprice { font-weight: 800; color: var(--primary); font-size: .92rem; }
.pstock { font-size: .74rem; color: var(--muted); }
.pstock.low { color: var(--red); font-weight: 700; }
.pos-cart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; box-shadow: var(--shadow); }
.cart-head { display: flex; align-items: center; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); }
.cust-btn { flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: left; min-width: 0; color: var(--text); width: 100%; }
.cust-btn span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cust-btn strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.cust-btn small { color: var(--muted); font-size: .76rem; }
.cart-tools { display: flex; }
.cart-opts { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.in-sm-select { width: auto; min-height: 34px; padding: 4px 8px; font-weight: 700; }
.cart-lines { flex: 1; overflow-y: auto; padding: 4px 10px; }
.cart-empty { text-align: center; color: var(--muted); padding: 40px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cart-empty .ic { opacity: .4; }
.cline { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main total" "qty actions"; gap: 4px 8px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: center; }
.cl-main { grid-area: main; min-width: 0; }
.cl-main strong { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-price { font-size: .82rem; color: var(--muted); }
.cl-price em { color: var(--red); font-style: normal; }
.cl-total { grid-area: total; font-weight: 750; text-align: right; white-space: nowrap; }
.cl-actions { grid-area: actions; display: flex; justify-content: flex-end; }
.cl-actions .icon-btn { width: 30px; height: 30px; }
.qty { grid-area: qty; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; width: max-content; }
.qty button { width: 34px; height: 32px; border: 0; background: var(--surface-2); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text); }
.qty input { width: 56px; height: 32px; border: 0; text-align: center; background: var(--surface); outline: none; font-weight: 700; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cart-foot { padding: 10px 12px 12px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.tot-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: .9rem; }
.tot-row.grand { font-size: 1.35rem; font-weight: 800; padding: 6px 0 10px; }
.cart-fab { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 35; background: var(--primary); color: #fff; border: 0; border-radius: 30px; padding: 13px 22px; font-size: 1rem; box-shadow: var(--shadow-lg); display: flex; gap: 8px; align-items: center; cursor: pointer; }
.cart-fab[hidden] { display: none !important; }
.pay-total { text-align: center; padding: 10px 0 16px; }
.pay-total small { color: var(--muted); display: block; }
.pay-total strong { font-size: 2rem; font-weight: 800; color: var(--primary); }
.pay-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pay-row select, .pay-row input { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-height: 46px; }
.pay-row select { flex: 1 1 150px; }
.pay-row input[data-f=amount] { flex: 1 1 140px; font-size: 1.15rem; font-weight: 700; text-align: right; }
.pay-row input[data-f=ref] { flex: 1 1 100%; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.pay-summary > div { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 10px; margin: 10px 0; font-size: 1rem; }
.change { background: var(--green-soft); color: var(--green); } .due { background: var(--amber-soft); color: var(--amber); } .okpay { background: var(--primary-soft); color: var(--primary); }
.totals-box { margin-top: 12px; margin-left: auto; max-width: 380px; display: flex; flex-direction: column; gap: 4px; }
.totals-box > div { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; padding: 3px 0; }
.totals-box .grand { font-size: 1.2rem; font-weight: 800; border-top: 2px solid var(--border); padding-top: 8px; margin-top: 4px; }
.doc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.doc-editor h4 { margin: 0; }
.table.lines td { padding: 6px 8px; }
.denoms { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.denoms label { display: flex; flex-direction: column; gap: 3px; font-size: .8rem; font-weight: 600; }
.denoms input { padding: 7px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }

/* ---------- Boutiques, rôles, paramètres ---------- */
.shop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.shop-card { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--sc); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.shop-card.inactive { opacity: .6; }
.shop-top { display: flex; align-items: center; gap: 12px; }
.shop-top img { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); }
.shop-top .brand-mark { background: var(--sc); width: 48px; height: 48px; }
.shop-top small { color: var(--muted); }
.shop-info { flex: 1; }
.shop-foot { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0; display: flex; flex-direction: column; }
.perm-group legend { font-weight: 700; padding: 0 6px; }
.perm-group legend label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; flex: 1 1 100%; }
.preset { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--text); }
.preset i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
.preset span { margin-left: 4px; }
.cf-block { padding: 6px 0 12px; border-bottom: 1px solid var(--border); }
.setup { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, var(--primary-soft), var(--bg) 60%); }
.setup-card { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 28px; width: 100%; max-width: 620px; }
.setup-card.wide { max-width: 940px; }
.setup-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.setup-head > .ic { color: var(--primary); }
.lock-page .setup-head > .ic { color: var(--red); }
.vendor-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.vendor-card h3 { display: flex; align-items: center; gap: 8px; }
.lic-status { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 12px; margin-bottom: 12px; }
.lic-status div { display: flex; flex-direction: column; }
.lic-status strong { font-size: 1.3rem; }
.lic-status small, .lic-status span { font-size: .84rem; opacity: .85; }
.lic-status.ok { background: var(--green-soft); color: var(--green); } .lic-status.warn { background: var(--amber-soft); color: var(--amber); } .lic-status.bad { background: var(--red-soft); color: var(--red); }
.install-box { text-align: center; } .install-box > .ic { color: var(--primary); margin-bottom: 6px; }
.steps { text-align: left; } .ok-box { background: var(--green-soft); color: var(--green); padding: 8px; border-radius: 8px; }

/* ---------- Verrouillage ---------- */
.lock-screen { position: fixed; inset: 0; z-index: 300; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(14px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lock-card { background: var(--surface); padding: 28px; border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.lock-card input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 1rem; text-align: center; }
.lock-card .ic { color: var(--primary); }

/* ---------- Authentification ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero { background: linear-gradient(150deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; gap: 22px; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.07); right: -140px; bottom: -140px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { border-radius: 12px; background: #fff; }
.auth-brand strong { font-size: 1.2rem; display: block; }
.auth-brand small { opacity: .8; }
.auth-hero h1 { font-size: 2.2rem; line-height: 1.15; max-width: 460px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-points li { display: flex; gap: 10px; align-items: center; font-size: 1rem; }
.auth-points .ic { background: rgba(255,255,255,.15); border-radius: 8px; padding: 6px; width: 32px; height: 32px; }
.auth-vendor { opacity: .85; font-size: .9rem; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 520px; }
.auth-card .seg { width: 100%; margin-bottom: 20px; }
.auth-card .seg button { flex: 1; padding: 10px; }
.auth-card h2 { margin-bottom: 6px; }
.auth-card .kb-form > .field { margin-top: 12px; }
.auth-card .btn-lg { margin-top: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --top: 56px; }
  .only-sm { display: inline-flex !important; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 39; }
  .main { margin-left: 0; }
  .topbar { padding: 0 10px; gap: 6px; }
  .searchbar { max-width: none; }
  .searchbar span, .searchbar kbd { display: none; }
  .searchbar { flex: 0 0 40px; justify-content: center; padding: 0; }
  .top-ctx { flex: 1; min-width: 0; gap: 6px; }
  .ctx-select { padding: 0 8px; min-width: 0; flex: 1; }
  .ctx-select select { max-width: none; width: 100%; font-size: .8rem; }
  .ctx-select .ic { display: none; }
  .sync-pill span { display: none; }
  .sync-pill { padding: 0 9px; }
  .content { padding: 14px 12px 96px; }
  .banner { padding: 7px 12px; font-size: .8rem; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 35; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottomnav a, .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: .68rem; font-weight: 600; color: var(--muted); border: 0; background: transparent; cursor: pointer; }
  .bottomnav a.active { color: var(--primary); }
  .grid-2, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  h1 { font-size: 1.3rem; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi.big strong { font-size: 1.1rem; }
  .kpi-ic { display: none; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hide-sm { display: none; }
  .filters .field { max-width: none; flex: 1 1 calc(50% - 12px); }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { max-width: none !important; border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal-foot .btn { flex: 1 1 auto; }
  .field.half, .field.third { flex: 1 1 100%; }
  .table { font-size: .86rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 22px; gap: 14px; }
  .auth-hero h1 { font-size: 1.5rem; }
  .auth-points { display: none; }
  body.pos-mode .content { padding: 10px 10px 140px; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); overflow: visible; }
  .pos-cart { position: fixed; inset: 0; z-index: 60; border-radius: 0; transform: translateY(100%); transition: transform .25s ease; }
  body.cart-open .pos-cart { transform: none; }
  .cart-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  #toasts { top: auto; bottom: 80px; left: 16px; right: 16px; max-width: none; }
  .toast { transform: translateY(150%); }
  .doc-actions { grid-template-columns: 1fr; }
}
@media (min-width: 901px) { .cart-fab { display: none !important; } }
@media print { .sidebar, .topbar, .bottomnav, #banner { display: none !important; } .main { margin: 0; } }

/* ---------- Accès admin & copyright ---------- */
.admin-link { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; padding: 10px; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.admin-link:hover { color: var(--primary); border-color: var(--primary); }
.copyright { margin-top: 18px; text-align: center; font-size: .76rem; color: var(--muted); line-height: 1.7; }
.copyright a { color: var(--muted); text-decoration: underline; }
.sidebar-foot a { color: var(--muted); }
