/* ==========================================================================
   Componentes — sidebar, navbar, cards, botones, tablas, forms, badges,
   toasts, modales, skeletons. Ver docs/05-ui-ux.md
   ========================================================================== */

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
  box-shadow: var(--shadow-2);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5);
  min-height: var(--navbar-h);
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.sidebar-brand::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--gradient-brand);
  opacity: .5;
}

.sidebar-brand .logo-mark {
  width: 38px; height: 38px; border-radius: var(--radius-md);
  background: var(--gradient-brand);
  flex: none;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px;
  font-family: var(--font-display);
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}
.sidebar-brand .logo-mark::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--dot-grid);
  background-size: 6px 6px;
  opacity: .5;
}

.sidebar-brand .logo-text { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); white-space: nowrap; }
.sidebar-brand .logo-text small { display: block; font-weight: 500; font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--text-muted); letter-spacing: .02em; }

.is-collapsed .sidebar-brand .logo-text,
.is-collapsed .nav-group-label,
.is-collapsed .nav-link span,
.is-collapsed .nav-link .badge { display: none; }

.sidebar-nav { padding: var(--sp-5) var(--sp-3); flex: 1; }

.nav-group-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  color: var(--text-muted);
  padding: var(--sp-5) var(--sp-3) var(--sp-2);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 3px;
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.nav-link svg { width: 18px; height: 18px; flex: none; transition: transform var(--dur-fast) var(--ease); }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); transform: translateX(2px); }
.nav-link:hover svg { transform: scale(1.08); }
.nav-link.active { background: linear-gradient(90deg, rgba(22,184,105,.18), rgba(22,184,105,.03)); color: var(--accent-strong); font-weight: 600; }
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: var(--gradient-brand); border-radius: var(--radius-pill);
  box-shadow: 0 0 10px rgba(22,184,105,.5);
}

.nav-link .badge { margin-left: auto; }

/* ---------------- Navbar ---------------- */
.navbar {
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg-app) 72%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.navbar .btn-icon { flex: none; }

.navbar-search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.navbar-search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.navbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: var(--ring-focus);
}

.navbar-search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted);
  pointer-events: none;
}

/* Panel de resultados del buscador global (ver navbar-search.js) */
.navbar-search-resultados {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: var(--sp-2);
  z-index: 150;
}
.navbar-search-resultados.is-open { display: block; }

.navbar-search-grupo + .navbar-search-grupo { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border-color); }
.navbar-search-grupo-titulo {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 4px 10px;
}

.navbar-search-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}
.navbar-search-item:hover { background: var(--bg-hover); }
.navbar-search-item i { flex: none; color: var(--text-muted); font-size: 15px; }
.navbar-search-item-titulo { font-size: var(--fs-sm); font-weight: 600; }
.navbar-search-item-subtitulo { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 1px; }

.navbar-search-vacio { padding: var(--sp-4); text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }

.navbar-spacer { flex: 1; }

.navbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.user-chip {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 14px 6px 6px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.user-chip:hover { background: var(--bg-hover); border-color: var(--border-color-strong); }

.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gradient-brand);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
  font-family: var(--font-display);
  box-shadow: var(--shadow-1);
}

.user-chip .meta { line-height: 1.2; }
.user-chip .meta strong { font-size: var(--fs-sm); display: block; }
.user-chip .meta span { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 11px 20px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn svg { width: 16px; height: 16px; }

.btn-sm { padding: 7px 14px; font-size: var(--fs-xs); }
.btn-lg { padding: 14px 24px; font-size: var(--fs-base); }

.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { box-shadow: 0 10px 28px rgba(15,157,88,.4); transform: translateY(-1px); }

.btn-secondary { background: var(--bg-surface-2); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-color-strong); }

.btn-outline { background: transparent; color: var(--accent-strong); border-color: var(--border-color-strong); }
.btn-outline:hover { background: var(--bg-hover); border-color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 6px 18px rgba(240,68,56,.28); }
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-md); background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-icon:hover { color: var(--accent-strong); background: var(--bg-hover); border-color: var(--border-color-strong); }

