:root {
  --bg: #07080c;
  --surface: rgba(20, 23, 32, 0.72);
  --surface-solid: #12141c;
  --surface-2: #1a1d28;
  --surface-3: #232736;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef5;
  --muted: #8b92a7;
  --faint: #5a6176;
  --accent: #8b7cff;
  --accent-2: #3dd6f5;
  --grad: linear-gradient(135deg, #8b7cff 0%, #6a8bff 50%, #3dd6f5 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 3px rgba(139, 124, 255, 0.35);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --topbar-h: 64px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(55rem 35rem at 105% -10%, rgba(139, 124, 255, 0.16), transparent 60%),
    radial-gradient(45rem 30rem at -15% 105%, rgba(61, 214, 245, 0.09), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input { font: inherit; color: inherit; }

.icon { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--mono); font-size: 0.85em; letter-spacing: -0.01em; }
.center { text-align: center; }
.grow { flex: 1; }
.min-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stack { display: grid; gap: 14px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 8, 12, 0.7);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1100px;
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--grad);
  color: #07080c;
  box-shadow: 0 8px 24px -8px rgba(139, 124, 255, 0.7);
}
.brand-mark .icon { width: 19px; height: 19px; stroke-width: 2.4; }
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; }
.brand-mark-lg .icon { width: 28px; height: 28px; }

.nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 550;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }
.nav-link .icon { width: 18px; height: 18px; }
.topbar-user { display: flex; align-items: center; gap: 6px; }
.topbar-user form { margin: 0; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn-sm .icon { width: 16px; height: 16px; }

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 120px;
  display: grid;
  gap: 20px;
  align-content: start;
}
.page-head { display: flex; align-items: center; gap: 14px; }
.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title .icon { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn .icon { width: 18px; height: 18px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--grad);
  color: #080913;
  box-shadow: 0 10px 30px -10px rgba(106, 139, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover { box-shadow: 0 14px 36px -10px rgba(106, 139, 255, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn-primary .icon { stroke-width: 2.5; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn-danger { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.3); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.18); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.actions-split > * { flex: 1; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 0.85rem; font-weight: 550; color: var(--muted); }
/* :where() deja la especificidad en 0 para que .search input, .stepper input, etc. puedan sobrescribir. */
:where(input:not([type="hidden"], [type="checkbox"])) {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(10, 11, 16, 0.6);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-size: 16px; /* evita zoom en iOS */
}
input::placeholder { color: var(--faint); }
input:focus { border-color: rgba(139, 124, 255, 0.6); box-shadow: var(--ring); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.form-error { color: var(--danger); font-size: 0.9rem; }

.check { position: relative; display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; user-select: none; color: var(--muted); font-size: 0.92rem; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.check-box {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: rgba(10, 11, 16, 0.6);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.check-box .icon { width: 14px; height: 14px; stroke-width: 3; color: #080913; opacity: 0; transform: scale(0.6); transition: opacity 0.15s, transform 0.15s; }
.check:hover .check-box { border-color: rgba(139, 124, 255, 0.6); }
.check input:checked + .check-box { background: var(--grad); border-color: transparent; }
.check input:checked + .check-box .icon { opacity: 1; transform: none; }
.check input:focus-visible + .check-box { box-shadow: var(--ring); }
.check input:checked ~ span:last-child { color: var(--text); }
.hint { font-size: 0.85rem; margin-top: 10px; padding-left: 2px; }

.search { position: relative; display: block; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; transition: color 0.15s; }
.search:focus-within .icon { color: var(--accent); }
.search input { padding-left: 44px; }
.search-lg .icon { left: 18px; }
.search-lg input { min-height: 56px; padding-left: 50px; font-size: 17px; border-radius: 16px; }

.stepper {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(10, 11, 16, 0.6);
  overflow: hidden;
}
.stepper:focus-within { border-color: rgba(139, 124, 255, 0.6); box-shadow: var(--ring); }
.stepper button {
  display: grid;
  place-items: center;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.stepper button:hover { background: var(--surface-3); }
.stepper button:active { background: rgba(139, 124, 255, 0.25); }
.stepper input {
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  min-height: 58px;
  box-shadow: none !important;
}

/* ---------- Auth ---------- */
.auth-page .container { min-height: 100dvh; padding-bottom: 28px; }
.auth { display: grid; place-items: center; min-height: calc(100dvh - 56px); }
.auth-card { width: min(420px, 100%); padding: 32px 26px; display: grid; gap: 24px; }
.auth-brand { display: grid; justify-items: center; gap: 10px; text-align: center; }
.auth-footer { text-align: center; margin: 0; }

/* ---------- Dashboard ---------- */
.btn-load { flex: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(139, 124, 255, 0.18), transparent 70%);
  pointer-events: none;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(139, 124, 255, 0.12);
  color: var(--accent);
  margin-bottom: 8px;
}
.stat-value { font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2rem); font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-warn .stat-icon { background: rgba(251, 191, 36, 0.12); color: var(--warn); }
.stat-warn::after { background: radial-gradient(circle, rgba(251, 191, 36, 0.14), transparent 70%); }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 8px; }
.chip {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 550;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip.is-active { color: var(--text); border-color: rgba(139, 124, 255, 0.5); background: rgba(139, 124, 255, 0.14); }

.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.item:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.item-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(139, 124, 255, 0.22), rgba(61, 214, 245, 0.14));
  border: 1px solid rgba(139, 124, 255, 0.25);
  font-weight: 700;
  color: #cfc9ff;
}
.item-body { display: grid; min-width: 0; flex: 1; }
.item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.item-code { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-qty {
  display: grid;
  justify-items: end;
  line-height: 1.1;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(52, 211, 153, 0.1);
  color: var(--ok);
}
.item-qty-value { font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.item-qty small { font-size: 0.7rem; opacity: 0.8; }
.item-qty.is-low { background: rgba(251, 191, 36, 0.1); color: var(--warn); }
.item-qty.is-empty { background: rgba(248, 113, 113, 0.1); color: var(--danger); }

.empty { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 48px 20px; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: rgba(139, 124, 255, 0.12);
  color: var(--accent);
}
.empty-icon .icon { width: 30px; height: 30px; }
.empty-inline { text-align: center; padding: 20px; }

/* ---------- Carga ---------- */
.container.is-narrow { max-width: 680px; }
.load { display: grid; gap: 16px; width: 100%; }
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.segment.is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.6); }
.segment.is-active .icon { color: var(--accent); }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fde68a;
  font-size: 0.9rem;
}
.notice .icon { color: var(--warn); margin-top: 1px; }

.scanner {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 1;
  max-height: 60vh;
  margin: 0 auto 14px;
  max-width: 100%;
}
#reader { width: 100%; height: 100%; border: 0 !important; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
#reader img[alt="Info icon"], #reader__dashboard_section_csr span { display: none !important; }

.code-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: rgba(61, 214, 245, 0.08);
  border: 1px solid rgba(61, 214, 245, 0.25);
  font-size: 0.9rem;
}
.code-chip > .icon { color: var(--accent-2); }
.code-chip > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.suggestions { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.suggestion {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.suggestion:hover, .suggestion:focus-visible { border-color: rgba(139, 124, 255, 0.5); background: var(--surface-3); outline: none; }
.suggestion-body { display: grid; flex: 1; min-width: 0; }
.suggestion-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-meta { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-tag { font-size: 0.75rem; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: rgba(52, 211, 153, 0.12); color: var(--ok); white-space: nowrap; }
.suggestion-create { border-style: dashed; border-color: rgba(139, 124, 255, 0.4); background: rgba(139, 124, 255, 0.06); }
.suggestion-create .suggestion-tag { background: rgba(139, 124, 255, 0.16); color: #c4bbff; }

/* Lector de etiquetas */
.label-reader { margin-bottom: 14px; }
.label-reader-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(139, 124, 255, 0.35);
  background: linear-gradient(135deg, rgba(139, 124, 255, 0.14), rgba(61, 214, 245, 0.06));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.label-reader-btn:hover { border-color: rgba(139, 124, 255, 0.6); transform: translateY(-1px); }
.label-reader-btn:disabled { cursor: progress; transform: none; }
.label-reader-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 14px;
  background: var(--grad);
  color: #080913;
  overflow: hidden;
}
.label-reader-icon img { width: 100%; height: 100%; object-fit: cover; }
.label-reader-icon:has(img:not([hidden])) .icon { display: none; }
.label-reader-body { display: grid; min-width: 0; }
.label-reader-body strong { overflow-wrap: anywhere; }
.label-reader-body .muted { font-size: 0.85rem; }
.label-reader-btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.09) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.confirm { display: grid; gap: 18px; }
.confirm form { display: grid; gap: 16px; }
.confirm-head { display: grid; gap: 6px; }
.confirm-head h2 { font-size: 1.4rem; overflow-wrap: anywhere; }
.badge {
  justify-self: start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
}
.badge.is-new { background: rgba(139, 124, 255, 0.16); color: #c4bbff; }

.success { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 32px 20px; }
.success-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(52, 211, 153, 0.14);
  color: var(--ok);
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.success-icon .icon { width: 34px; height: 34px; stroke-width: 2.6; }
.success .actions { justify-content: center; margin-top: 10px; }

/* ---------- Ventana de carga (modal) ---------- */
body.modal-open { overflow: hidden; overscroll-behavior: none; }
.sheet {
  width: min(520px, calc(100% - 32px));
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.sheet::backdrop { background: rgba(3, 4, 8, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet[open] .sheet-inner { animation: sheet-in 0.25s ease-out; }
.sheet.is-nudged .sheet-inner { animation: nudge 0.3s ease-in-out; }
.sheet-inner {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 26px 24px 24px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 24px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.85);
}
.sheet-close { position: absolute; top: 16px; right: 16px; z-index: 1; }
.sheet .confirm-head { padding-right: 52px; }
.sheet .success { padding: 12px 0 0; }

@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Producto ---------- */
.product-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.qty-hero { display: grid; justify-items: center; gap: 2px; padding: 8px 0 22px; }
.qty-hero-label { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.qty-hero-value {
  font-size: clamp(3.2rem, 2.5rem + 3vw, 4.6rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.qty-hero.is-low .qty-hero-value { background: none; color: var(--warn); }
.qty-hero.is-empty .qty-hero-value { background: none; color: var(--danger); }

.qr-card { display: grid; gap: 16px; align-content: start; }
.qr-label {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  color: #0b0c10;
  text-align: center;
}
.qr-label img { width: 180px; height: 180px; }
.qr-label strong { font-size: 1rem; overflow-wrap: anywhere; }
.qr-label .mono { color: #4b5263; }

.moves { list-style: none; margin: 0; padding: 0; display: grid; }
.move { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.move:first-child { border-top: 0; padding-top: 0; }
.move-delta {
  min-width: 58px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.move-delta.is-in { background: rgba(52, 211, 153, 0.1); color: var(--ok); }
.move-delta.is-out { background: rgba(248, 113, 113, 0.1); color: var(--danger); }
.move-body { display: grid; flex: 1; min-width: 0; }
.move-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-after { white-space: nowrap; }

.settings summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  color: var(--muted);
}
.settings summary::-webkit-details-marker { display: none; }
.settings[open] summary { color: var(--text); margin-bottom: 16px; }
.settings form { margin: 0 0 12px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 200px; }

/* ---------- Notificaciones ---------- */
.toasts {
  position: fixed;
  top: calc(var(--topbar-h) + 16px + env(safe-area-inset-top));
  right: 16px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  --toast-color: var(--accent);
  --toast-duration: 4500ms;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 12px 10px 15px 12px;
  border-radius: 16px;
  background: rgba(22, 25, 35, 0.9);
  border: 1px solid var(--border-strong);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  pointer-events: auto;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  animation: toast-in 0.45s cubic-bezier(0.2, 1.2, 0.3, 1) backwards;
}
.toast::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: var(--toast-color);
  opacity: 0.75;
  transform-origin: left;
  animation: toast-progress var(--toast-duration) linear forwards;
}
.toast:hover::after { animation-play-state: paused; }
.toast.is-leaving { animation: toast-out 0.3s ease-in forwards; }
.toast-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: var(--toast-color);
  background: color-mix(in srgb, var(--toast-color) 16%, transparent);
}
.toast-icon .icon { width: 18px; height: 18px; stroke-width: 2.4; }
.toast-body { display: grid; gap: 1px; min-width: 0; padding-top: 1px; }
.toast-title { font-weight: 650; font-size: 0.93rem; }
.toast-message { color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.toast-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.toast-close:hover { color: var(--text); background: var(--surface-3); }
.toast-close .icon { width: 16px; height: 16px; }
.toast-success { --toast-color: var(--ok); }
.toast-error { --toast-color: var(--danger); }
.toast-warning { --toast-color: var(--warn); }
.toast-info { --toast-color: var(--accent); }

@keyframes toast-in { from { opacity: 0; transform: translateX(48px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(48px) scale(0.96); } }
@keyframes toast-drop { from { opacity: 0; transform: translateY(-24px) scale(0.96); } }
@keyframes toast-lift { to { opacity: 0; transform: translateY(-16px) scale(0.96); } }
@keyframes toast-progress { to { transform: scaleX(0); } }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

@media (max-width: 760px) {
  .toasts { left: 16px; right: 16px; width: auto; top: calc(var(--topbar-h) + 10px + env(safe-area-inset-top)); }
  .toast { animation-name: toast-drop; }
  .toast.is-leaving { animation-name: toast-lift; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .nav { margin-left: 0; justify-content: center; }
  .nav-link span { display: none; }
  .nav-link { padding: 9px 12px; }
  .brand-name { display: none; }
  .container { padding-top: 20px; gap: 16px; }
  .product-grid { grid-template-columns: 1fr; }
  .items { grid-template-columns: 1fr; }
  .stats { gap: 8px; }
  .stat { padding: 14px 12px; }
  .stat-icon { width: 30px; height: 30px; border-radius: 9px; margin-bottom: 4px; }
  .stat-icon .icon { width: 16px; height: 16px; }
  .stat-label { font-size: 0.76rem; }
  .card { padding: 16px; }
  .chips { width: 100%; }
  .chip { flex: 1; }
  .move-after { display: none; }

  /* Botón flotante de carga en celulares */
  .btn-load {
    position: fixed;
    right: 16px;
    left: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 30;
    min-height: 56px;
    border-radius: 18px;
    font-size: 1.05rem;
    box-shadow: 0 18px 40px -12px rgba(106, 139, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  }
  .toasts { top: calc(var(--topbar-h) + 8px + env(safe-area-inset-top)); }

  /* En el celular la ventana de carga sale desde abajo */
  .sheet { width: 100%; margin: auto 0 0; }
  .sheet-inner {
    max-height: calc(100dvh - 24px);
    padding: 24px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
  }
  .sheet[open] .sheet-inner { animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
  .sheet .actions > * { flex: 1; }
}

@keyframes sheet-up { from { transform: translateY(100%); } }

/* ---------- Movimiento y transiciones ---------- */
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
::view-transition-old(root) { animation: vt-out 0.16s ease-in both; }
::view-transition-new(root) { animation: vt-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* Fondo con brillo que se desplaza lentamente */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(30rem 30rem at 22% 30%, rgba(139, 124, 255, 0.1), transparent 70%),
    radial-gradient(26rem 26rem at 78% 72%, rgba(61, 214, 245, 0.07), transparent 70%);
  animation: drift 28s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(6%, -4%, 0) rotate(8deg); } }

/* Entrada escalonada del contenido */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade { from { opacity: 0; } }
.container > * { animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.container > .page-head,
.container > .items { animation-name: fade; }
.container > :nth-child(2) { animation-delay: 50ms; }
.container > :nth-child(3) { animation-delay: 100ms; }
.container > :nth-child(4) { animation-delay: 150ms; }
.container > :nth-child(n + 5) { animation-delay: 200ms; }
.item { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(180ms + var(--i, 0) * 30ms); }
.suggestions li { animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
.move { animation: fade 0.4s backwards; }

.stat { transition: transform 0.2s, border-color 0.2s; }
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }

/* Botón principal con brillo al pasar el mouse */
.btn-primary {
  background-size: 180% 100%;
  background-position: 0% 0;
  transition: transform 0.12s, box-shadow 0.2s, background-position 0.5s ease, opacity 0.2s;
}
.btn-primary:hover { background-position: 100% 0; }

/* Indicadores de carga */
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading .icon { opacity: 0; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-loading::after { border-color: rgba(8, 9, 19, 0.25); border-top-color: #080913; }
.search.is-loading::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

/* Check de éxito que se dibuja */
.success-icon { position: relative; }
.success-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ok);
  opacity: 0;
  animation: ring 0.9s 0.1s ease-out;
}
@keyframes ring { from { opacity: 0.6; transform: scale(0.8); } to { opacity: 0; transform: scale(1.7); } }
.success-icon .icon path { stroke-dasharray: 24; stroke-dashoffset: 0; animation: draw 0.45s 0.18s ease-out backwards; }
@keyframes draw { from { stroke-dashoffset: 24; } }

.stepper input.is-bumped { animation: bump 0.18s ease-out; }
@keyframes bump { 50% { transform: scale(1.14); } }

/* Cartel de stock bajo */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(251, 191, 36, 0.03));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.alert-banner:hover { border-color: rgba(251, 191, 36, 0.5); transform: translateY(-1px); }
.alert-banner-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.14);
  color: var(--warn);
}
.alert-banner-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.45); }
  70%, 100% { box-shadow: 0 0 0 12px rgba(251, 191, 36, 0); }
}
.alert-banner-body { display: grid; flex: 1; min-width: 0; }
.alert-banner-body .muted { font-size: 0.85rem; }
.alert-banner-arrow { display: grid; color: var(--warn); transition: transform 0.2s; }
.alert-banner:hover .alert-banner-arrow { transform: translateX(3px); }
.toolbar { scroll-margin-top: calc(var(--topbar-h) + 16px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}

/* ---------- Impresión de etiqueta ---------- */
@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; top: 0; left: 0; padding: 8mm; }
  .topbar, .toasts { display: none; }
}
