/* =====================================================================
   ScanUpp · Upper Logistics
   Identidad: #1C156D (principal), #F16522 (acento), #6DBC45 (éxito).
   Regla de uso:
   - Navy: navegación, encabezados, botones principales, foco.
   - Naranja: una llamada a la acción por pantalla (.btn-accent), indicador
     de sección activa, SKU padre activo y avisos.
   - Verde: confirmaciones, estados activos e indicadores positivos.
   El resto de la interfaz es blanco y grises neutros.
   ===================================================================== */

   :root {
  /* Marca */
  --brand: #1C156D;
  --brand-600: #160F5C;
  --brand-700: #100B47;
  --brand-50: #EFEEF8;
  --brand-100: #DEDCF1;
  --brand-200: #BEBAE3;
  --accent: #F16522;
  --accent-hover: #F37A40;
  --accent-50: #FEF2EB;
  --accent-200: #FBD0B8;
  --ink-900: #16132F;     /* texto principal: neutro con matiz navy */

  --bg: #F5F6F9;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --surface-3: #F2F4F7;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --text: #16132F;
  --text-2: #3B4256;
  --text-3: #5B6476;
  --text-4: #98A2B3;

  /* Estados (verde y naranja de la marca; rojo solo para errores) */
  --success: #6DBC45;
  --success-600: #4E9A2B;
  --success-700: #3D7A21;
  --success-50: #F1F8EC;
  --success-200: #CDE8BC;
  --success-text: #2E5E19;
  --warn: #F16522;
  --warn-600: #D9541A;
  --warn-50: #FEF2EB;
  --warn-200: #FBD0B8;
  --warn-text: #A33A0B;
  --danger: #E5483D;
  --danger-600: #D92D20;
  --danger-50: #FEF3F2;
  --danger-200: #FECDCA;
  --danger-text: #B42318;

  /* Forma */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Alturas de control: botones e inputs comparten medida. */
  --h-sm: 34px;
  --h-md: 42px;
  --h-lg: 50px;

  --shadow-xs: 0 1px 2px rgba(22, 19, 47, .05);
  --shadow-sm: 0 1px 3px rgba(22, 19, 47, .08), 0 1px 2px rgba(22, 19, 47, .04);
  --shadow-md: 0 6px 16px -6px rgba(22, 19, 47, .12);
  --shadow-lg: 0 18px 40px -14px rgba(22, 19, 47, .22);
  --ring: 0 0 0 3px rgba(28, 21, 109, .18);
  --ring-danger: 0 0 0 3px rgba(229, 72, 61, .16);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --topbar-h: 64px;
  --tabbar-h: 60px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
form { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
img { max-width: 100%; }
code, .mono { font-family: var(--font-mono); font-feature-settings: normal; }
:focus-visible { outline: none; box-shadow: var(--ring); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--brand); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; padding: 5px;
  background: #fff; border: 1px solid var(--border);
}
.brand-mark img { display: block; width: 100%; height: auto; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.02em; color: var(--brand); white-space: nowrap; }
.brand-name span { color: var(--accent); }
.brand-divider { width: 1px; height: 26px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.brand-company { display: block; height: 24px; width: auto; flex-shrink: 0; }
.brand-oscuro .brand-mark { border-color: transparent; }
.brand-oscuro .brand-name { color: #fff; }
.brand-oscuro .brand-divider { background: rgba(255, 255, 255, .2); }
/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 3px 0 var(--brand);   /* franja de marca */
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; height: var(--topbar-h);
  padding: 0 24px; display: flex; align-items: center; gap: 28px;
}

.nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.nav-link {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  color: var(--text-3); font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-3); }
.nav-link.is-active { color: var(--brand); font-weight: 600; background: var(--brand-50); }
.nav-link.is-active::after {
  content: ''; position: absolute; left: 12px; right: 12px; height: 3px; border-radius: 3px 3px 0 0;
  bottom: calc((var(--topbar-h) - 38px) / -2); background: var(--accent);
}

.user-menu { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-meta { text-align: right; line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11.5px; color: var(--text-3); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--brand); background: var(--brand-50);
}
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-3);
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { color: var(--danger-text); background: var(--danger-50); border-color: var(--danger-200); }