/* ---------------- Cards ---------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}

.card-header {
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  border-bottom: 1px solid var(--border-color);
}
.card-header h3 { font-size: var(--fs-base); font-family: var(--font-display); font-weight: 700; }
.card-body { padding: var(--sp-6); }
.card-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: var(--sp-3); }

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-1);
  display: flex; align-items: flex-start; gap: var(--sp-4);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.stat-card::after {
  content: ""; position: absolute; inset: 0; background: var(--gradient-surface); pointer-events: none;
}
/* Marcas de esquina tipo "lectura técnica" — firma visual del sistema */
.stat-card::before {
  content: "";
  position: absolute; top: 10px; left: 10px; width: 14px; height: 14px;
  border-top: 2px solid var(--border-color-strong);
  border-left: 2px solid var(--border-color-strong);
  border-radius: 4px 0 0 0;
  opacity: .6;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.stat-card .stat-body { flex: 1; min-width: 0; position: relative; z-index: 1; }
.stat-card .stat-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat-card .stat-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-xl); font-weight: 700; margin-top: var(--sp-2); letter-spacing: -.02em;
  white-space: nowrap;
}
.stat-card .stat-delta { font-size: var(--fs-xs); font-weight: 700; margin-top: var(--sp-3); display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: var(--radius-pill); }
.stat-card .stat-delta.up { color: var(--success); background: var(--success-bg); }
.stat-card .stat-delta.down { color: var(--danger); background: var(--danger-bg); }

/* Ícono como chip a la izquierda: fondo tintado suave + glifo a color, en
   vez de un cuadro de gradiente flotando en la esquina (algunos glifos de
   Bootstrap Icons perdían contraste ahí y se veían genéricos/rotos). */
.stat-card .stat-icon {
  position: relative; z-index: 1;
  width: 46px; height: 46px; border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--success-bg); color: var(--success);
  flex: none;
}
.stat-card .stat-icon svg { width: 20px; height: 20px; }
.stat-card .stat-icon i.bi { font-size: 20px; }
.stat-card .stat-icon.tone-warning { background: var(--warning-bg); color: var(--warning); }
.stat-card .stat-icon.tone-neutral { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border-color-strong); }
.stat-card .stat-icon.tone-info { background: var(--info-bg); color: var(--info); }

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(224px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); }
@media (max-width: 992px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 4px 12px; border-radius: var(--radius-pill);
  letter-spacing: .01em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-surface-2); color: var(--text-secondary); }

/* ---------------- Alerts (mensajes flash de error/exito) ---------------- */
.alert { border-radius: var(--radius-md); padding: 14px 18px; font-size: var(--fs-sm); border: 1px solid transparent; display: flex; align-items: center; gap: var(--sp-3); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(240,68,56,.25); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(23,178,106,.25); }

