/* =====================================================================
   MovingUpper · 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 ----------
   Misma altura que los inputs (--h-*), mismo radio y peso en todas las variantes.
   Jerarquía: accent (CTA de la página) > primary > secondary > ghost. */
.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; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field + .field, .field + .field-row, .field-row + .field { margin-top: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row > .field, .field-stack > .field { margin-top: 0; }
.field-stack { display: grid; gap: 18px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.label .optional { font-weight: 400; color: var(--text-4); }
.hint { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12px; color: var(--danger-text); display: flex; align-items: center; gap: 5px; }
.field-error .icon { width: 13px; height: 13px; }

.control { position: relative; }
.control > .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-4); pointer-events: none; transition: color .15s;
}
.control:focus-within > .icon { color: var(--brand); }
.input {
  width: 100%; height: var(--h-md); padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 14px; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--text-4); }
.input:hover:not(:disabled):not(:focus) { border-color: #B5BCC8; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input:disabled { background: var(--surface-3); color: var(--text-4); border-color: var(--border); cursor: not-allowed; }
.control > .icon ~ .input, .control .input.has-icon { padding-left: 40px; }
.control .input.has-action { padding-right: 46px; }
.input-lg { height: var(--h-lg); font-size: 16px; border-radius: var(--r-md); }
.input-mono { font-family: var(--font-mono); letter-spacing: .02em; }
.input.is-invalid { border-color: var(--danger); background: #FFFBFA; }
.input.is-invalid:focus { box-shadow: var(--ring-danger); }
select.input {
  padding-right: 38px; cursor: pointer;
  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 12px center; background-size: 16px;
}
.control-action {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-3);
}
.control-action:hover { background: var(--surface-3); color: var(--text); }
.kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
  padding: 3px 7px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border);
}
.input:disabled ~ .kbd { opacity: .4; }
.control:has(.kbd) .input { padding-right: 44px; text-overflow: ellipsis; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text-2); user-select: none; }
.checkbox {
  -webkit-appearance: none; appearance: none; margin: 0; flex-shrink: 0;
  width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; transition: all .15s;
}
.checkbox::after {
  content: ''; width: 10px; height: 10px; transform: scale(0); transition: transform .15s var(--ease);
  background: #fff; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.checkbox:checked { background: var(--brand); border-color: var(--brand); }
.checkbox:checked::after { transform: scale(1); }

.switch-row { display: flex; align-items: center; 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 strong { display: block; font-size: 14px; font-weight: 600; }
.switch-row span { font-size: 12px; color: var(--text-3); }
.switch {
  -webkit-appearance: none; appearance: none; margin: 0; flex-shrink: 0;
  width: 42px; height: 24px; border-radius: var(--r-full); background: var(--border-strong);
  position: relative; cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(22, 19, 47, .2); transition: transform .2s var(--ease);
}
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(18px); }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-4); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.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;
  background: var(--brand-50); color: var(--brand);
}
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.badge-warn { background: var(--accent-50); color: var(--warn-text); }
.badge-success { background: var(--success-50); color: var(--success-text); }
.badge-success .dot { background: var(--success); }
.badge-dark { background: var(--brand); color: #fff; }
.badge-danger { background: var(--danger-50); color: var(--danger-text); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty { text-align: center; padding: 44px 20px; }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.empty-title { font-weight: 600; font-size: 15px; color: var(--text); }
.empty-text { color: var(--text-3); font-size: 13px; margin: 4px auto 0; max-width: 38ch; }

.workspace { display: grid; grid-template-columns: minmax(360px, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.sticky-col { position: sticky; top: calc(var(--topbar-h) + 20px); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: var(--r-md); border: 1px solid var(--border); }
.segmented form { display: flex; }
.segmented-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; border: 0; border-radius: 7px; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--text-3); transition: background .15s, color .15s;
}
.segmented-btn:hover { color: var(--text); }
.segmented-btn.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

/* SKU padre activo: estado destacado con el acento naranja. */
.active-sku {
  position: relative; margin-top: 18px; padding: 16px; border-radius: var(--r-md);
  background: var(--accent-50); border: 1px solid var(--accent-200); border-left: 4px solid var(--accent);
}
.active-sku-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn-text); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: relative; }
.live-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: pulse 1.8s var(--ease) infinite; }
.active-sku-code { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--brand); margin: 8px 0 10px; word-break: break-all; padding-right: 64px; }
.active-sku-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--warn-text); }
.active-sku-meta span { display: inline-flex; align-items: center; gap: 5px; }
.active-sku-meta .icon { width: 13px; height: 13px; }
.active-sku-count { position: absolute; right: 16px; bottom: 14px; text-align: right; }
.active-sku-count b { display: block; font-family: var(--font-display); font-size: 28px; line-height: 1; color: var(--brand); }
.active-sku-count small { font-size: 11px; color: var(--warn-text); font-weight: 600; }