/* ---------- Página ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 28px 24px 56px; }
.page-narrow { max-width: 920px; }
.page-xs { max-width: 640px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--brand); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px;
}
.eyebrow .icon { color: var(--accent); }
.page-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -.025em; color: var(--text); }
.page-sub { color: var(--text-3); margin-top: 6px; font-size: 14px; max-width: 62ch; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); margin-bottom: 10px; min-width: 0; }
.breadcrumb a { color: var(--text-3); font-weight: 500; }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--text-4); }

/* ---------- Flash / alertas ---------- */
.flash { max-width: 1440px; margin: 0 auto; padding: 20px 24px 0; display: grid; gap: 10px; }
.flash:not(:has(.alert)) { display: none; }
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid;
  font-size: 14px; animation: slide-in .3s var(--ease);
}
.alert > .icon { margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; }
.alert-text { font-size: 13px; opacity: .9; margin-top: 2px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.alert-close { border: 0; background: transparent; padding: 2px; border-radius: 6px; color: inherit; opacity: .6; line-height: 0; }
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-50); border-color: var(--success-200); color: var(--success-text); }
.alert-success > .icon { color: var(--success-600); }
.alert-warn { background: var(--warn-50); border-color: var(--warn-200); color: var(--warn-text); }
.alert-danger { background: var(--danger-50); border-color: var(--danger-200); color: var(--danger-text); }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand); }
.alert.is-leaving { opacity: 0; transform: translateY(-6px); transition: all .3s var(--ease); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card-head { padding: 20px 22px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; color: var(--text); }
.card-title > .icon { color: var(--brand); }
.card-desc { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.card-body { padding: 20px 22px 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.card + .card { margin-top: 20px; }

.step {
  width: 24px; height: 24px; border-radius: 7px; display: inline-grid; place-items: center; flex-shrink: 0;
  font-size: 12px; font-weight: 700; background: var(--accent-50); color: var(--warn-text); font-family: var(--font-display);
}
.tile {
  width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0;
  background: var(--brand-50); color: var(--brand);
}
.tile-success { background: var(--success-50); color: var(--success-700); }
.tile-warn { background: var(--accent-50); color: var(--warn-600); }
.tile-ink { background: var(--brand); color: #fff; }
.tile-muted { background: var(--surface-3); color: var(--text-3); }

/* ---------- KPIs ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; display: flex; align-items: center; gap: 14px; min-width: 0;
}
.stat-label { font-size: 13px; color: var(--text-3); font-weight: 500; }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.stat-value.mono { font-family: var(--font-mono); font-size: 18px; letter-spacing: 0; }
.stat-value small { font-size: 13px; color: var(--text-3); font-weight: 500; font-family: var(--font); }

/* ---------- Botones ---------- */
.btn {
  --h: var(--h-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-primary:active:not(:disabled) { background: var(--brand-700); }
.btn-accent { background: var(--accent); color: var(--brand); }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-accent:focus-visible { box-shadow: 0 0 0 3px rgba(241, 101, 34, .28); }
.btn-dark { background: var(--brand-700); color: #fff; }
.btn-dark:hover:not(:disabled) { background: var(--brand); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #B5BCC8; color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-success { background: var(--success-700); color: #fff; }
.btn-success:hover:not(:disabled) { background: #336A1A; }
.btn-danger { background: var(--danger-600); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-text); }
.btn-danger-soft { background: var(--surface); color: var(--danger-text); border-color: var(--danger-200); }
.btn-danger-soft:hover:not(:disabled) { background: var(--danger-50); border-color: #FDA29B; }
/* Deshabilitado: gris explícito en vez de transparencia, se lee igual en todas las variantes. */
.btn:disabled, .btn.is-disabled {
  background: var(--surface-3); border-color: var(--border); color: var(--text-4);
  box-shadow: none; cursor: not-allowed;
}
.btn-ghost:disabled, .btn-ghost.is-disabled { background: transparent; border-color: transparent; }
.btn-sm { --h: var(--h-sm); padding: 0 12px; font-size: 13px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { --h: var(--h-lg); padding: 0 20px; font-size: 15px; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn-icon { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.96); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes flash-ok { from { box-shadow: 0 0 0 4px rgba(109, 188, 69, .45); } to { box-shadow: 0 0 0 0 rgba(109, 188, 69, 0); } }
@keyframes flash-bad { from { box-shadow: 0 0 0 4px rgba(229, 72, 61, .45); } to { box-shadow: 0 0 0 0 rgba(229, 72, 61, 0); } }
@keyframes pulse-dot { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--danger-text); }
.hint { font-size: 12.5px; color: var(--text-3); }
.error-text { font-size: 12.5px; color: var(--danger-text); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: var(--h-md); padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6476' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: #B5BCC8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input:disabled, .select:disabled, .input[readonly] { background: var(--surface-3); color: var(--text-3); }
.input:disabled, .select:disabled { cursor: not-allowed; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: var(--ring-danger); }
.input-lg { height: var(--h-lg); font-size: 16px; border-radius: var(--r-md); }
.input-group { position: relative; }
.input-group .input { padding-right: 48px; }
.input-group .input-addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-group .input-addon .btn { --h: 36px; padding: 0 10px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; }
.switch-row b { display: block; font-size: 14px; color: var(--text); }
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--border-strong); transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.switch input:checked + span { background: var(--success-600); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; background: var(--surface-3); border-radius: var(--r-md); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px; border-radius: var(--r-sm); font-weight: 600; font-size: 14px; color: var(--text-3); transition: background .15s, color .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: var(--ring); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.caps-warning { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--warn-text); font-weight: 500; }
.stack { display: grid; gap: 16px; }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-50); color: var(--success-text); border-color: var(--success-200); }
.badge-warn { background: var(--warn-50); color: var(--warn-text); border-color: var(--warn-200); }
.badge-danger { background: var(--danger-50); color: var(--danger-text); border-color: var(--danger-200); }
.badge-brand { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.badge-muted { background: var(--surface-3); color: var(--text-3); border-color: var(--border); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover, .table th a.is-sorted { color: var(--brand); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { display: inline-flex; vertical-align: middle; }
.table .actions > * + * { margin-left: 6px; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--text-3); }
.row-inactive td { color: var(--text-4); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.list-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.only-mobile { display: none; }

/* ---------- Toolbar / filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.toolbar .field { flex: 1 1 150px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.filters-toggle { display: none; }
.card-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.muted { color: var(--text-3); }

/* ---------- Paginación ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links span { min-width: 36px; height: 36px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 500; }
.pager-links a:hover { border-color: var(--brand-200); color: var(--brand); }
.pager-links .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-links .is-disabled { color: var(--text-4); background: var(--surface-2); }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: 44px 20px; display: grid; justify-items: center; gap: 8px; }
.empty .tile { width: 52px; height: 52px; border-radius: var(--r-lg); margin-bottom: 6px; }
.empty-title { font-weight: 600; font-size: 15px; color: var(--text); }
.empty-text { color: var(--text-3); font-size: 13.5px; max-width: 46ch; }
.empty .btn { margin-top: 10px; }

/* ---------- Conexión / sincronización ---------- */
.net-pill { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: var(--r-full); font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); white-space: nowrap; }
.net-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.net-pill.is-offline { background: var(--warn-50); border-color: var(--warn-200); color: var(--warn-text); }
.net-pill.is-offline .dot { background: var(--warn); animation: pulse-dot 1.4s infinite; }
.net-pill.is-syncing { color: var(--brand); border-color: var(--brand-100); background: var(--brand-50); }
.net-pill.is-syncing .dot { background: var(--brand); animation: pulse-dot 1s infinite; }
.offline-bar { display: none; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; background: var(--warn-50); color: var(--warn-text); border-bottom: 1px solid var(--warn-200); font-size: 13px; font-weight: 500; text-align: center; }
html.is-offline .offline-bar { display: flex; }
html.is-offline .needs-network { pointer-events: none; opacity: .5; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--brand-700); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; animation: slide-in .25s var(--ease); }
.toast.toast-danger { background: var(--danger-text); }
.toast.toast-success { background: var(--success-700); }
.toast.is-leaving { opacity: 0; transition: opacity .3s; }

/* ---------- Modal ---------- */
.modal { border: 0; padding: 0; border-radius: var(--r-lg); width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface); }
.modal::backdrop { background: rgba(16, 11, 71, .45); }
.modal[open] { animation: pop .2s var(--ease); }
.modal-body { padding: 22px; display: grid; gap: 10px; }
.modal-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.modal-text { color: var(--text-3); font-size: 14px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- Navegación móvil ---------- */
.tabbar { display: none; }
.more-sheet .modal-body { gap: 2px; padding: 10px; }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 10px 12px 12px; }
.sheet-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; background: transparent; border-radius: var(--r-md); color: var(--text-2); font-weight: 500; font-size: 15px; text-align: left; }
.sheet-link:hover, .sheet-link.is-active { background: var(--brand-50); color: var(--brand); }
.sheet-link .icon { color: var(--brand); }
.sheet-link.is-danger, .sheet-link.is-danger .icon { color: var(--danger-text); }
.sheet-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Escaneo ---------- */
.scan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.scan-layout > .card + .card, .scan-side > .card + .card { margin-top: 0; }
.scan-side { display: grid; gap: 20px; }
.scan-context { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--text-3); }
.scan-context b { color: var(--text); font-weight: 600; }
.scan-box { padding: 22px; display: grid; gap: 14px; }
.scan-input {
  height: 64px; font-size: 22px; font-family: var(--font-mono); letter-spacing: .02em;
  border: 2px solid var(--brand-200); border-radius: var(--r-lg); padding: 0 18px; background: #fff; width: 100%; color: var(--text);
}
.scan-input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.scan-input.flash-ok { animation: flash-ok .6s var(--ease); border-color: var(--success-600); }
.scan-input.flash-bad { animation: flash-bad .6s var(--ease); border-color: var(--danger); }
.scan-focus-hint { display: none; align-items: center; gap: 8px; font-size: 13px; color: var(--warn-text); font-weight: 500; border: 0; background: transparent; padding: 0; }
.scan-box.is-blurred .scan-focus-hint { display: flex; }
.progress { height: 12px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; display: flex; }
.progress-bar { height: 100%; background: var(--success); transition: width .3s var(--ease); }
.progress-bar.pending { background: var(--accent-200); }
.counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.counter { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.counter-label { font-size: 12px; color: var(--text-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--text); }
.counter.is-pending .counter-value { color: var(--warn-600); }
.counter.is-error .counter-value { color: var(--danger-text); }
.counter.is-ok .counter-value { color: var(--success-700); }
.last-read { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); min-height: 72px; }
.last-read.is-ok { background: var(--success-50); border-color: var(--success-200); }
.last-read.is-pending { background: var(--warn-50); border-color: var(--warn-200); }
.last-read.is-bad { background: var(--danger-50); border-color: var(--danger-200); }
.last-read .tile { background: var(--surface); }
.last-read-body { min-width: 0; flex: 1; }
.last-read-serial { font-family: var(--font-mono); font-size: 18px; font-weight: 600; word-break: break-all; color: var(--text); }
.last-read-meta { font-size: 13px; color: var(--text-2); }
.reads { max-height: 460px; overflow-y: auto; }
.read-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.read-row:last-child { border-bottom: 0; }
.read-serial { font-family: var(--font-mono); font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-meta { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-idx { font-size: 12px; color: var(--text-4); font-variant-numeric: tabular-nums; min-width: 28px; }
.read-row.is-error { background: var(--danger-50); }
.scan-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.scan-actions .btn { flex: 1 1 auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 600; color: var(--text); text-align: right; overflow-wrap: anywhere; }

/* ---------- Dashboard ---------- */
.stat-delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; margin-top: 2px; }
.stat-delta.up { color: var(--success-700); }
.stat-delta.down { color: var(--danger-text); }
.stat-delta.flat { color: var(--text-3); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.grid-2 > .card + .card { margin-top: 0; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; }
.bars-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars-bar { width: 100%; max-width: 36px; background: var(--brand-200); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars-col:last-child .bars-bar, .bars-col:hover .bars-bar { background: var(--brand); }
.bars-label { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.bars-value { font-size: 11px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hbars { display: grid; gap: 14px; }
.hbar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; color: var(--text-2); }
.hbar-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-head span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.hbar-track { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: var(--r-full); background: var(--brand); }

/* ---------- Login (pantalla dividida) ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside {
  position: relative; overflow: hidden; color: #fff; padding: 44px 52px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  background: var(--brand);
}
.auth-aside .brand-name { font-size: 19px; }
.auth-aside .brand-mark { width: 42px; height: 42px; }
.auth-headline { font-family: var(--font-display); font-size: clamp(32px, 3.3vw, 48px); font-weight: 600; line-height: 1.08; letter-spacing: -.03em; margin: 0 0 18px; max-width: 15ch; }
.auth-headline em { font-style: normal; color: var(--accent); }
.auth-lead { color: rgba(255, 255, 255, .78); font-size: 15px; margin-top: 14px; max-width: 46ch; }

.auth-rule { display: flex; gap: 6px; margin-bottom: 26px; }
.auth-rule i { display: block; height: 4px; border-radius: 4px; }
.auth-rule i:nth-child(1) { width: 40px; background: var(--accent); }
.auth-rule i:nth-child(2) { width: 14px; background: var(--success); }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; max-width: 440px; }
.feature { display: flex; gap: 14px; align-items: center; }
.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: #fff; }
.feature strong { display: block; font-size: 14px; font-weight: 600; }
.feature span { font-size: 13px; color: rgba(255, 255, 255, .7); }
.auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12px; color: rgba(255, 255, 255, .7); border-top: 1px solid rgba(255, 255, 255, .14); padding-top: 22px; }
.auth-foot span { display: inline-flex; align-items: center; gap: 6px; }
.auth-foot .icon { color: var(--success); }

.auth-features { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-features li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; color: rgba(255, 255, 255, .86); }
.auth-features b { color: #fff; }
.auth-features .tile { width: 34px; height: 34px; background: rgba(255, 255, 255, .1); color: var(--accent); }
.auth-aside-foot { font-size: 12.5px; color: rgba(255, 255, 255, .6); }
.auth-main { display: flex; flex-direction: column; padding: 32px 24px; gap: 24px; }
.auth-card { width: 100%; max-width: 400px; margin: auto; display: grid; gap: 22px; }
.auth-logo { height: 44px; width: auto; }
.auth-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.auth-sub { color: var(--text-3); margin-top: 4px; }
.auth-help { font-size: 13px; color: var(--text-3); text-align: center; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.auth-trust { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.auth-trust .icon { width: 15px; height: 15px; color: var(--brand); }
.auth-legal { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-4); text-align: center; }



/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .scan-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .topbar-inner { gap: 16px; }
  .user-meta { display: none; }
}
@media (max-width: 1024px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .scan-layout { grid-template-columns: 1fr; }
  .scan-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
/* Teléfonos, handhelds y tablets en vertical: barra inferior de pestañas. */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .topbar .nav, .topbar .user-chip, .topbar .logout-form { display: none; }
  .brand-divider, .brand-company { display: none; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px -8px rgba(22, 19, 47, .12);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--text-3); border: 0; background: transparent; position: relative; min-width: 0; padding: 0 2px; }
  .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab .icon { width: 22px; height: 22px; }
  .tab.is-active { color: var(--brand); }
  .tab.is-active::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .page { padding: 18px 16px 32px; }
  .flash { padding: 14px 16px 0; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head > .btn, .page-head > div:last-child:not(:first-child) .btn { flex: 1; }
  .page-title { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 16px; }
  .card-foot, .card-section-head, .pager { padding: 12px 16px; }
  .toolbar { padding: 14px 16px; }
  .only-desktop { display: none !important; }
  .only-mobile { display: block; }
  .filters-toggle { display: inline-flex; }
  .toolbar.is-collapsible:not(.is-open) .field, .toolbar.is-collapsible:not(.is-open) .toolbar-actions { display: none; }
  .toolbar .field { flex-basis: 100%; }
  .toolbar-actions { width: 100%; margin-left: 0; }
  .toolbar-actions .btn { flex: 1; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-side { grid-template-columns: 1fr; }
  .scan-box { padding: 16px; }
  .scan-input { height: 58px; font-size: 19px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat .tile { display: none; }
  .stat-value { font-size: 20px; }
  .toasts { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
  .btn { --h: 46px; }
  .btn-sm { --h: 38px; }
  .input, .select { height: 46px; font-size: 16px; }
  .form-actions .btn { flex: 1; }
  .modal-foot .btn { flex: 1; }
}
@media (max-width: 380px) {
  .counter-value { font-size: 20px; }
  .tab { font-size: 10px; }
}

/* ---------- Revisión de escaneos ---------- */
.review-counters { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 20px; }
.review-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 440px); }
.review-context { gap: 12px 14px; }
.review-sync { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--warn-text); background: var(--warn-50); border: 1px solid var(--warn-200); border-radius: var(--r-md); padding: 8px 12px; }
.review-sync .icon { vertical-align: -2px; }
.review-findings { max-height: 640px; overflow-y: auto; }
.finding { padding: 14px 18px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
.finding:last-child { border-bottom: 0; }
.finding.is-closed { background: var(--surface-2); }
.finding-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.finding-serial { font-weight: 600; color: var(--text); word-break: break-all; }
.finding-text { font-size: 13.5px; color: var(--text-2); }
.finding-meta { font-size: 12px; color: var(--text-3); }
.finding-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.segmented-sm { gap: 4px; padding: 3px; }
/* Cada almacén registra cuántas áreas quiera: el selector pasa a filas. */
.segmented-wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.segmented-sm span { height: 30px; padding: 0 10px; font-size: 13px; }
.list-item.row-inactive .list-item-title { color: var(--text-4); text-decoration: line-through; }
.review-ot { flex-wrap: wrap; }
.review-ot-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.modal-wide { width: min(600px, calc(100vw - 32px)); }
.modal-wide .modal-body { max-height: calc(100dvh - 160px); overflow-y: auto; }
.review-kv { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.choice-list { display: grid; gap: 8px; }
.choice-list-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice > span { display: grid; gap: 2px; padding: 10px 12px 10px 38px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color .15s, background .15s; height: 100%; }
.choice > span::before { content: ''; position: absolute; left: 13px; top: 13px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.choice b { font-size: 14px; color: var(--text); }
.choice input:checked + span { border-color: var(--brand); background: var(--brand-50); }
.choice input:checked + span::before { border: 5px solid var(--brand); }
.choice input:focus-visible + span { box-shadow: var(--ring); }
.check-grid { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.zone-row { display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr) auto auto auto; gap: 10px 12px; align-items: end; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.zone-row.zone-new { border-bottom: 0; padding-bottom: 0; }
.zone-active { min-height: var(--h-md); }
.zone-error { grid-column: 1 / -1; }
@media (max-width: 1180px) {
  .review-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 380px); }
}
@media (max-width: 1024px) {
  .review-layout { grid-template-columns: 1fr; }
  .review-counters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .review-counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-findings { max-height: none; }
  .only-desktop-inline { display: none; }
  .review-ot-badges { width: 100%; justify-content: flex-start; order: 3; }
  .review-ot .btn { order: 2; }
  .choice-list-row { grid-template-columns: 1fr; }
  .zone-row { grid-template-columns: 1fr 1fr; }
  .zone-row .btn { grid-column: 1 / -1; }
  .finding { padding: 12px 16px; }
}