/* ---------------- Tables ---------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  box-shadow: var(--shadow-1);
}
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.table thead th {
  position: sticky; top: 0;
  text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 700;
  background: var(--bg-surface-2);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
table.table thead th:first-child { border-top-left-radius: var(--radius-lg); }
table.table thead th:last-child { border-top-right-radius: var(--radius-lg); }

table.table tbody td {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}
table.table tbody td.num { text-align: right; }
table.table tbody tr { background: var(--bg-surface); transition: background var(--dur-fast) var(--ease); }
table.table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-surface-2) 35%, var(--bg-surface)); }
table.table tbody tr:hover { background: var(--bg-hover); }

/* Lista de productos bajo el concepto de un movimiento de caja (ver caja/index.php) */
.caja-movimiento-items {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.caja-movimiento-items li { padding: 1px 0; }
.caja-movimiento-items li::before { content: "· "; }
table.table tbody tr:last-child td { border-bottom: none; }

/* Fila de producto con foto: usada dentro de tablas de inventario/pedidos */
table.table .row-product { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
table.table .row-product .row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.table .row-product .row-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

.table-empty {
  text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.table-empty svg { width: 44px; height: 44px; opacity: .5; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5); font-size: var(--fs-sm); color: var(--text-muted); border-top: 1px solid var(--border-color); }
.pagination .pages { display: flex; gap: var(--sp-2); }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border-radius: var(--radius-md);
  border: 1px solid var(--border-color); color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.pagination a:hover { background: var(--bg-hover); border-color: var(--border-color-strong); }
.pagination .active { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: var(--sp-5); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.form-row-swap { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-5); }
.form-row-swap .field-floating { margin-bottom: 0; }
.form-row-swap .btn-icon { margin-top: 10px; }
@media (max-width: 640px) {
  .form-row-swap { grid-template-columns: 1fr; }
  .form-row-swap .btn-icon { justify-self: center; transform: rotate(90deg); margin-top: 0; }
}

.field-floating { position: relative; }
.field-floating input, .field-floating select, .field-floating textarea {
  width: 100%;
  padding: 21px 14px 9px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field-floating textarea { padding-top: 24px; min-height: 92px; resize: vertical; }
.field-floating input:focus, .field-floating select:focus, .field-floating textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring-focus);
}
.field-floating label {
  position: absolute; left: 14px; top: 15px;
  font-size: var(--fs-sm); color: var(--text-muted);
  transition: all var(--dur-fast) var(--ease);
  pointer-events: none;
}
.field-floating input:focus + label,
.field-floating input:not(:placeholder-shown) + label,
.field-floating select + label,
.field-floating textarea:focus + label,
.field-floating textarea:not(:placeholder-shown) + label {
  top: 7px; font-size: var(--fs-xs); color: var(--accent-strong); font-weight: 600;
}
.field-error { color: var(--danger); font-size: var(--fs-xs); margin-top: 4px; }

.input-icon-group { position: relative; }
.input-icon-group svg { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }

/* ---------------- Modal ----------------
   Centrado robusto: el backdrop cubre todo el viewport con posicionamiento
   fijo explícito (no solo `inset`) + `place-items: center` como respaldo,
   de modo que el modal SIEMPRE queda centrado y nunca se puede desplazar
   a una esquina por estilos externos del contenido. */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
  overflow-y: auto;
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.modal {
  /* Reset defensivo: si esta clase llega a convivir con otra librería que
     también use el nombre ".modal" (p. ej. Bootstrap define .modal con
     position:fixed; top:0; left:0; height:100%), esas reglas se cuelan por
     debajo y empujan el modal a la esquina en vez de dejarlo centrado por
     el backdrop. Al fijar explícitamente position/top/left/height aquí,
     el modal queda inmune a ese conflicto pase lo que pase. */
  position: relative; top: auto; left: auto; right: auto; bottom: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 640px;
  height: auto; max-height: 88vh;
  margin: auto;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-3);
  transform: translateY(16px) scale(.97);
  opacity: 0;
  transition: transform var(--dur-base) var(--ease-spring), opacity var(--dur-fast) var(--ease);
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal.modal-lg { max-width: 900px; }
.modal.modal-sm { max-width: 440px; }

.modal-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--gradient-surface);
}
.modal-header h3 { font-size: var(--fs-md); font-family: var(--font-display); font-weight: 700; }
.modal-body { padding: var(--sp-6); overflow-y: auto; }
.modal-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: var(--sp-3); }

/* ---------------- Producto: foto + precios por almacen ---------------- */
.producto-form-layout { display: grid; grid-template-columns: 240px 1fr; gap: var(--sp-6); }
@media (max-width: 640px) { .producto-form-layout { grid-template-columns: 1fr; } }

/* Foto principal del formulario de producto — mucho más grande y con
   marco protagonista en vez de un cuadro discreto */
.foto-picker { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.foto-picker .foto-preview {
  width: 100%; max-width: 240px; aspect-ratio: 1 / 1; height: auto;
  border-radius: var(--radius-xl);
  background: var(--bg-surface-2);
  border: 2px dashed var(--border-color-strong);
  object-fit: cover; display: block;
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.foto-picker:hover .foto-preview { transform: scale(1.015); box-shadow: var(--shadow-glow); }
.foto-picker label.btn { width: 100%; text-align: center; cursor: pointer; }
.foto-picker input[type="file"] { display: none; }

/* Miniatura en listas/tablas — más grande y con esquinas suaves */
.producto-thumb {
  width: 108px; height: 108px; border-radius: var(--radius-lg);
  object-fit: cover; background: var(--bg-surface-2); border: 1px solid var(--border-color); flex: none;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-fast) var(--ease);
}
table.table tr:hover .producto-thumb { transform: scale(1.04); }

.producto-thumb-placeholder {
  width: 108px; height: 108px; border-radius: var(--radius-lg);
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  display: grid; place-items: center; color: var(--text-muted); flex: none; font-size: 2rem;
}

/* Variante compacta opcional cuando el espacio de fila es reducido */
.producto-thumb-sm, .producto-thumb-sm.producto-thumb-placeholder {
  width: 64px; height: 64px; border-radius: var(--radius-md);
}

.almacenes-precio-table { width: 100%; border-collapse: collapse; margin-top: var(--sp-3); }
.almacenes-precio-table th {
  text-align: left; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--border-color);
  text-transform: uppercase; letter-spacing: .05em;
}
.almacenes-precio-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-color); }
.almacenes-precio-table input {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-surface-2); color: var(--text-primary); font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.almacenes-precio-table input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring-focus); }

