/* Stock Railing — feuille de style unique, sans framework.
   La couleur d'accent (--accent) vient des paramètres et est injectée dans la page. */

:root {
    --accent: #E0222E;
    --accent-strong: color-mix(in srgb, var(--accent) 82%, #000);
    --accent-soft: color-mix(in srgb, var(--accent) 9%, #fff);
    --accent-softer: color-mix(in srgb, var(--accent) 5%, #fff);
    --bg: #F4F5F7;
    --surface: #FFFFFF;
    --border: #E3E6EA;
    --border-strong: #CDD3D9;
    --text: #2F3E45;
    --muted: #5F6B72;
    --ok: #1E7B4A;
    --ok-soft: #E6F4EC;
    --warn: #8A5A00;
    --warn-soft: #FFF4DC;
    --danger: #B42318;
    --danger-soft: #FDECEA;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
    --sidebar-w: 268px;
    --gap: 16px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.25; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, #fff); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Arrondis : squircle si le navigateur le gère, sinon border-radius classique ---------- */
.card, .button, input, select, textarea, .sidebar, .alert, .menu-link, .user-card, .tile-icon, .stat-icon, .search-field, .login-card {
    border-radius: var(--radius);
}
.button, input, select, textarea, .menu-link, .search-field, .alert { border-radius: var(--radius-sm); }
@supports (corner-shape: squircle) {
    .card, .sidebar, .login-card, .user-card { corner-shape: squircle; border-radius: 26px; }
    .button, input, select, textarea, .menu-link, .search-field, .alert, .tile-icon, .stat-icon { corner-shape: squircle; border-radius: 18px; }
}

/* ---------- Menu latéral : carte flottante ---------- */
.sidebar {
    position: fixed;
    top: var(--gap); bottom: var(--gap); left: var(--gap);
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 18px 12px 12px;
    z-index: 40;
}

.sidebar-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 8px; }
.brand { display: block; }
.brand-logo { display: block; height: 42px; width: auto; }
.sidebar-head .sidebar-close { display: none; position: absolute; right: 0; top: 50%; transform: translateY(-50%); }

.sidebar-sections { flex: 1; overflow-y: auto; margin-top: 18px; padding-right: 2px; }

.menu-section { margin-bottom: 6px; }
.menu-title {
    display: flex; align-items: center; gap: 8px;
    list-style: none; cursor: pointer;
    padding: 10px 10px;
    font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted);
    border-radius: 8px;
    user-select: none;
}
.menu-title::-webkit-details-marker { display: none; }
.menu-title > span:first-child { flex: 1; }
.menu-title:hover { color: var(--text); }
.menu-title .chevron { width: 16px; height: 16px; transition: transform .15s ease; }
.menu-section[open] > .menu-title .chevron { transform: rotate(180deg); }
.menu-section[open] > .menu-title .badge-closed { display: none; }

.menu-items { list-style: none; margin: 0 0 4px; padding: 0; }
.menu-divider { height: 1px; margin: 6px 12px; background: var(--border); }

.menu-link {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    color: var(--text);
    font: inherit; font-size: 15px;
    background: none; border: 0; cursor: pointer; text-align: left;
}
.menu-link:hover { background: var(--bg); text-decoration: none; }
.menu-link .icon { color: var(--muted); }
.menu-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.menu-link.is-active .icon { color: var(--accent-strong); }
.menu-label { flex: 1; }

.badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, #fff);
    font-size: 12px; font-weight: 700; line-height: 1;
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 6px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: 13px;
}
.user-meta { display: grid; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12.5px; color: var(--muted); }
.logout { color: var(--text); }

/* ---------- Barre du haut (téléphone) ---------- */
.topbar { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(20, 28, 33, .45); z-index: 30; }
.backdrop[hidden] { display: none; }

.icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
}
@supports (corner-shape: squircle) { .icon-button { corner-shape: squircle; border-radius: 18px; } }