.pallets { display: grid; gap: 16px; }
.pallet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); transition: border-color .15s, box-shadow .15s; overflow: hidden; }
.pallet:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.pallet-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.pallet-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.pallet-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.pallet-head .badge { margin-left: auto; }
.pallet-body { padding: 0 18px 14px; display: grid; gap: 8px; }
.pallet-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.pallet-foot .spacer { flex: 1; }

.line { border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 13px; background: var(--surface); }
.line-parent { border-left: 3px solid var(--accent); }
.line-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--brand); }
.line-desc { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.line-top .badge { margin-left: auto; }
.dest { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-family: var(--font-mono); font-size: 11.5px; padding: 3px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.line-note { font-size: 12px; color: var(--warn-text); margin-top: 8px; font-style: italic; }
.line-simple { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.line-simple .line-desc { flex: 1; min-width: 120px; }

.empty-pallets { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; color: var(--text); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3); letter-spacing: .05em; text-transform: uppercase;
  padding: 11px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 14px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table td b, .table td strong { color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: #FAFAFD; }
.table .num { color: var(--text-4); font-variant-numeric: tabular-nums; width: 1%; }
.table .actions { text-align: right; width: 1%; white-space: nowrap; }
.table td.actions .btn-group { flex-wrap: nowrap; justify-content: flex-end; }
.table .nowrap { white-space: nowrap; }
.person { display: flex; align-items: center; gap: 12px; }
.person-name { font-weight: 600; color: var(--text); }
.person-mail { font-size: 13px; color: var(--text-3); }
.is-inactive .avatar { background: var(--surface-3); color: var(--text-4); }
.is-inactive .person-name { color: var(--text-3); }

.toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .control { flex: 1; max-width: 340px; min-width: 200px; }
.toolbar-count { font-size: 13px; color: var(--text-3); margin-left: auto; }
.toolbar-count b { color: var(--text); }

.print-layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.action-list { display: grid; gap: 8px; }
.status-box { margin-top: 12px; min-height: 0; font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; }
.status-box:empty { display: none; }
.note { display: flex; gap: 10px; font-size: 12.5px; color: var(--text-3); padding: 14px; background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--border); margin-top: 18px; line-height: 1.55; }
.note .icon { color: var(--brand); margin-top: 1px; }
.preview-canvas {
  border-radius: var(--r-md); padding: 36px 20px; display: flex; justify-content: center;
  background-color: var(--surface-3);
  background-image: radial-gradient(#D5DAE1 1px, transparent 1px);
  background-size: 18px 18px; border: 1px solid var(--border);
}
#zonaImpresion { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.etiqueta-hoja { margin: 0; text-align: center; }
/* En pantalla se amplía para revisarla; al imprimir usa su tamaño físico (ver etiquetas/show). */
.etiqueta-svg { display: block; width: 520px; max-width: 100%; height: auto; background: #fff; box-shadow: var(--shadow-lg); border-radius: 4px; }
.etiqueta-hoja figcaption { font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* ---------- Consulta pública (QR) ---------- */
.public-top { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: inset 0 3px 0 var(--brand); }
.public-top .topbar-inner { height: 60px; }
.public-top .badge { margin-left: auto; }
.public-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.public-hero .tile { width: 52px; height: 52px; border-radius: 14px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.meta-item { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); min-width: 0; }
.meta-item span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.meta-item span .icon { width: 13px; height: 13px; }
.meta-item b { display: block; font-size: 16px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.site-foot { text-align: center; font-size: 12px; color: var(--text-3); padding: 24px 16px 32px; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.site-foot img { height: 16px; width: auto; }

/* ---------- Login ---------- */
.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-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-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 400px; animation: rise .4s var(--ease); }
.auth-company { display: block; height: 44px; width: auto; margin-bottom: 36px; }
.auth-mobile-brand { display: none; margin-bottom: 28px; }
.auth-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -.03em; color: var(--text); }
.auth-sub { color: var(--text-3); margin: 8px 0 28px; font-size: 15px; }
.auth-form .field + .field { margin-top: 18px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 24px; }
.auth-help { font-size: 13px; color: var(--text-3); }
.caps { display: none; font-size: 12px; color: var(--warn-text); align-items: center; gap: 5px; }
.caps.is-on { display: flex; }
.caps .icon { width: 13px; height: 13px; }
.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; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* La barra se queda con la marca del sistema; el logo de empresa vuelve en el login y la consulta pública. */
  .topbar .brand-divider, .topbar .brand-company { display: none; }
}
@media (max-width: 1024px) {
  .workspace, .print-layout { grid-template-columns: 1fr; }
  .sticky-col { position: static; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-company { display: none; }
  .auth-mobile-brand { display: flex; }
}
@media (max-width: 760px) {
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .user-meta { display: none; }
  .page { padding: 20px 16px 40px; }
  .flash { padding: 16px 16px 0; }
  .page-title { font-size: 24px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat .tile { width: 34px; height: 34px; }
  .stat-value { font-size: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .card-head { padding: 18px 18px 0; }
  .card-body { padding: 18px; }
  .person-mail { word-break: break-all; }

  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-size: 12px; color: var(--text-3); font-weight: 500; text-align: left; flex-shrink: 0; }
  .table-stack td.num, .table-stack td.actions { width: 100%; }
  .table-stack tbody tr:hover td { background: transparent; }
  .table-stack td .chips { justify-content: flex-end; }
}

@media print {
  body * { visibility: hidden; }
  #zonaImpresion, #zonaImpresion * { visibility: visible; }
  #zonaImpresion { position: absolute; top: 0; left: 0; display: block; }
  .preview-canvas { background: none; border: 0; padding: 0; }
  .etiqueta-hoja { break-after: page; }
  .etiqueta-hoja figcaption { display: none; }
  .etiqueta-svg { box-shadow: none; border-radius: 0; }
}

/* ===== Guardar tarima e Historial ===== */
.guardar-wrap { display: inline-flex; }
.guardar-wrap .btn:disabled { pointer-events: none; } /* el tooltip lo muestra el contenedor */
.guardar-wrap[title] { cursor: not-allowed; }
.pallet.is-leaving { opacity: 0; transform: scale(.98); transition: opacity .3s var(--ease), transform .3s var(--ease); }

/* Filtros: zona gris propia, separada de los resultados. */
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: end; padding: 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.filters .field { margin-top: 0; }
.filters-actions { display: flex; gap: 8px; }
.filters-active { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-page, .pager-gap { min-width: 34px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: var(--r-sm); font-size: 13px; color: var(--text-2); text-decoration: none; }
.pager-page:hover { background: var(--surface-3); color: var(--text); }
.pager-page.is-current { background: var(--brand); color: #fff; font-weight: 600; }
.pager .is-disabled { pointer-events: none; }

@media (max-width: 1024px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters-actions { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr; }
  .filters-actions .btn { flex: 1; }
}

/* ===== Impresión Zebra ===== */
.status-box[data-tipo="ok"] { background: var(--success-50); border-color: var(--success-200); color: var(--success-text); }
.status-box[data-tipo="error"] { background: var(--danger-50); border-color: var(--danger-200); color: var(--danger-text); }
.status-box[data-tipo="aviso"] { background: var(--warn-50); border-color: var(--warn-200); color: var(--warn-text); }
.verify-box { margin-top: 12px; padding: 12px; border: 1px solid var(--brand-100); background: var(--brand-50); border-radius: var(--r-sm); }
.verify-title { font-weight: 600; font-size: 14px; color: var(--brand); }
.verify-text { font-size: 12px; color: var(--text-3); margin: 2px 0 10px; }


/* Pantallas táctiles de cualquier tamaño: objetivos más grandes. Inputs y botones suben juntos. */
@media (pointer: coarse) {
  :root { --h-sm: 40px; --h-md: 44px; }
  .segmented-btn { height: 44px; }
  .control-action { width: 40px; height: 40px; right: 2px; }
  .icon-btn, .nav-link { min-height: 40px; min-width: 40px; }
  .pager-page, .pager-gap { min-width: 40px; height: 40px; }
  .checkbox { width: 22px; height: 22px; }
  .alert-close { padding: 8px; margin: -6px -6px -6px 0; }
}

@media (max-width: 760px) {
  /* 16 px evita que el navegador haga zoom al enfocar un campo. */
  .input { font-size: 16px; }
  .label { flex-wrap: wrap; row-gap: 2px; }
  .card-head { flex-wrap: wrap; }
  .card-head > div { min-width: 0; flex: 1 1 200px; }

  /* Login: arriba, para que el teclado no tape los campos. */
  .auth-main { align-items: flex-start; padding: 32px 20px; }
  .auth-mobile-brand { margin-bottom: 24px; }
  .auth-title { font-size: 26px; }
  .auth-sub { margin-bottom: 22px; }

  /* Tarimas: acciones en rejilla de dos columnas; Guardar ocupa toda la fila. */
  .pallet-head { padding: 14px; gap: 12px; }
  .pallet-body { padding: 0 14px 12px; }
  .pallet-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px; }
  .pallet-foot .spacer { display: none; }
  .pallet-foot > *, .pallet-foot form, .pallet-foot .btn { width: 100%; }
  .pallet-foot .guardar-wrap { grid-column: 1 / -1; }
  .empty-pallets .btn-group { margin-left: 0 !important; width: 100%; }

  /* Formularios con pie: acción principal arriba y a lo ancho. */
  .card-foot { flex-direction: column-reverse; align-items: stretch; }
  .card-foot .btn { width: 100%; }

  /* Tabla apilada: la celda principal se lee de corrido, sin rótulo. */
  .table-stack td.cell-person { display: block; text-align: left; padding-bottom: 8px; }
  .table-stack td.cell-person::before { display: none; }
  .table-stack td.actions { justify-content: flex-end; padding-top: 10px; }
  .table-stack td.actions::before { display: none; }
  .table-stack td.actions .btn-group { width: 100%; flex-wrap: wrap; }
  .table-stack td.actions .btn-group > * { flex: 1; }
  .table-stack td.actions .btn { width: 100%; }
  .person-mail { word-break: normal; overflow-wrap: anywhere; }

  /* Detalle público (QR): una pieza por tarjeta compacta. */
  .table-piezas tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; padding: 12px 16px; }
  .table-piezas td { display: block; padding: 0; text-align: left; width: auto; }
  .table-piezas td::before { display: none; }
  .table-piezas td.c-num { grid-row: 1 / span 3; width: auto; font-size: 13px; padding-top: 2px; }
  .table-piezas .c-sku { grid-column: 2; }
  .table-piezas .c-hora { grid-column: 3; grid-row: 1; font-size: 12px; }
  .table-piezas .c-ns { grid-column: 2 / -1; }
  .table-piezas .c-desc { grid-column: 2 / -1; font-size: 13px; color: var(--text-3); }
  .table-piezas .c-ns .mono { font-size: 14px !important; font-weight: 600; }
  .meta-grid .meta-item:nth-child(3):last-child { grid-column: 1 / -1; }
}

/* Handheld: pantalla angosta. Se prioriza el campo de escaneo. */
@media (max-width: 560px) {
  .page { padding: 16px 12px 32px; }
  .flash { padding: 12px 12px 0; }
  .page-head { margin-bottom: 16px; gap: 12px; align-items: center; }
  .page-head .eyebrow, .page-head .page-sub { display: none; }
  .page-head > .btn, .page-head > form, .page-head > form .btn { flex: 1 0 auto; }
  .page-title { font-size: 22px; }
  .breadcrumb { margin-bottom: 6px; }

  .stats { gap: 8px; margin-bottom: 16px; }
  .stat-opcional { display: none; }
  .stat { padding: 12px; gap: 10px; }
  .stat .tile { width: 32px; height: 32px; border-radius: 9px; }
  .stat .tile .icon { width: 16px; height: 16px; }
  .stat-label { font-size: 12px; }
  .stat-value { font-size: 20px; }
  .stat-value small { display: none; }

  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 16px; }
  .card-foot { padding: 12px 16px; }
  .workspace { gap: 16px; }
  .divider { margin: 18px 0; }
  .active-sku { padding: 14px; }
  .active-sku-code { font-size: 20px; }

  .line { padding: 10px 11px; }
  .line-top .badge { margin-left: 0; }
  .chip { font-size: 12px; padding: 4px 8px; }

  .toolbar { padding: 12px 14px; }
  .toolbar .control { min-width: 0; max-width: none; }
  .filters { padding: 14px; }
  .pager { justify-content: center; padding: 12px 14px; }
  .pager > .btn { flex: 1; }
  .pager-pages { order: -1; width: 100%; justify-content: center; }

  .preview-canvas { padding: 16px 10px; }
  .note { padding: 12px; }
}

/* Handheld más angosto (320–400 px): barra superior solo con íconos. */
@media (max-width: 400px) {
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .user-menu { gap: 8px; }
  .public-top .badge { display: none; }
  .auth-mobile-brand .brand-company { height: 20px; }
}

/* ===== Manuales ===== */
.manual-row { display: flex; align-items: center; gap: 12px; min-width: 0; text-align: left; }
.manual-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.35; overflow-wrap: anywhere; }
.manual-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.manuales-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.manual-card {
  display: flex; flex-direction: column; gap: 18px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  transition: border-color .15s, box-shadow .15s;
}
.manual-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.manual-card .manual-row { align-items: flex-start; }
.manual-card .manual-title { font-size: 15px; margin: 0; }
.manual-card .manual-meta { margin: 4px 0 0; }
.manual-card-foot { display: flex; gap: 8px; margin-top: auto; }
.manual-card-foot .btn-primary { flex: 1 1 auto; }

.file-current {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.file-drop {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 18px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.file-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop:hover, .file-drop.is-dragover { border-color: var(--brand); background: var(--brand-50); }
.file-drop:focus-within { box-shadow: var(--ring); border-color: var(--brand); }
.file-drop.has-file { border-style: solid; border-color: var(--success-200); background: var(--success-50); }
.file-drop.has-file .tile { background: #fff; color: var(--success-700); }
.file-drop.is-invalid { border-color: var(--danger-200); background: var(--danger-50); }
.file-drop-text { min-width: 0; }
.file-drop-text strong { display: block; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.file-drop-text span { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.file-drop.has-file .file-drop-text span { color: var(--success-text); }
.file-drop.is-invalid .file-drop-text span { color: var(--danger-text); }

.option-cards { display: grid; gap: 10px; }
.option-card {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.option-card:hover { border-color: var(--border-strong); }
.option-card:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.option-card input {
  -webkit-appearance: none; appearance: none; flex-shrink: 0; margin: 2px 0 0;
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.option-card input::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); transform: scale(0); transition: transform .15s; }
.option-card input:checked { border-color: var(--brand); }
.option-card input:checked::after { transform: scale(1); }
.option-card input:focus-visible { box-shadow: var(--ring); }
.option-text { flex: 1; min-width: 0; }
.option-text strong { display: block; font-size: 14px; color: var(--text); }
.option-text span { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.option-roles { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.option-card:has(input:checked) .option-roles .badge { background: #fff; color: var(--brand); }

@media (max-width: 760px) {
  .option-roles { display: none; }
  .manual-card-foot { flex-direction: column; }
  /* En la tabla apilada, el manual se lee completo arriba, sin rótulo. */
  .table-stack td.cell-manual { display: block; text-align: left; padding-bottom: 8px; }
  .table-stack td.cell-manual::before { display: none; }
}


/* ===== Diálogo de motivo ===== */
.dialog {
  width: min(440px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface);
}
.dialog::backdrop { background: rgba(22, 19, 47, .45); }
.dialog form { padding: 20px; }
.dialog-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.dialog-text { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.dialog-campo { height: auto; padding: 10px 14px; resize: vertical; margin-top: 6px; line-height: 1.4; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ===== Escaneo ===== */
/* El botón de teclado solo tiene sentido en pantallas táctiles. */
.control-teclado { display: none; }
.control-teclado.is-on { color: var(--brand); background: var(--brand-50); }
.scan-estado { font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid; overflow-wrap: anywhere; }
.scan-estado[data-tipo="ok"] { background: var(--success-50); border-color: var(--success-200); color: var(--success-text); }
.scan-estado[data-tipo="error"] { background: var(--danger-50); border-color: var(--danger-200); color: var(--danger-text); }
.scan-flash-ok { animation: scan-ok .6s var(--ease); }
.scan-flash-error { animation: scan-error .45s var(--ease); }
@keyframes scan-ok { 0% { box-shadow: 0 0 0 4px rgba(109, 188, 69, .55); border-color: var(--success); } 100% { box-shadow: none; } }
@keyframes scan-error { 0%, 50% { transform: translateX(-4px); } 25%, 75% { transform: translateX(4px); } 100% { transform: none; } }
.chip-nuevo { animation: slide-in .3s var(--ease); background: var(--success-50); border-color: var(--success-200); color: var(--success-text); }
.chips-mas { margin-top: 10px; }
.chips-mas summary { font-size: 12px; font-weight: 600; color: var(--brand); cursor: pointer; padding: 4px 0; }
.chips-mas .chips { margin-top: 6px; }

@media (pointer: coarse) {
  .control-teclado { display: grid; }
  .control:has(.control-teclado) .kbd { display: none; }
  .control:has(.control-teclado) .input { padding-right: 48px; }
}

/* ===== Handheld ===== */
@media (max-width: 760px) {
  .dialog-actions .btn { flex: 1; }
}
@media (max-width: 560px) {
  /* El campo de escaneo es lo más importante de la pantalla. */
  .input-lg { height: 54px; font-size: 18px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 10px 12px; }
  .stat .tile { display: none; }
  .stat-value { font-size: 19px; }
  .active-sku { margin-top: 14px; }
  .active-sku-count b { font-size: 32px; }
  .pallet-title { font-size: 16px; }
}

/* App instalada: respeta la barra de gestos de Android. */
@media (display-mode: standalone) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* Handheld: el campo que se escanea y su resultado quedan siempre a la vista,
   sin que el título, los contadores o la tarjeta del SKU activo los empujen
   fuera de la pantalla. */
@media (max-width: 560px) {
  .page-head { flex-wrap: nowrap; }
  .page-head > form { flex: 0 0 auto; }
  .page-head > form .btn { flex: 0 0 auto; height: var(--h-sm); padding: 0 12px; font-size: 13px; }
  .page-title { font-size: 20px; }

  .stats { gap: 6px; margin-bottom: 12px; }
  .stat { padding: 8px 12px; }
  .stat > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; }
  .stat-value { font-size: 17px; }

  .card-captura .card-head { padding-top: 12px; }
  .card-captura .card-desc { display: none; }
  .card-captura .card-body { display: flex; flex-direction: column; padding-top: 12px; }
  .card-captura .card-body > .divider { display: none; }
  /* Con SKU padre activo: el campo de N/S sube justo debajo del modo. */
  .card-captura .card-body:has(.active-sku) > * { order: 3; }
  .card-captura .card-body:has(.active-sku) > .segmented { order: 0; }
  .card-captura .card-body:has(.active-sku) > form[data-escaneo-ns] { order: 1; margin-top: 14px; }
  .card-captura .card-body:has(.active-sku) > .active-sku { order: 2; }
  /* Sin SKU padre activo, el campo de N/S deshabilitado solo estorba. */
  .card-captura .card-body:not(:has(.active-sku)) > form[data-escaneo-ns] { display: none; }

  /* "Vaciar" con borde para que no se vea suelto junto a los demás botones. */
  .pallet-foot .btn-ghost { border-color: var(--border-strong); }
}

/* ===== Corregir tarima ===== */
.table-partidas tr.is-marcada td { background: var(--success-50); }
.table-partidas tr:has(.checkbox:checked) td { background: var(--brand-50); }
@media (max-width: 760px) {
  /* Cada pieza en una fila compacta: casilla a la izquierda, datos a la derecha. */
  .table-partidas tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; align-items: center; }
  .table-partidas td { display: block; padding: 0; text-align: left; width: auto; }
  .table-partidas td::before { display: none; }
  .table-partidas td.c-check { grid-row: 1 / span 3; }
  .table-partidas td:nth-child(2) { grid-column: 3; grid-row: 1; font-size: 12px; color: var(--text-3); }
  .table-partidas td:nth-child(3) { grid-column: 2; grid-row: 1; }
  .table-partidas td:nth-child(4) { grid-column: 2 / -1; font-weight: 600; }
  .table-partidas td:nth-child(5) { grid-column: 2 / -1; font-size: 13px; color: var(--text-3); }
}

/* ===== Navegación =====
   Computadora: secciones con texto y "Más" para administración.
   Laptop chica / tablet: solo íconos (el nombre aparece al pasar el mouse).
   Celular y handheld: pestañas abajo, al alcance del pulgar; lo demás en "Más". */
.nav-contador {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; line-height: 1;
}
.nav-solo-movil, .nav-mas-solo-movil { display: none; }
.nav-mas { position: relative; }
.nav-mas > summary { list-style: none; cursor: pointer; user-select: none; }
.nav-mas > summary::-webkit-details-marker { display: none; }
.nav-mas[open] > summary { color: var(--text); background: var(--surface-3); }
.nav-mas-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 50; min-width: 220px; padding: 6px;
  display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); animation: slide-in .15s var(--ease);
}
.nav-mas-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 500; font-size: 14px; white-space: nowrap;
}
.nav-mas-link:hover { background: var(--surface-3); color: var(--text); }
.nav-mas-link.is-active { color: var(--brand); background: var(--brand-50); font-weight: 600; }
.nav-mas-link .nav-contador { margin-left: auto; }
.nav-mas-usuario { display: none; }
.nav-mas-link.nav-solo-movil, .nav-contador.nav-solo-movil { display: none; }

.mudanza-franja {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 16px;
  font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--border);
  background: var(--accent-50); color: var(--warn-text);
}
.mudanza-franja.is-captura { background: var(--success-50); color: var(--success-text); }
.mudanza-franja-texto { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1320px) {
  .topbar-inner { gap: 20px; }
  .topbar .user-meta { display: none; }
}
@media (min-width: 761px) and (max-width: 1120px) {
  .nav-texto { display: none; }
  .nav-link { padding: 0 11px; }
  .nav-link .nav-contador { position: absolute; top: 2px; right: 0; }
}
@media (max-width: 760px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; gap: 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 18px rgba(22, 19, 47, .07);
  }
  .nav > .nav-link, .nav-mas { flex: 1 1 0; min-width: 0; height: var(--tabbar-h); }
  .nav .nav-link {
    width: 100%; height: var(--tabbar-h); padding: 6px 2px 4px; flex-direction: column; justify-content: center; gap: 3px;
    border-radius: 0; font-size: 11px; font-weight: 500; color: var(--text-3);
  }
  .nav .nav-link .icon { width: 22px; height: 22px; }
  .nav .nav-texto { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav .nav-link.is-active { background: transparent; color: var(--brand); font-weight: 600; }
  .nav .nav-link.is-active::after { top: 0; bottom: auto; left: 24%; right: 24%; border-radius: 0 0 3px 3px; }
  .nav .nav-link .nav-contador { position: absolute; top: 5px; left: calc(50% + 4px); }
  .nav-mas[open] > summary { background: var(--surface-2); }

  .nav-solo-escritorio { display: none; }
  .nav-mas-solo-movil { display: block; }
  .nav-mas-link.nav-solo-movil { display: flex; }
  .nav-contador.nav-solo-movil { display: inline-grid; }

  /* "Más" se abre como hoja sobre las pestañas, con el usuario arriba. */
  .nav-mas[open]::before { content: ''; position: fixed; inset: 0; z-index: -1; background: rgba(22, 19, 47, .38); }
  .nav-mas-panel {
    position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
    max-height: 70vh; overflow-y: auto; padding: 8px; border-radius: var(--r-lg);
  }
  .nav-mas-link { padding: 14px 12px; font-size: 15px; }
  .nav-mas-link .icon { width: 20px; height: 20px; }
  .nav-mas-usuario {
    display: flex; align-items: center; gap: 10px; padding: 6px 12px 12px; margin-bottom: 4px;
    border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text);
  }
  .nav-mas-usuario small { display: block; font-size: 12px; color: var(--text-3); }
}
@media print {
  .nav, .mudanza-franja { display: none !important; }
}

/* ===== Incidencias ===== */
.incidencia-titulo { font-weight: 600; color: var(--text); }
.incidencia-texto { margin-top: 16px; white-space: pre-line; color: var(--text-2); }
.meta-item small { display: block; margin-top: 2px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.seguimiento { display: grid; gap: 20px; }
.resolver { padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 12px; }
.resolver .field { margin-top: 0; }
.input-archivo { height: auto; padding: 8px; }
.evidencias { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.evidencia { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text-2); min-width: 0; }
.evidencia:hover { border-color: var(--brand); }
.evidencia img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.evidencia .tile { width: 100%; height: 110px; }
.evidencia-nombre { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { list-style: none; margin: 0; display: grid; gap: 14px; }
.timeline-item { display: flex; gap: 12px; align-items: flex-start; }
.timeline-item .tile { width: 30px; height: 30px; border-radius: 8px; }
.timeline-meta { font-size: 12px; color: var(--text-3); }
.timeline-texto { font-size: 14px; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .inline-form > .btn { width: 100%; }
  .evidencias { grid-template-columns: 1fr 1fr; }
  .table-stack td.cell-incidencia { display: block; text-align: left; }
  .table-stack td.cell-incidencia::before { display: none; }
}

/* ===== Autorizaciones ===== */
@media (max-width: 760px) {
  /* Alcance: cada pieza en dos renglones (N/S y consecutivo; SKU, tarima y estado). */
  .table-alcance tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; padding: 10px 16px; }
  .table-alcance td { display: block; padding: 0; width: auto; text-align: left; }
  .table-alcance td::before { display: none; }
  .table-alcance td:nth-child(1) { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--text-3); }
  .table-alcance td:nth-child(2) { grid-column: 1; grid-row: 1; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
  .table-alcance td:nth-child(3), .table-alcance td:nth-child(4) { display: inline; grid-row: 2; font-size: 13px; }
  .table-alcance td:nth-child(3) { grid-column: 1; }
  .table-alcance td:nth-child(4) { grid-column: 2; text-align: right; color: var(--text-3); }
  .table-alcance td:nth-child(5) { grid-column: 1 / -1; }
  .table-alcance td.is-vacia { display: none; }
}


/* ===== Embarques ===== */
.summary-card { cursor: pointer; list-style: none; padding-bottom: 18px; }
.summary-card::-webkit-details-marker { display: none; }
details.card[open] > .summary-card { padding-bottom: 0; }
.lista-embarque { list-style: none; margin: 0; padding: 0; }
.lista-embarque li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px; border-top: 1px solid var(--border); }
.lista-embarque li b { display: block; color: var(--text); font-size: 16px; }
.lista-embarque li.is-recibida { background: var(--success-50); }
@media (max-width: 760px) {
  .lista-embarque li { padding: 10px 16px; }
}