.almacenes-precio-badges { display: flex; flex-direction: column; gap: 5px; margin-top: var(--sp-2); }
.almacenes-precio-badges .fila { font-size: var(--fs-xs); color: var(--text-secondary); display: flex; gap: 6px; }
.almacenes-precio-badges .fila strong { color: var(--text-primary); font-family: var(--font-mono); }

.check-toggle { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); cursor: pointer; margin-bottom: var(--sp-3); }
.check-toggle input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ---------------- Toasts ---------------- */
.toast-stack { position: fixed; top: var(--sp-5); right: var(--sp-5); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-3); }
.toast {
  min-width: 300px; max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: var(--sp-4);
  display: flex; gap: var(--sp-3); align-items: flex-start;
  animation: toast-in var(--dur-base) var(--ease-spring);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast strong { display: block; font-size: var(--fs-sm); font-family: var(--font-display); }
.toast p { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 3px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.96); } to { opacity: 1; transform: translateX(0) scale(1); } }

/* ---------------- Skeleton ---------------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-hover) 37%, var(--bg-surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- Avatar (usuarios, clientes, comentarios, etc.) ---------------- */
.avatar {
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-family: var(--font-display);
  flex: none;
  box-shadow: var(--shadow-1);
}
.avatar-sm { width: 34px; height: 34px; font-size: 12px; }
.avatar-md { width: 42px; height: 42px; font-size: 14px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

/* ---------------- Buscador de listas (usuarios, clientes, proveedores…) ---------------- */
.search-bar { position: relative; flex: 1; }
.search-bar svg, .search-bar i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); font-size: 15px; pointer-events: none;
}
.search-bar input.input-search {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.search-bar input.input-search:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring-focus); }

/* ---------------- Chips seleccionables (roles / permisos como checkbox) ---------------- */
.chip-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 600;
  padding: 6px 14px 6px 10px; border-radius: var(--radius-pill);
  background: var(--bg-surface-2); color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip-check input { width: 14px; height: 14px; accent-color: var(--accent); }
.chip-check:hover { border-color: var(--border-color-strong); }
.chip-check.is-checked {
  background: linear-gradient(90deg, rgba(22,184,105,.18), rgba(22,184,105,.06));
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* Íconos de Bootstrap Icons (fuente <i class="bi bi-*">) usados dentro de
   botones, nav y stat-cards: sin esto quedan chicos/desalineados porque
   son glifos de fuente, no SVG con width/height. */
.btn i.bi, .btn-icon i.bi { font-size: 16px; line-height: 1; }
.nav-link i.bi { width: 18px; font-size: 17px; text-align: center; flex: none; }
.stat-icon i.bi { font-size: 20px; }
.user-chip i.bi, .navbar-search i.bi, .search-bar i.bi { font-size: 15px; }

/* ---------------- Catálogo de productos en grid (tarjetas, no tabla) ---------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: var(--sp-5);
}

.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column;
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.product-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-surface-2);
  overflow: hidden;
}
.product-card-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform var(--dur-slow) var(--ease);
}
.product-card:hover .product-card-media img { transform: scale(1.05); }
.product-card-media .producto-thumb-placeholder {
  width: 100%; height: 100%; border-radius: 0;
  display: grid; place-items: center; font-size: 2.6rem; color: var(--text-muted);
}

.product-card-ribbons {
  position: absolute; top: var(--sp-3); left: var(--sp-3); right: var(--sp-3);
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-2); flex-wrap: wrap;
  pointer-events: none;
}
.product-card-ribbons .badge { box-shadow: var(--shadow-1); backdrop-filter: blur(4px); }

.product-card-body { padding: var(--sp-4) var(--sp-5); flex: 1; display: flex; flex-direction: column; }
.product-card-title { font-weight: 700; font-size: var(--fs-base); line-height: 1.3; }
.product-card-code { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; margin-bottom: var(--sp-3); }

.product-card-precios { display: flex; flex-direction: column; gap: 5px; margin-top: auto; padding-top: var(--sp-2); }
.product-card-precios .fila { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-xs); }
.product-card-precios .fila .nombre-almacen { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-card-precios .fila .precio { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); flex: none; }
.product-card-precios .fila .stock-mini { color: var(--text-muted); font-size: 11px; }

.product-card-footer {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-color);
  background: var(--gradient-surface);
}
.product-card-footer .btn-icon { flex: 1; width: auto; }

/* ---------------- Listado de ventas como "filas de ticket" (no tabla) ----------------
   CSS Grid en vez de flex: cada fila tiene 4 columnas fijas (ícono | datos |
   total | acciones). A diferencia de flex-wrap, un grid nunca "colapsa" un
   hijo a su propia línea si el contenido de al lado no cabe — cada bloque
   se queda en su columna, así nunca se ve roto/apilado. */
.ticket-list { display: flex; flex-direction: column; }
.ticket-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  grid-template-areas: "icon main total actions";
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--dur-fast) var(--ease);
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: var(--bg-hover); }

