/* Gestion de stock - app design system. Plain CSS, no build step. */
:root {
  /* Tokens from the UI UX Pro Max design system (flat, industrial slate + stock green), contrast checked for AA. */
  --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9; --text: #0f172a; --muted: #475569;
  --border: #e2e8f0; --border-strong: #94a3b8;
  --primary: #334155; --accent: #047857; --accent-hover: #065f46; --accent-text: #ffffff; --accent-soft: #e6f4ee;
  --ok: #047857; --ok-soft: #e6f4ee; --warn: #8a5a00; --warn-soft: #fff3d6;
  --danger: #b91c1c; --danger-soft: #fdecec; --info-soft: #eef2f7;
  --radius: 8px; --radius-sm: 6px; --shadow: none;
  --gutter: 16px; --header-h: 56px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --surface: #1e293b; --surface-2: #273449; --text: #f1f5f9; --muted: #a8b3c5;
    --border: #334155; --border-strong: #64748b;
    --primary: #cbd5e1; --accent: #34d399; --accent-hover: #6ee7b7; --accent-text: #052e22; --accent-soft: #11382c;
    --ok: #34d399; --ok-soft: #11382c; --warn: #f0c36a; --warn-soft: #382c10;
    --danger: #fca5a5; --danger-soft: #3b1a1a; --info-soft: #1b2638;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; font-size: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.125rem; } h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-text); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .9em; }


/* App shell */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; min-height: var(--header-h); padding: 0 var(--gutter); display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--bg); display: inline-grid; place-items: center; font-size: .9rem; }
.nav { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; min-height: 40px; display: inline-flex; align-items: center; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px; z-index: 60; }
.menu-panel a, .menu-panel button { display: flex; width: 100%; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); background: none; border: 0; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; min-height: 40px; align-items: center; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }
.menu-head { padding: 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.mobile-menu { display: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 24px var(--gutter) 64px; }
.container.narrow { max-width: 760px; }
.page-header { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-header .sub { color: var(--muted); margin-top: 4px; }
.breadcrumb { font-size: .875rem; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

/* Guest shell */
.guest { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.guest-main { display: grid; place-items: start center; padding: 32px var(--gutter); }
.guest-card { width: 100%; max-width: 440px; }
.guest-foot { text-align: center; padding: 16px; color: var(--muted); font-size: .875rem; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; } .stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: .875rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; cursor: progress; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .opt { font-weight: 400; color: var(--muted); }
.input, .select, .textarea, input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=file], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.help { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.field-error, .error { color: var(--danger); font-size: .875rem; margin-top: 4px; }
.has-error input, .has-error select, .has-error textarea, input[aria-invalid=true] { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; min-height: 32px; }
.check input { width: 18px; height: 18px; min-height: 0; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar input[type=search], .toolbar input[type=text] { min-height: 40px; }

/* Alerts and toasts */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-ok, .status { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-info { background: var(--info-soft); border-color: var(--border); }
.status { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid transparent; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; min-width: 32px; min-height: 32px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table, .table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8125rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.actions, .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
td .actions { justify-content: flex-end; }

/* Badges, empty states, pagination */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.pagination { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 16px; list-style: none; margin: 0; }
.pagination a, .pagination span { min-width: 36px; min-height: 36px; padding: 6px 10px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; background: var(--surface); color: var(--text); }
.pagination .active span, .pagination [aria-current=page] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pagination .disabled span { color: var(--muted); opacity: .6; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.meta dt { color: var(--muted); } dl.meta dd { margin: 0; }

/* Toasts (flash messages, injected by app.js) */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border-strong); border-left: 4px solid var(--ok); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgb(0 0 0 / .18); padding: 12px 14px; animation: slide-in .2s ease-out; }
.toast.is-error { border-left-color: var(--danger); }
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog.confirm { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; max-width: 420px; width: calc(100% - 32px); }
dialog.confirm::backdrop { background: rgb(0 0 0 / .45); }

@media (max-width: 860px) {
  .nav { display: none; }
  .mobile-menu { display: block; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .container { padding-top: 16px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .form-actions .btn { flex: 1 1 auto; }
  .topbar-actions .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Error summary (focusable, links to each invalid field) */
.error-summary { border: 2px solid var(--danger); background: var(--danger-soft); color: var(--text); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.error-summary h2 { color: var(--danger); font-size: 1rem; margin-bottom: 6px; }
.error-summary ul { margin: 0; padding-left: 18px; }
.error-summary a { color: var(--text); font-weight: 600; }
.error-summary:focus { outline: 3px solid var(--danger); outline-offset: 2px; }
td.num, th.num { text-align: right; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px var(--gutter); margin: 16px calc(var(--gutter) * -1) 0; }

/* App shell with left sidebar (desktop) and compact top bar (mobile) */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar .brand { padding: 4px 8px; }
.side-cta { margin: 0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 500; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-nav .ico { width: 20px; height: 20px; flex: none; }
.side-user { margin-top: auto; display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.side-user-info { display: grid; gap: 2px; min-width: 0; }
.side-user-info .muted { font-size: .8125rem; overflow-wrap: anywhere; }
.side-user-info .badge { justify-self: start; margin-top: 4px; }
.content { min-width: 0; }
.mobilebar { display: none; position: sticky; top: 0; z-index: 50; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--header-h); padding: 0 var(--gutter); background: var(--surface); border-bottom: 1px solid var(--border); }
.mobilebar .menu-panel { width: min(320px, calc(100vw - 32px)); display: grid; gap: 8px; padding: 10px; }
.mobilebar .menu-panel .side-nav { margin: 4px 0; }
.mobilebar .menu-panel .menu-head { border-top: 1px solid var(--border); border-bottom: 0; margin: 4px 0 0; padding-top: 12px; }
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .mobilebar { display: flex; }
}

.account-link { color: var(--text); text-decoration: none; }
.account-link:hover strong { text-decoration: underline; }