/* ---------- Contenu ---------- */
.main {
    margin-left: calc(var(--sidebar-w) + var(--gap) * 2);
    padding: 40px 48px 64px;
    max-width: calc(1120px + var(--sidebar-w) + var(--gap) * 2);
}
.main:focus { outline: none; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-header h1 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.subtitle { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.back-link .icon { width: 16px; height: 16px; }

.page-help {
    display: flex; gap: 10px; align-items: flex-start;
    margin: 0 0 24px; padding: 10px 14px;
    background: #EEF1F3;
    border-radius: var(--radius-sm);
    color: var(--text); font-size: 14px;
}
.page-help .icon { color: var(--muted); width: 18px; height: 18px; margin-top: 1px; }

.section { margin-top: 28px; }
.section-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(16, 24, 40, .03); }

/* Raccourcis */
.shortcut-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.shortcut {
    display: flex; align-items: center; gap: 16px;
    padding: 20px 18px;
    color: var(--text);
    min-height: 100px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.shortcut:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow); }
.shortcut .chevron { color: var(--muted); width: 18px; height: 18px; }
.shortcut-text { flex: 1; display: grid; gap: 3px; min-width: 0; }
.shortcut-title { display: block; font-weight: 600; font-size: 16px; }
.shortcut-desc { display: block; color: var(--muted); font-size: 14px; }

.tile-icon, .stat-icon {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 44px; height: 44px;
    background: var(--accent-soft); color: var(--accent-strong);
}
.stat-icon { width: 32px; height: 32px; border-radius: 9px; }
.stat-icon .icon { width: 17px; height: 17px; }

/* Chiffres clés */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-bottom: 8px; }
.stat { position: relative; display: grid; gap: 2px; padding: 18px; }
.stat .stat-icon { position: absolute; top: 14px; right: 14px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.15; }
.stat-label { font-size: 14px; color: var(--muted); }
.stock-low { color: var(--danger); font-weight: 700; }

/* Boutons */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px;
    font: inherit; font-weight: 600; font-size: 15px;
    border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.button:hover { text-decoration: none; }
.button .icon { width: 18px; height: 18px; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-strong); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--bg); }
.button-ghost { background: transparent; color: var(--text); }
.button-ghost:hover { background: var(--bg); }
.button-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, #fff); }
.button-block { width: 100%; }

/* Recherche */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-field {
    flex: 1 1 260px; display: flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border-strong); padding: 0 12px;
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search-field .icon { color: var(--muted); width: 18px; height: 18px; }
.search-field input { border: 0; box-shadow: none; padding-left: 0; background: transparent; min-height: 42px; }
.search-field input:focus { box-shadow: none; outline: none; }
.select-compact { width: auto; min-width: 130px; }
.input-compact { width: 96px; }

/* Tableaux */
.table-card { overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
    color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); background: #FAFBFC;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFC; }