.ticket-icon {
  grid-area: icon;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  background: var(--bg-surface-2); color: var(--text-secondary);
  border: 1px solid var(--border-color-strong);
}
.ticket-icon i.bi { font-size: 19px; line-height: 1; }
.ticket-icon.metodo-efectivo { background: var(--success-bg); color: var(--success); border-color: rgba(23,178,106,.3); }
.ticket-icon.metodo-yape_plin { background: var(--info-bg); color: var(--info); border-color: rgba(47,158,68,.3); }
.ticket-icon.metodo-tarjeta { background: var(--warning-bg); color: var(--warning); border-color: rgba(247,144,9,.3); }
.ticket-icon.metodo-credito { background: var(--bg-elevated); color: var(--text-secondary); }
.ticket-icon.metodo-mixto { background: var(--bg-elevated); color: var(--accent-strong); border-color: var(--border-color-strong); }
.ticket-icon.traslado { background: var(--bg-elevated); color: var(--accent-strong); border-color: var(--border-color-strong); }

.ticket-main { grid-area: main; min-width: 0; }
.ticket-cliente { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.ticket-meta i { margin-right: 3px; }

.ticket-total { grid-area: total; text-align: right; white-space: nowrap; }
.ticket-total .monto { font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.ticket-total .badge { margin-top: 4px; }

.ticket-actions { grid-area: actions; display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.ticket-actions form { display: flex; } /* un <form> es block por defecto: sin esto rompía la fila a otra línea */

@media (max-width: 760px) {
  .ticket-row {
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "icon main"
      "total total"
      "actions actions";
    row-gap: var(--sp-2);
  }
  .ticket-total { text-align: left; }
  .ticket-actions { flex-wrap: wrap; }
}

/* ---------------- Separador de sección con etiqueta (reemplaza <hr>+label sueltos) ---------------- */
.section-divider {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-6) 0 var(--sp-4);
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.section-divider::before, .section-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-color); }
.section-divider.align-start::before { flex: 0 0 0; }

/* ---------------- Input de una línea sin floating label (búsquedas rápidas, altas rápidas) ---------------- */
.input-field {
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input-field:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring-focus); }

/* ---------------- Utilities ---------------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-600 { font-weight: 600; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.mt-3 { margin-top: var(--sp-3); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-0 { margin-bottom: 0; }
.w-100 { width: 100%; }
.flex-wrap { flex-wrap: wrap; }

/* ---------------- Buscador de producto (filas de Ventas/Compras) ---------------- */
.buscador-producto { position: relative; display: block; width: 100%; }

.buscador-producto .buscador-input {
  display: block;
  width: 100% !important; /* !important: algunos scripts de autocompletado ponen un width en línea al crear el input; esto lo gana siempre */
  min-width: 220px;
  box-sizing: border-box;
  padding: 9px 12px 9px 34px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.buscador-producto .buscador-input:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring-focus);
}
.buscador-producto::before {
  content: "\F52A"; /* bi-search, vía fuente Bootstrap Icons */
  font-family: "bootstrap-icons", sans-serif;
  position: absolute; left: 11px; top: 9px;
  font-size: 14px; color: var(--text-muted); pointer-events: none;
}

