/* =====================================================================
   SYLI-GESTION - thème principal (rose foncé / blanc)
   Aucune dépendance externe : fonctionne sans connexion Internet.
   ===================================================================== */
:root {
  --primary: #c33b80;
  --primary-dark: #9c2c64;
  --primary-darker: #6b1e45;
  --primary-light: #fbe9f2;
  --primary-soft: #ecb6d1;
  --white: #ffffff;
  --bg: #f6f4f7;
  --surface: #ffffff;
  --border: #ebe4ea;
  --text: #2a1f27;
  --muted: #7a6d76;
  --success: #1e8e5a;
  --success-bg: #e3f6ec;
  --warning: #b26a00;
  --warning-bg: #fff3dc;
  --danger: #c62828;
  --danger-bg: #fde8e8;
  --info: #1565c0;
  --info-bg: #e5effc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(107, 30, 69, .06), 0 4px 16px rgba(107, 30, 69, .06);
  --sidebar-w: 256px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* ---------- Barre de défilement personnalisée (toutes les pages et zones défilantes) ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--primary-soft) transparent; }  /* Firefox */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-soft); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: var(--primary-dark); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
/* Variante claire sur le menu latéral rose foncé */
.sidebar { scrollbar-color: rgba(255, 255, 255, .35) transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .3); background-clip: padding-box; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .55); background-clip: padding-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; color: var(--text); }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.icon { display: inline-block; vertical-align: -3px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "Courier New", monospace; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .mb0 { margin-bottom: 0; }
.flex { display: flex; gap: .75rem; 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; }
.hidden { display: none !important; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0; z-index: 30;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
  color: var(--white); display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.2rem 1.25rem 1rem; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px; background: var(--white); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 18px; letter-spacing: -1px;
}
a.brand { color: var(--white); flex-direction: column; align-items: flex-start; gap: .35rem; }
a.brand:hover { color: var(--white); }
.brand-img { display: block; width: 200px; max-width: 100%; height: auto; }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; opacity: .75; }
.nav { padding: .25rem .75rem 1.5rem; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; opacity: .6; padding: 1rem .6rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .88); font-weight: 500; margin-bottom: 2px; transition: background .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .1); color: var(--white); }
.nav a.active { background: var(--white); color: var(--primary-dark); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.nav a .pill { margin-left: auto; background: var(--primary-soft); color: var(--primary-darker); border-radius: 20px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.nav a.cta { background: var(--white); color: var(--primary); font-weight: 700; justify-content: center; margin: .5rem 0; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.branch-switch select { min-width: 220px; }
.branch-chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--primary-light); color: var(--primary-dark); padding: .35rem .8rem; border-radius: 30px; font-weight: 600; font-size: 13px; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--white); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.avatar { flex-shrink: 0; position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: var(--white); }
.user-name { font-weight: 600; line-height: 1.15; display: block; }
.user-role { font-size: 11.5px; color: var(--muted); display: block; }

/* Menu déroulant utilisateur */
.dropdown { position: relative; }
.user-trigger { display: flex; align-items: center; gap: .65rem; background: none; border: 1px solid transparent; border-radius: 12px; padding: .3rem .55rem .3rem .35rem; cursor: pointer; font: inherit; color: inherit; text-align: left; transition: background .15s, border-color .15s; }
.user-trigger:hover, .dropdown.open .user-trigger { background: var(--primary-light); border-color: var(--primary-soft); }
.user-chevron { color: var(--muted); transition: transform .2s; }
.dropdown.open .user-chevron { transform: rotate(180deg); }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 270px; background: var(--white); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(107, 30, 69, .16); padding: .5rem; z-index: 60; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .15s, transform .15s, visibility .15s; }
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-header { display: flex; align-items: center; gap: .7rem; padding: .6rem .6rem .7rem; }
.dropdown-header .avatar { width: 42px; height: 42px; font-size: 14px; }
.dropdown-info { display: flex; align-items: center; gap: .7rem; margin: 0 .3rem; padding: .6rem .7rem; background: #fbf8fa; border: 1px solid var(--border); border-radius: 10px; }
.dropdown-info .icon { color: var(--primary); }
.dropdown-sep { height: 1px; background: var(--border); margin: .5rem .2rem; }
.dropdown-item { display: flex; align-items: center; gap: .65rem; padding: .6rem .7rem; border-radius: 9px; color: var(--text); font-weight: 600; }
.dropdown-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.dropdown-item .icon { color: var(--primary); }

/* Bouton de déconnexion (power rouge) */
.btn-power { width: 38px; height: 38px; border-radius: 50%; border: 1px solid #f5c3c3; background: var(--danger-bg); color: var(--danger); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s, transform .1s; }
.btn-power:hover { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-power:active { transform: scale(.94); }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: .1rem 0 0; color: var(--muted); }

/* ---------- Cards / KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; gap: .5rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 1rem 1.25rem 0; }
.grid { display: grid; gap: 1.25rem; }
.grid > * { min-width: 0; }
.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-2-1 { grid-template-columns: 2fr 1fr; }
.kpi { position: relative; overflow: hidden; margin-bottom: 0; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 1.6rem; font-weight: 750; margin-top: .3rem; color: var(--text); white-space: nowrap; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: .2rem; }
.kpi .kpi-icon { position: absolute; right: 1rem; top: 1rem; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-light); color: var(--primary); }
.kpi.primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); border: none; }
.kpi.primary .label, .kpi.primary .sub { color: rgba(255, 255, 255, .8); }
.kpi.primary .value { color: var(--white); }
.kpi.primary .kpi-icon { background: rgba(255, 255, 255, .18); color: var(--white); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 650; padding: .7rem 1rem; background: #fbf8fa; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #fdf7fa; }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot td { font-weight: 700; background: #fbf8fa; padding: .7rem 1rem; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table.compact td, .table.compact th { padding: .45rem .7rem; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem !important; }
.empty-ok { display: inline-flex; align-items: center; gap: .45rem; color: var(--success); font-weight: 600; }
.greeting { display: flex; align-items: center; gap: .55rem; }
.greeting .icon { color: var(--primary); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .18rem .6rem; border-radius: 20px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #efebee; color: var(--muted); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .58rem 1.05rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; line-height: 1.2;
  background: var(--white); color: var(--text); border-color: var(--border);
}
.btn:hover { border-color: var(--primary-soft); color: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: var(--white); border-color: var(--success); }
.btn-success:hover { filter: brightness(.95); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-danger:hover { filter: brightness(.95); color: var(--white); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-light); color: var(--primary-dark); border-color: transparent; }
.btn-sm { padding: .35rem .65rem; font-size: 12.5px; }
.btn-lg { padding: .85rem 1.4rem; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { font-weight: 600; font-size: 13px; display: block; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: .58rem .8rem; border: 1px solid #ddd2da; border-radius: var(--radius-sm); font: inherit; background: var(--white);
  color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(195, 59, 128, .13); }
input:disabled, select:disabled { background: #f6f2f5; color: var(--muted); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); vertical-align: -3px; margin-right: .35rem; }
/* Champ mot de passe avec bouton « œil » */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 2.7rem !important; }
.pw-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: none; background: transparent; color: var(--muted); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.pw-toggle:hover { color: var(--primary); background: var(--primary-light); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { margin-bottom: .2rem; }
.field.checkbox label { display: flex; align-items: center; font-weight: 500; cursor: pointer; }
.help { font-size: 12px; color: var(--muted); margin-top: .25rem; }
.errorlist { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--danger); font-size: 12.5px; font-weight: 600; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters > * { flex: 0 1 auto; }
.filters input[type=search], .filters input[type=text] { min-width: 240px; }
.filters select, .filters input[type=date] { width: auto; }

/* ---------- Alerts ---------- */
.messages { margin-bottom: 1rem; }
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: .6rem; display: flex; gap: .6rem; align-items: flex-start; border: 1px solid transparent; font-weight: 500; }
.alert-success { background: var(--success-bg); color: #145c3b; border-color: #bfe8d2; }
.alert-danger { background: var(--danger-bg); color: #8e1c1c; border-color: #f5c3c3; }
.alert-warning { background: var(--warning-bg); color: #7a4a00; border-color: #f7dca5; }
.alert-info { background: var(--info-bg); color: #0d4687; border-color: #c4daf6; }
.alert .close { margin-left: auto; cursor: pointer; opacity: .6; background: none; border: none; font-size: 18px; line-height: 1; color: inherit; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .3rem; justify-content: center; align-items: center; padding: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .35rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--white); font-weight: 600; font-size: 13px; }
.pagination .current { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ---------- Bar chart (CSS) ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; min-width: 0; }
.bar { width: 100%; max-width: 42px; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-soft) 100%); border-radius: 6px 6px 2px 2px; min-height: 3px; position: relative; transition: opacity .15s; }
.bar:hover { opacity: .85; }
.bar-label { font-size: 10.5px; color: var(--muted); margin-top: 5px; white-space: nowrap; }
.hbar { height: 8px; background: var(--primary-light); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.hbar > span { display: block; height: 100%; background: var(--primary); border-radius: 8px; }

/* ---------- Product picker ---------- */
.picker { position: relative; }
.picker-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 50; max-height: 320px; overflow-y: auto; margin-top: 4px; }
.picker-item { padding: .55rem .8rem; cursor: pointer; display: flex; justify-content: space-between; gap: .75rem; border-bottom: 1px solid var(--border); }
.picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item.active { background: var(--primary-light); }
.picker-selected { margin-top: .5rem; padding: .6rem .8rem; background: var(--primary-light); border-radius: var(--radius-sm); color: var(--primary-darker); font-weight: 600; display: flex; justify-content: space-between; gap: .5rem; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(140deg, var(--primary) 0%, var(--primary-dark) 55%, var(--primary-darker) 100%); color: var(--white); padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: rgba(255, 255, 255, .06); right: -160px; bottom: -160px; }
.auth-hero h1 { color: var(--white); font-size: 2.3rem; line-height: 1.15; margin-bottom: 1rem; }
.auth-hero p { opacity: .85; font-size: 1.05rem; max-width: 460px; }
.auth-hero ul { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-hero li { margin: .7rem 0; display: flex; gap: .6rem; align-items: center; opacity: .92; }
.auth-form-wrap { display: grid; place-items: center; padding: 2rem; background: var(--white); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 1.5rem; }
.auth-card .field { margin-bottom: 1rem; }

/* ---------- Connexion (page simple centrée) ---------- */
.login-body { background: var(--white); min-height: 100vh; display: flex; flex-direction: column; }
.login-page { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 2.5rem 1rem 2rem; }
.login-logo { margin-bottom: 1.6rem; font-weight: 800; font-size: 1.6rem; color: var(--primary-dark); letter-spacing: .5px; }
.login-logo img { display: block; width: 360px; max-width: calc(100vw - 3rem); height: auto; }
.login-card { width: 100%; max-width: 350px; border: 1px solid #ddd; border-radius: 8px; padding: 1.5rem 1.6rem 1.3rem; box-shadow: 0 1px 6px rgba(0, 0, 0, .08); }
.login-card h1 { font-size: 1.75rem; font-weight: 600; margin-bottom: 1.1rem; }
.login-card .field { margin-bottom: .9rem; }
.login-card label { font-weight: 700; font-size: 13px; margin-bottom: .25rem; }
.login-card input[type=text], .login-card input[type=password] { padding: .5rem .7rem; border-color: #a6a6a6; border-radius: 4px; }
.login-submit { margin-top: .3rem; padding: .62rem; border-radius: 8px; font-size: 14.5px; }
.login-help { margin-top: 1.1rem; font-size: 13px; }
.login-help summary { cursor: pointer; color: var(--primary); list-style: none; display: inline-flex; align-items: center; gap: .3rem; }
.login-help summary::-webkit-details-marker { display: none; }
.login-help p { margin: .5rem 0 0; color: var(--muted); }
.login-company { margin-top: 1.6rem; color: var(--muted); font-size: 13px; }
.login-footer { border-top: 1px solid var(--border); background: linear-gradient(180deg, #fbf8fa, var(--white)); padding: 1rem; display: flex; justify-content: center; gap: 1.4rem; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* ---------- POS terminal ---------- */
.pos-body { background: var(--bg); height: 100vh; overflow: hidden; }
.pos { display: grid; grid-template-columns: 1fr 400px; grid-template-rows: 58px 1fr; height: 100vh; }
.pos-top { grid-column: 1 / -1; background: linear-gradient(90deg, var(--primary-dark), var(--primary)); color: var(--white); display: flex; align-items: center; gap: 1rem; padding: 0 1.1rem; }
.pos-top .brand-logo { width: 34px; height: 34px; font-size: 15px; }
.pos-top .info { display: flex; gap: 1.4rem; font-size: 13px; opacity: .95; flex-wrap: wrap; }
.pos-top .info b { font-weight: 700; }
.pos-top .actions { margin-left: auto; display: flex; gap: .5rem; }
.pos-top .btn { background: rgba(255, 255, 255, .14); color: var(--white); border-color: rgba(255, 255, 255, .25); }
.pos-top .btn:hover { background: rgba(255, 255, 255, .26); color: var(--white); }
.pos-left { display: flex; flex-direction: column; min-height: 0; padding: 1rem; gap: .8rem; }
.scan-box { display: flex; gap: .6rem; background: var(--white); padding: .7rem; border-radius: var(--radius); border: 2px solid var(--primary); box-shadow: var(--shadow); position: relative; }
.scan-box input { border: none; font-size: 1.25rem; padding: .5rem .6rem; box-shadow: none !important; }
.scan-box .qty-prefix { background: var(--primary-light); color: var(--primary-dark); border-radius: var(--radius-sm); padding: 0 .9rem; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; min-width: 64px; }
.cart { flex: 1; background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); overflow-y: auto; box-shadow: var(--shadow); min-height: 0; }
.cart table { width: 100%; border-collapse: collapse; }
.cart th { position: sticky; top: 0; background: #fbf8fa; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: .65rem .8rem; border-bottom: 1px solid var(--border); z-index: 1; }
.cart td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); font-size: 15px; }
.cart tr.selected td { background: var(--primary-light); }
.cart tr.flash td { animation: flash .6s; }
@keyframes flash { from { background: #ffd6e6; } to { background: transparent; } }
.cart .name { font-weight: 600; }
.cart .code { font-size: 11.5px; color: var(--muted); }
.qty-ctrl { display: inline-flex; align-items: center; gap: .3rem; }
.qty-ctrl button { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border); background: var(--white); cursor: pointer; font-weight: 800; color: var(--primary); }
.qty-ctrl button:hover { background: var(--primary-light); }
.qty-ctrl .q { min-width: 46px; text-align: center; font-weight: 700; }
.cart-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 2rem; }
.cart-empty .big { font-size: 1.15rem; font-weight: 600; color: var(--text); margin-top: .75rem; }
.shortcuts { display: flex; gap: .5rem; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.kbd { display: inline-block; background: var(--white); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 .4rem; font-weight: 700; color: var(--text); font-family: Consolas, monospace; font-size: 11.5px; }
.pos-right { background: var(--white); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.total-panel { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-darker) 100%); color: var(--white); padding: 1.3rem 1.4rem; }
.total-panel .lbl { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
.total-panel .amount { font-size: 2.6rem; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; margin-top: .2rem; word-break: break-all; }
.total-panel .meta { display: flex; justify-content: space-between; margin-top: .6rem; font-size: 13px; opacity: .85; }
.last-scan { padding: 1rem 1.4rem; border-bottom: 1px solid var(--border); min-height: 86px; }
.last-scan .n { font-weight: 700; font-size: 1.05rem; }
.last-scan .p { color: var(--primary); font-weight: 800; font-size: 1.4rem; }
.pos-actions { padding: 1rem 1.4rem; display: grid; gap: .6rem; }
.pos-actions .btn-pay { font-size: 1.25rem; padding: 1.05rem; }
.recent { flex: 1; overflow-y: auto; padding: 0 1.4rem 1rem; min-height: 0; }
.recent h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: .5rem 0; }
.recent a { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px dashed var(--border); color: var(--text); font-size: 13px; }
.banner { padding: .55rem 1rem; background: var(--warning-bg); color: #7a4a00; font-weight: 600; border-radius: var(--radius-sm); display: flex; gap: .5rem; align-items: center; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(42, 10, 30, .55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--white); border-radius: 16px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-head { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 1.15rem; display: flex; align-items: center; gap: .5rem; }
.modal-head h3 .icon { color: var(--primary); }
.modal-body { padding: 1.3rem 1.4rem; }
.modal-foot { padding: 1rem 1.4rem; border-top: 1px solid var(--border); display: flex; gap: .6rem; justify-content: flex-end; }
.pay-total { text-align: center; background: var(--primary-light); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.pay-total .v { font-size: 2.2rem; font-weight: 800; color: var(--primary-dark); }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.pay-method { border: 2px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .5rem; text-align: center; cursor: pointer; font-weight: 700; background: var(--white); font: inherit; font-weight: 700; }
.pay-method.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.pay-input { font-size: 1.6rem !important; font-weight: 700; text-align: right; padding: .7rem 1rem !important; }
.quick-cash { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; margin-top: .6rem; }
.quick-cash button { padding: .6rem .3rem; border: 1px solid var(--border); background: var(--white); border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; font: inherit; font-weight: 700; font-size: 13px; }
.quick-cash button:hover { background: var(--primary-light); border-color: var(--primary-soft); }
.change-box { margin-top: 1rem; padding: .9rem 1rem; border-radius: var(--radius); background: var(--success-bg); color: var(--success); display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 1.15rem; }
.change-box.neg { background: var(--danger-bg); color: var(--danger); }
.change-box .v { font-size: 1.6rem; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--white); padding: .8rem 1.3rem; border-radius: 10px; z-index: 200; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); display: none; max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
.toast.show { display: block; animation: toastin .2s; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.token-code { white-space: nowrap; display: inline-block; font-family: Consolas, "Courier New", monospace; font-size: 1.25rem; font-weight: 800; letter-spacing: 2px; background: var(--primary-light); color: var(--primary-dark); padding: .2rem .6rem; border-radius: 8px; }
.token-input { font-family: Consolas, "Courier New", monospace; font-size: 1.6rem !important; font-weight: 800; letter-spacing: 4px; text-align: center; text-transform: uppercase; padding: .6rem !important; }

/* ---------- Boîtes de dialogue (style SweetAlert) ---------- */
.sd-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(42, 10, 30, 0); transition: background .18s ease; }
.sd-overlay.sd-show { background: rgba(42, 10, 30, .5); }
.sd-overlay.sd-hide { background: rgba(42, 10, 30, 0); }
.sd-box { background: var(--white); width: 100%; max-width: 440px; border-radius: 18px; padding: 2rem 1.8rem 1.6rem; text-align: center; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); transform: scale(.7); opacity: 0; transition: transform .22s cubic-bezier(.2, 1.4, .4, 1), opacity .15s; }
.sd-show .sd-box { transform: scale(1); opacity: 1; }
.sd-hide .sd-box { transform: scale(.9); opacity: 0; transition: transform .15s, opacity .15s; }
.sd-icon { width: 76px; height: 76px; border-radius: 50%; border: 4px solid; margin: 0 auto 1.1rem; display: grid; place-items: center; animation: sd-pop .45s ease; }
.sd-glyph { font-size: 2.6rem; font-weight: 800; line-height: 1; font-family: Arial, sans-serif; }
.sd-icon-question { border-color: var(--primary-soft); color: var(--primary); }
.sd-icon-warning { border-color: #f8bb86; color: #f0932b; }
.sd-icon-danger { border-color: #f5a3a3; color: var(--danger); animation: sd-pop .45s ease, sd-shake .5s .3s ease; }
.sd-icon-info { border-color: #9ec5f2; color: var(--info); }
.sd-icon-success { border-color: #a5dcb9; color: var(--success); }
.sd-icon-error { border-color: #f5a3a3; color: var(--danger); }
.sd-check, .sd-cross { width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: sd-draw .45s .2s ease forwards; }
.sd-title { font-size: 1.45rem; font-weight: 700; margin: 0 0 .5rem; color: var(--text); }
.sd-text { color: var(--muted); font-size: 15px; line-height: 1.5; white-space: pre-line; }
.sd-input { margin-top: 1rem; font-size: 1.15rem !important; text-align: center; padding: .65rem !important; }
.sd-error { margin-top: .6rem; color: var(--danger); font-weight: 600; font-size: 13px; }
.sd-actions { display: flex; gap: .6rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.sd-btn { min-width: 120px; padding: .7rem 1.3rem; border-radius: 10px; border: none; font: inherit; font-weight: 700; font-size: 14.5px; cursor: pointer; transition: filter .15s, box-shadow .15s; }
.sd-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(195, 59, 128, .25); }
.sd-confirm { background: var(--primary); color: var(--white); }
.sd-confirm.sd-danger { background: var(--danger); }
.sd-confirm.sd-danger:focus-visible { box-shadow: 0 0 0 4px rgba(198, 40, 40, .25); }
.sd-cancel { background: #ece6ea; color: var(--text); }
.sd-btn:hover { filter: brightness(.94); }
@keyframes sd-pop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes sd-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes sd-draw { to { stroke-dashoffset: 0; } }

/* ---------- Report ---------- */
.report-head { text-align: center; margin-bottom: 1rem; }
.stat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.stat { background: #fbf8fa; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.2rem; font-weight: 750; margin-top: .15rem; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; counter-reset: step; }
.step { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; position: relative; padding-left: 3.3rem; background: #fdfbfc; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 1rem; top: 1rem; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--white); display: grid; place-items: center; font-weight: 800; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .pos { grid-template-columns: 1fr 340px; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .grid-2, .grid-4, .form-grid, .steps { grid-template-columns: minmax(0, 1fr); }
  .bars { gap: 3px; }
  .bar-col:nth-child(even) .bar-label { visibility: hidden; }
  .filters input[type=search], .filters input[type=text] { min-width: 0; width: 100%; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .content { padding: 1rem; }
  .branch-switch select { min-width: 0; }
  .user-trigger .user-meta, .user-chevron { display: none; }
}

@media print {
  .sidebar, .topbar, .no-print, .form-actions, .filters, .pagination { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: var(--white); }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