.table .num { text-align: right; white-space: nowrap; }
.cell-main { font-weight: 500; }
.ref { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13.5px; }
a.ref { font-weight: 600; }
.unit { color: var(--muted); font-size: 13px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-left: 6px; vertical-align: middle; }
.pill-ok { background: var(--ok-soft); color: var(--ok); margin-left: 0; }
.pill-muted { background: #EEF0F2; color: var(--muted); }
.pill-alert { background: var(--danger-soft); color: var(--danger); }

/* Formulaires */
.form { display: block; }
.card.form, .card.form-grid { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; margin-bottom: 14px; align-content: start; }
.field label { font-weight: 600; font-size: 14px; }
.required { color: var(--danger); }
input, select, textarea {
    width: 100%; min-height: 44px; padding: 10px 12px;
    font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong);
}
textarea { min-height: 96px; resize: vertical; }
.textarea-refs { min-height: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type="color"] { padding: 4px; width: 88px; cursor: pointer; }
input[type="file"] { padding: 8px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint.center { text-align: center; margin-top: 14px; }
.error { margin: 0; font-size: 13.5px; color: var(--danger); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; min-height: 44px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.logo-preview { padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #FAFBFC; }
.logo-preview img { display: block; max-height: 56px; }

/* Rôles */
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.role-card { display: grid; gap: 14px; padding: 18px; color: var(--text); }
.role-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow); }
.role-head { display: flex; align-items: center; gap: 14px; }
.role-head > span:nth-child(2) { flex: 1; }
.role-head .chevron { color: var(--muted); width: 18px; height: 18px; }
.perm-list { list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: grid; gap: 7px; font-size: 13.5px; }
.perm-list li { display: flex; gap: 8px; align-items: flex-start; }
.perm-list .icon { width: 17px; height: 17px; margin-top: 1px; }
.perm-on .icon { color: var(--ok); }
.perm-off { color: var(--muted); }
.perm-off .icon { color: #A3ADB3; }
.perm-fieldset { border: 0; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.perm-fieldset legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.perm-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.perm-option:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 40%, #fff); background: var(--accent-softer); }
.perm-option > span { display: grid; gap: 2px; }
.perm-label { font-weight: 600; }
.danger-zone { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Détails d'une fiche */
.details { margin: 0; padding: 6px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.details > div { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.details dt { font-size: 13px; color: var(--muted); }
.details dd { margin: 0; font-weight: 500; }

/* Messages */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 18px; border: 1px solid; font-size: 14.5px; }
.alert .icon { width: 19px; height: 19px; margin-top: 1px; }
.alert-success { background: var(--ok-soft); border-color: #BFE3CE; color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: #F5C2BD; color: var(--danger); }
.alert-warning { background: var(--warn-soft); border-color: #F2DDA6; color: var(--warn); margin-top: 16px; }

.empty-state { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state p { margin: 0; }
.error-page { max-width: 560px; margin: 40px auto; }
.error-page h1 { color: var(--text); font-size: 24px; }
.error-detail { white-space: pre-wrap; text-align: left; font-size: 12px; max-width: 100%; overflow: auto; }

/* Aide */
.help-list { display: grid; gap: var(--gap); max-width: 860px; }
.help-topic { padding: 20px 22px; }
.help-topic h2 { display: flex; align-items: center; gap: 12px; font-size: 17px; margin-bottom: 8px; }
.help-topic .tile-icon { width: 36px; height: 36px; }
.help-topic .tile-icon .icon { width: 18px; height: 18px; }
.help-topic p { margin: 6px 0 0; color: var(--text); }

/* Connexion */
.page-simple { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.simple-main { width: 100%; max-width: 420px; }
.login-card { padding: 32px 28px; box-shadow: var(--shadow); }
.login-logo { display: block; height: 56px; width: auto; margin: 0 auto 18px; }
.login-card h1 { text-align: center; font-size: 22px; }
.login-card .subtitle { text-align: center; margin-bottom: 22px; }

/* Installation */
.simple-main:has(.install-card) { max-width: 620px; }
.install-card .page-help { margin-bottom: 18px; }
.install-step { margin: 0 0 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.install-step .section-title { font-size: 16px; margin-bottom: 10px; }
.install-step > .hint { margin-bottom: 12px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; }
.check-list li > span { display: grid; gap: 2px; }
.check-list .icon { width: 18px; height: 18px; margin-top: 1px; }
.check-ko .icon { color: var(--danger); }

/* Sécurité des connexions : mot de passe, double authentification, journal */
.simple-main:has(.setup-card) { max-width: 480px; }
.setup-card form + form { margin-top: 10px; }
.steps-list { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; font-size: 14.5px; }
.qr-box { display: flex; justify-content: center; margin: 6px 0 10px; }
.qr-code { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.secret-key, .recovery-codes li { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; background: var(--bg); border-radius: var(--radius-sm); }
.secret-key { margin: 6px 0 18px; padding: 10px; text-align: center; font-size: 15px; letter-spacing: .04em; overflow-wrap: anywhere; }
.code-input { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 22px; letter-spacing: .25em; text-align: center; }
.recovery-codes { list-style: none; margin: 4px 0 18px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.recovery-codes li { padding: 9px 6px; text-align: center; font-size: 16px; }
.form-narrow { max-width: 560px; }
.account-row { display: flex; align-items: center; gap: 14px; padding: 18px 20px; flex-wrap: wrap; }
.account-row p { flex: 1 1 260px; margin: 0; }
.account-hint { margin-top: 8px; }
.ip-check { margin-bottom: 16px; }

/* Mouvements */
.pill-entree, .pill-retour { background: var(--ok-soft); color: var(--ok); margin-left: 0; }
.pill-sortie { background: var(--accent-soft); color: var(--accent-strong); margin-left: 0; }
.pill-correction { background: var(--warn-soft); color: var(--warn); margin-left: 0; }
.pill-inventaire { background: #E8EEF6; color: #2B4C7E; margin-left: 0; }
.qty-in { color: var(--ok); font-weight: 600; }
.qty-out { color: var(--text); font-weight: 600; }
.qty-in .unit, .qty-out .unit { font-weight: 400; }
.row-comment td { padding-top: 0; color: var(--muted); font-size: 13.5px; }
.table tbody tr.row-comment:hover { background: transparent; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head .section-title { margin-bottom: 0; }
.filter-chip { display: inline-flex; align-items: center; gap: 8px; margin: -6px 0 18px; padding: 4px 4px 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; font-weight: 500; }
.filter-chip .icon { width: 17px; height: 17px; }
.filter-remove { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 999px; color: inherit; }
.filter-remove:hover { background: color-mix(in srgb, var(--accent) 14%, #fff); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.pager .button:only-child { margin-left: auto; }
.form-intro { margin: 0 0 16px; }
.subsection-title { font-size: 15px; font-weight: 700; margin: 18px 0 8px; }
.plain-list { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 6px; font-size: 14.5px; }

/* Lignes de saisie (article + quantité) */
.lines { border: 0; padding: 16px 0 6px; margin: 6px 0 12px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.lines legend { font-weight: 700; font-size: 15px; padding: 0; margin-bottom: 4px; float: left; width: 100%; }
.line-row, .line-head { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 10px; align-items: start; }
.line-row-price { grid-template-columns: minmax(0, 1fr) 140px 160px; }
.line-head { font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.line-error { grid-column: 1 / -1; }
.line-info { grid-column: 1 / -1; margin: -4px 0 2px; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13.5px; line-height: 1.4; }
.line-info:empty { display: none; }
.line-designation { flex-basis: 100%; font-weight: 600; overflow-wrap: anywhere; }
.line-meta { color: var(--muted); }
.line-warn { color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 0 6px; font-weight: 600; }
.lines [data-add-line] { justify-self: start; }

/* Import de l'inventaire */
.report-list { list-style: none; margin: 0; padding: 6px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.report-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.report-count { min-width: 40px; text-align: center; padding: 2px 8px; border-radius: 999px; font-weight: 700; background: #EEF0F2; color: var(--muted); font-variant-numeric: tabular-nums; }
.report-on .report-count { background: var(--warn-soft); color: var(--warn); }
.report-off { color: var(--muted); }
.pill-import-ok { background: var(--ok-soft); color: var(--ok); margin-left: 0; }
.pill-import-merged { background: var(--warn-soft); color: var(--warn); margin-left: 0; }
.pill-import-excluded { background: #EEF0F2; color: var(--muted); margin-left: 0; }
.note-line { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.all-lines > summary { cursor: pointer; min-height: 44px; display: list-item; padding-top: 10px; }
.card.form > form + .form-actions, .card.form .form-actions form { margin: 0; }

/* Fournisseur donné en lot (liste des articles) et import des tarifs */
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #FAFBFC; }
.bulk-count { flex: 1; font-size: 14px; color: var(--muted); min-width: 140px; }
.bulk-group { display: flex; align-items: center; gap: 10px; }
.cell-check { width: 52px; }
.cell-check input { width: 22px; height: 22px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.table .cell-check { padding-right: 0; }
.note-warn { color: var(--warn); }
.sheet-columns { border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px 8px; margin: 0 0 14px; }
.sheet-columns legend { padding: 0 6px; }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Étiquettes QR code : planche à imprimer ----------
   Dimensions de la page et de la grille dans le bloc <style> de la page (paramètres « Étiquettes »). */
.page-print { background: var(--bg); }
.print-toolbar { max-width: 760px; margin: 0 auto; padding: 24px 16px 8px; }
.print-toolbar h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.print-toolbar .subtitle { margin: 2px 0 12px; color: var(--muted); }
.print-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 4px; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.page-print .alert { max-width: 728px; margin: 16px auto 0; }
.sheets { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 16px 0 48px; }
.sheet {
    display: grid; align-content: start;
    background: #fff; color: #000; overflow: hidden;
    box-shadow: var(--shadow); outline: 1px solid var(--border);
    break-after: page;
}
.sheet:last-child { break-after: auto; }
.label { display: flex; align-items: center; gap: 2mm; padding: 2.5mm; overflow: hidden; min-width: 0; outline: 1px dashed #D5DAE0; }
.label .qr-code { height: 100%; width: auto; max-width: 50%; aspect-ratio: 1; flex: none; border: 0; border-radius: 0; }
.label-text { display: flex; flex-direction: column; gap: 1mm; min-width: 0; font-family: var(--font); }
.label-ref { font-size: 11pt; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.label-designation {
    font-size: 7.5pt; line-height: 1.25; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden;
}
/* Aperçu à l'écran : la planche est réduite pour tenir dans la largeur (elle est imprimée en taille réelle). */
@media screen and (max-width: 860px) { .sheet { zoom: .75; } }
@media screen and (max-width: 640px) { .sheet { zoom: .55; } }
@media screen and (max-width: 460px) { .sheet { zoom: .42; } }
@media print {
    .no-print { display: none !important; }
    body, .page-print { background: #fff; margin: 0; }
    .sheets { display: block; padding: 0; }
    .sheet { box-shadow: none; outline: 0; zoom: 1; }
    .label { outline: 0; }
}

/* ---------- Scan au téléphone (écrans de saisie) ---------- */
.scan-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 6px; }
.scan-dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.scan-dialog::backdrop { background: rgba(16, 24, 40, .55); }
.scan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.scan-head h2 { margin: 0; font-size: 17px; }
.scan-video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #000; }
.scan-status { margin: 0; padding: 12px 16px 16px; font-size: 14px; color: var(--muted); }

/* ---------- Ordinateur moyen ---------- */
@media (max-width: 1280px) {
    .main { padding: 32px 32px 56px; }
    .shortcut-grid, .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Téléphone et tablette : menu masqué, ouvert par un bouton ---------- */
@media (max-width: 1023px) {
    .topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 20;
        padding: 10px 16px;
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--border);
    }
    .topbar-brand { display: flex; align-items: center; }
    .topbar-logo { height: 30px; width: auto; }
    .topbar-spacer { flex: 1; }

    .sidebar {
        top: 12px; bottom: 12px; left: 12px;
        width: min(var(--sidebar-w), calc(100vw - 24px));
        transform: translateX(calc(-100% - 24px));
        transition: transform .2s ease;
        visibility: hidden;
    }
    body.menu-open .sidebar { transform: none; visibility: visible; }
    body.menu-open { overflow: hidden; }
    .sidebar-head { padding: 0 48px; }
    .sidebar-head .sidebar-close { display: inline-flex; right: -4px; }
    .brand-logo { max-width: 100%; height: auto; max-height: 42px; }

    .main { margin-left: 0; padding: 20px 16px 48px; }
    .page-header h1 { font-size: 25px; }
    .shortcut-grid, .role-grid, .stat-grid { grid-template-columns: minmax(0, 1fr); }
    .stat-grid { gap: 10px; }
    .form-grid, .details { grid-template-columns: minmax(0, 1fr); }
    .card.form, .card.form-grid { padding: 18px 16px; }
    .page-actions { width: 100%; }
    .page-actions .button { flex: 1; }

    /* Tableaux en cartes empilées */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
    .table-stack td.cell-main { font-size: 15.5px; text-align: left; display: block; padding-bottom: 4px; }
    .table-stack td.cell-main::before, .table-stack td.cell-ref::before { content: none; }
    .table-stack td.cell-ref { justify-content: flex-start; padding-bottom: 0; }
    .table-stack td.cell-main { padding-top: 0; }
    .table-stack .num { text-align: right; }
    .table-stack td.cell-notes { display: block; text-align: left; }
    .table-stack td.cell-notes::before { content: none; }
    .table-stack tr:has(.cell-check) { position: relative; padding-right: 64px; }
    .table-stack td.cell-check { position: absolute; top: 4px; right: 4px; width: auto; padding: 0; }
    .table-stack td.cell-check::before { content: none; }
    .table-stack td.cell-check input { width: 26px; height: 26px; margin: 9px; }
    .bulk-bar .select-compact { flex: 1; }
    .bulk-group { flex: 1 1 100%; min-width: 0; }
    .bulk-group .input-compact { flex: 1 1 0; width: auto; min-width: 0; }
    .bulk-group .button { flex: none; }

    .line-row, .line-row-price { grid-template-columns: minmax(0, 1fr) 96px; }
    .line-row-price input:nth-of-type(3) { grid-column: 1 / -1; }
    .line-head { display: none; }
    .report-list { grid-template-columns: minmax(0, 1fr); }
    .section-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