/* Menú de sugerencias: position:fixed + medidas puestas por JS (ver
   items-form.js), así el menú no queda recortado por el overflow-x:auto de
   .table-wrap ni limitado al ancho angosto de la celda. min-width es
   deliberado: si el JS calcula un ancho basado en el input y este quedó
   angosto, el menú NUNCA baja de 280px — CSS respeta min-width por encima
   de cualquier width en línea que le hayan puesto, sin necesitar !important. */
.buscador-sugerencias {
  position: fixed; z-index: 150;
  min-width: 280px;
  max-width: 420px;
  max-height: 260px; overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: 6px;
  animation: sugerencias-in var(--dur-fast) var(--ease);
}
@keyframes sugerencias-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.buscador-opcion {
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.buscador-opcion .buscador-opcion-titulo {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.buscador-opcion .buscador-opcion-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.buscador-opcion:hover { background: var(--bg-hover); }
.buscador-opcion.is-activa {
  background: linear-gradient(90deg, rgba(22,184,105,.16), rgba(22,184,105,.04));
  color: var(--accent-strong);
}
.buscador-opcion.is-activa .buscador-opcion-meta { color: var(--accent-strong); opacity: .8; }
.buscador-opcion + .buscador-opcion { margin-top: 2px; }

.buscador-vacio {
  padding: var(--sp-4); text-align: center;
  font-size: var(--fs-xs); color: var(--text-muted);
}
/* ---------------- Ticket de venta (comprobante imprimible) ----------------
   Tarjeta "recibo digital" en pantalla (tipografía normal de la app, bordes
   suaves, total resaltado); @media print la aplana a algo simple en blanco y
   negro apto para una impresora térmica de 80mm (ver más abajo). */
.ticket-print {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-5);
  max-width: 320px;
  margin: 0 auto;
}

.ticket-print-header {
  text-align: center;
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px dashed var(--border-color-strong);
}
.ticket-print-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--sp-2);
  border-radius: var(--radius-pill);
  background: var(--success-bg);
  color: var(--accent-strong);
  font-size: var(--fs-md);
}
.ticket-print-header strong { display: block; font-family: var(--font-display); font-size: var(--fs-md); }
.ticket-print-header span { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

.ticket-print-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.ticket-print-meta div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); font-size: var(--fs-xs); }
.ticket-print-meta div span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-muted); white-space: nowrap; }
.ticket-print-meta div span:last-child { color: var(--text-primary); font-weight: 600; text-align: right; }

.ticket-print-badge {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--warning-bg); color: var(--warning);
  border-radius: var(--radius-pill); padding: 7px 10px;
  margin-bottom: var(--sp-4);
}

.ticket-print-items { border-top: 1px dashed var(--border-color-strong); padding-top: var(--sp-2); margin-bottom: var(--sp-4); }
.ticket-print-item { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); padding: 9px 0; }
.ticket-print-item + .ticket-print-item { border-top: 1px solid var(--border-color); }
.ticket-print-item-info { min-width: 0; }
.ticket-print-item-nombre { font-weight: 600; font-size: var(--fs-sm); overflow-wrap: break-word; }
.ticket-print-item-cant { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 1px; }
.ticket-print-item-subtotal { flex-shrink: 0; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.ticket-print-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--success-bg);
  border-radius: var(--radius-md);
}
.ticket-print-total span:first-child { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
.ticket-print-total span:last-child { font-size: var(--fs-lg); font-weight: 700; color: var(--accent-strong); font-variant-numeric: tabular-nums; }

.ticket-print-footer { text-align: center; font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-4); }

@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body * { visibility: hidden; }
  #ticketContenido, #ticketContenido * { visibility: visible; }
  #ticketContenido {
    position: absolute; left: 0; top: 0;
    width: 100%; max-width: none;
    background: #fff; border: none; box-shadow: none; padding: 0;
    color: #000;
  }
  .ticket-print-icon { display: none; }
  .ticket-print-header, .ticket-print-items { border-color: #000; }
  .ticket-print-item + .ticket-print-item { border-color: #ddd; }
  .ticket-print-badge { background: none; border: 1px solid #000; color: #000; border-radius: 0; }
  .ticket-print-total { background: none; border-top: 2px solid #000; border-radius: 0; padding: var(--sp-2) 0 0; }
  .ticket-print-total span:last-child { color: #000; }
}
