/* ═══════════════════════════════════════════════════════════════════════════
   NovaCore POS Desktop — Componentes
   Botones, campos, tarjetas, tablas, distintivos, ventanas, avisos.
   Cada componente se define UNA vez y se reutiliza en landing, acceso y app.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══ BOTONES ═══════════════════════════════════════════════════════════════
   Un solo elemento base `.btn` + modificador de color + modificador de tamaño.
   Alturas fijas (32/36/44) para que cualquier fila de controles quede alineada
   sin ajustes manuales. */
.btn {
  --btn-h: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--btn-h);
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; }

/* El hundido de 1px al presionar es la única señal táctil que tiene un ratón:
   confirma el clic antes de que llegue la respuesta del servidor. */
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--brand);
  color: var(--fg-on-brand);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--fg);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--fg-faint);
}

.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }

.btn-soft { background: var(--brand-soft); color: var(--brand-fg); }
.btn-soft:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
}

.btn-danger { background: var(--dan); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--dan-700); }

.btn-danger-soft { background: var(--dan-soft); color: var(--dan-fg); }
.btn-danger-soft:hover:not(:disabled) {
  background: color-mix(in srgb, var(--dan) 18%, transparent);
}

.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover:not(:disabled) { background: var(--ok-700); }

.btn-xs { --btn-h: 26px; padding: 0 var(--s-2); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-xs svg { width: 13px; height: 13px; }
.btn-sm { --btn-h: 32px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { --btn-h: 44px; padding: 0 var(--s-6); font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-lg svg { width: 18px; height: 18px; }
.btn-xl { --btn-h: 52px; padding: 0 var(--s-8); font-size: var(--fs-lg); border-radius: var(--r-lg); }

.btn-block { width: 100%; }

/* Botón que es solo un icono: cuadrado exacto, sin relleno lateral. */
.btn-icon { width: var(--btn-h); padding: 0; }

/* Estado de espera: el texto se desvanece y gira un anillo en su lugar, sin
   que el botón cambie de ancho (si cambiara, la fila entera se movería). */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  color: var(--fg-on-brand);
}
.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after,
.btn-soft.is-loading::after { color: var(--fg-muted); }

/* ═══ CAMPOS DE FORMULARIO ═════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.label .req { color: var(--dan); }

.input,
.select,
.textarea {
  width: 100%;
  height: 38px;
  padding: 0 var(--s-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--fg);
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease);
}
.textarea { height: auto; min-height: 80px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: var(--lh-snug); }

.input::placeholder,
.textarea::placeholder { color: var(--fg-faint); }

.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) { border-color: var(--fg-faint); }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-subtle);
  color: var(--fg-subtle);
  cursor: not-allowed;
}

.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid { border-color: var(--dan); }
.input.is-invalid:focus,
.textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dan) 25%, transparent);
}

/* La flecha del select se dibuja en CSS para que herede el color del tema;
   la nativa de Windows no se puede teñir. */
.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7488' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 15px;
  cursor: pointer;
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a3abbb' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}

/* Campo con icono o botón dentro (buscador, contraseña, importe). */
.input-group { position: relative; display: flex; align-items: center; width: 100%; }
.input-group .input { padding-left: var(--s-8); }
.input-group.no-icon .input { padding-left: var(--s-3); }
.input-group > .ig-icon {
  position: absolute;
  left: var(--s-3);
  width: 16px; height: 16px;
  color: var(--fg-subtle);
  pointer-events: none;
  transition: color var(--t-fast) var(--ease);
}
.input-group:focus-within > .ig-icon { color: var(--brand); }
.input-group.has-suffix .input { padding-right: 40px; }
.input-group > .ig-suffix {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.input-group > .ig-suffix:hover { background: var(--bg-hover); color: var(--fg); }
.input-group > .ig-suffix svg { width: 16px; height: 16px; }

/* Prefijo fijo, p. ej. el símbolo de moneda. */
.input-group.has-prefix .input { padding-left: 30px; }
.input-group > .ig-prefix {
  position: absolute;
  left: var(--s-3);
  color: var(--fg-subtle);
  font-size: var(--fs-sm);
  pointer-events: none;
}

.hint { font-size: var(--fs-xs); color: var(--fg-subtle); }
.error-text {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--dan);
  animation: rise var(--t-fast) var(--ease-out);
}
.error-text svg { width: 13px; height: 13px; flex: none; }

/* ── Casilla y opción única ─────────────────────────────────────────────────
   Se dibujan a mano: los controles nativos no aceptan color de marca ni
   transiciones en Windows. */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  font-size: var(--fs-sm);
  user-select: none;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  position: relative;
  width: 17px; height: 17px;
  flex: none;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--bg-surface);
  transition: all var(--t-fast) var(--ease);
}
.check .box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  opacity: 0;
  transform: scale(0.6);
  transition: all var(--t-fast) var(--ease-out);
}
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .box::after { opacity: 1; transform: none; }
.check:hover .box { border-color: var(--brand); }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--ring); }
.check.radio .box { border-radius: 50%; }
.check.radio .box::after {
  background: #fff;
  border-radius: 50%;
  inset: 4px;
  mask: none;
}

/* ── Interruptor ─────────────────────────────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative;
  width: 38px; height: 21px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--n-300);
  transition: background-color var(--t-base) var(--ease);
}
[data-theme="dark"] .switch .track { background: var(--n-700); }
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base) var(--ease-out);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ring); }

/* ── Control segmentado ──────────────────────────────────────────────────── */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.segmented button {
  padding: 5px var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-muted);
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.segmented button:hover { color: var(--fg); }
.segmented button.is-active {
  background: var(--bg-surface);
  color: var(--fg);
  box-shadow: var(--shadow-xs);
}

/* ═══ TARJETAS ══════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Envuelve en vez de desbordar: el área de trabajo recorta el eje
     horizontal, así que un control desbordado quedaría inalcanzable. */
  flex-wrap: wrap;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 52px;
}
.card-head > :first-child { min-width: 0; }
.card-title { font-size: var(--fs-md); font-weight: var(--fw-semi); letter-spacing: 0; }
.card-sub { font-size: var(--fs-xs); color: var(--fg-subtle); margin-top: 1px; }
.card-body { padding: var(--s-5); }
.card-body.tight { padding: var(--s-3); }
.card-body.flush { padding: 0; }
.card-foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ═══ INDICADORES (KPI) ═════════════════════════════════════════════════════
   La cifra manda: tamaño grande, cifras tabulares y la etiqueta arriba en
   pequeño. La variación va a la derecha con color semántico. */
.stat {
  position: relative;
  padding: var(--s-4) var(--s-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
/* Sin filete de color superior: la métrica ya se identifica por el icono
   coloreado de la etiqueta, así que la franja sobraba y ensuciaba la tarjeta.
   (El acento sigue disponible en `--stat-accent` para el icono de abajo.) */
.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.stat-label svg { width: 13px; height: 13px; color: var(--stat-accent, var(--brand)); }
.stat-value {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-tight);
  line-height: 1.15;
  margin-top: var(--s-2);
}
.stat-foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
}
.delta svg { width: 11px; height: 11px; }
.delta.up   { background: var(--ok-soft);  color: var(--ok-fg); }
.delta.down { background: var(--dan-soft); color: var(--dan-fg); }
.delta.flat { background: var(--bg-subtle); color: var(--fg-subtle); }

/* ═══ DISTINTIVOS ═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1.6;
}
.badge svg { width: 11px; height: 11px; }
.badge-neutral { background: var(--bg-subtle);  color: var(--fg-muted); }
.badge-brand   { background: var(--brand-soft); color: var(--brand-fg); }
.badge-ok      { background: var(--ok-soft);    color: var(--ok-fg); }
.badge-warn    { background: var(--warn-soft);  color: var(--warn-fg); }
.badge-dan     { background: var(--dan-soft);   color: var(--dan-fg); }
.badge-info    { background: var(--info-soft);  color: var(--info-fg); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--fg-muted); }

/* Punto de estado: el color solo no basta para daltonismo, por eso siempre
   va acompañado del texto del estado. */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: currentColor; }
.dot.live { animation: pulse-ring 2s ease-out infinite; }

/* ═══ AVATAR ════════════════════════════════════════════════════════════════ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  user-select: none;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: var(--fs-2xs); }
.avatar-lg { width: 44px; height: 44px; font-size: var(--fs-md); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--fs-xl); }

/* ═══ TABLAS ════════════════════════════════════════════════════════════════
   Densidad de escritorio: filas de 44px, encabezado fijo al desplazar,
   separadores tenues y hover de fila completa. */
.table-wrap {
  width: 100%;
  overflow: auto;
  border-radius: var(--r-lg);
}
.table { font-size: var(--fs-sm); }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-sunken);
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--fg-subtle);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.table thead th.sortable { cursor: pointer; transition: color var(--t-fast) var(--ease); }
.table thead th.sortable:hover { color: var(--fg); }
.table thead th .th-in { display: inline-flex; align-items: center; gap: 4px; }
.table thead th .sort-i {
  width: 12px; height: 12px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.table thead th.sortable:hover .sort-i { opacity: 0.45; }
.table thead th[aria-sort] { color: var(--fg); }
.table thead th[aria-sort] .sort-i { opacity: 1; color: var(--brand); }
.table thead th[aria-sort="descending"] .sort-i { transform: rotate(180deg); }

.table tbody td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  height: 44px;
}
.table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-selected { background: var(--brand-soft); }
.table .num, .table .right { text-align: right; }
.table .center-c { text-align: center; }
.table .nowrap { white-space: nowrap; }

/* Columna de acciones: aparece al pasar el ratón para no saturar la fila,
   pero permanece visible siempre con teclado. */
.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
tr:hover .row-actions,
.row-actions:focus-within { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  transition: all var(--t-fast) var(--ease);
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--bg-active); color: var(--fg); }
.icon-btn.danger:hover { background: var(--dan-soft); color: var(--dan); }

/* Barra de herramientas de tabla: buscador + filtros + acciones. */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.table-toolbar .search { width: 260px; max-width: 100%; }
.table-toolbar .search .input { height: 34px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
  flex-wrap: wrap;
}
.pagination .pages { display: flex; gap: 2px; }
.pagination .pg {
  min-width: 28px; height: 28px;
  padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-muted);
  transition: all var(--t-fast) var(--ease);
}
.pagination .pg:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }
.pagination .pg.is-active { background: var(--brand); color: var(--fg-on-brand); }
.pagination .pg:disabled { opacity: 0.35; cursor: not-allowed; }

/* ═══ ESTADO VACÍO ══════════════════════════════════════════════════════════ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-16) var(--s-6);
  text-align: center;
  color: var(--fg-subtle);
  /* Si el estado vacío cae dentro de una rejilla (Cocina, mesas…) sería UNA
     celda más y quedaría encajado en la primera columna, pegado a la orilla
     izquierda en vez de centrado. Ocupando todas las columnas vuelve a
     centrarse respecto al ancho completo. En un contenedor que no es rejilla
     esta línea no hace nada, así que es seguro dejarla global. */
  grid-column: 1 / -1;
}
.empty .empty-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: var(--r-xl);
  background: var(--bg-subtle);
  color: var(--fg-faint);
}
.empty .empty-icon svg { width: 24px; height: 24px; }
.empty h3 { font-size: var(--fs-md); color: var(--fg); font-weight: var(--fw-semi); }
.empty p { font-size: var(--fs-sm); max-width: 42ch; }

/* ═══ VENTANA MODAL ═════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  background: color-mix(in srgb, var(--n-950) 55%, transparent);
  backdrop-filter: blur(3px);
  animation: fade-in var(--t-base) var(--ease-out);
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - var(--s-12));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  animation: pop var(--t-base) var(--ease-out);
  overflow: hidden;
}
.modal.sm { max-width: 400px; }
.modal.lg { max-width: 720px; }
.modal.xl { max-width: 980px; }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-head h2 { font-size: var(--fs-lg); font-weight: var(--fw-semi); }
.modal-head p { font-size: var(--fs-sm); color: var(--fg-subtle); margin-top: 2px; }
.modal-body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-sunken);
}
.modal-foot.spread { justify-content: space-between; }

/* ═══ AVISOS FLOTANTES ══════════════════════════════════════════════════════ */
.toast-host {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
  max-width: min(400px, calc(100vw - var(--s-8)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--toast-accent, var(--brand));
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slide-left var(--t-base) var(--ease-out);
}
.toast.is-out { animation: fade-in var(--t-base) var(--ease) reverse forwards; }
.toast .t-icon { color: var(--toast-accent, var(--brand)); margin-top: 1px; }
.toast .t-icon svg { width: 17px; height: 17px; }
.toast .t-title { font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.toast .t-msg { font-size: var(--fs-xs); color: var(--fg-muted); margin-top: 1px; }
.toast.ok   { --toast-accent: var(--ok); }
.toast.warn { --toast-accent: var(--warn); }
.toast.dan  { --toast-accent: var(--dan); }
.toast.info { --toast-accent: var(--info); }

/* ═══ MENÚ CONTEXTUAL ═══════════════════════════════════════════════════════ */
.menu {
  min-width: 190px;
  padding: var(--s-1);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: rise var(--t-fast) var(--ease-out);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.menu-item svg { width: 15px; height: 15px; flex: none; }
.menu-item:hover { background: var(--bg-hover); color: var(--fg); }
.menu-item.danger { color: var(--dan); }
.menu-item.danger:hover { background: var(--dan-soft); }
.menu-sep { height: 1px; background: var(--border-subtle); margin: var(--s-1) 0; }
.menu-label {
  padding: var(--s-2) var(--s-3) var(--s-1);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* ═══ PESTAÑAS ══════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-subtle);
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.tab::after {
  content: "";
  position: absolute;
  left: var(--s-3); right: var(--s-3);
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand);
  transform: scaleX(0);
  transition: transform var(--t-base) var(--ease-out);
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--brand); }
.tab.is-active::after { transform: none; }

/* ═══ AVISO EN LÍNEA ════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
}
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert-ok   { background: var(--ok-soft);   color: var(--ok-fg);   border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn-fg); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.alert-dan  { background: var(--dan-soft);  color: var(--dan-fg);  border-color: color-mix(in srgb, var(--dan) 22%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info-fg); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert.shake { animation: shake 0.4s var(--ease); }

/* ═══ AYUDA EMERGENTE ═══════════════════════════════════════════════════════ */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 4px 8px;
  background: var(--bg-inverse);
  color: var(--fg-inverse);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  border-radius: var(--r-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  z-index: var(--z-toast);
  box-shadow: var(--shadow-md);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }
[data-tip].tip-right::after {
  bottom: auto; top: 50%; left: calc(100% + 7px);
  transform: translateY(-50%) translateX(-3px);
}
[data-tip].tip-right:hover::after { transform: translateY(-50%); }

/* ═══ BARRA DE PROGRESO ═════════════════════════════════════════════════════ */
.meter {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--r-full);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--meter-color, var(--brand));
  transition: width var(--t-slow) var(--ease-out);
}

/* ═══ SEPARADOR CON TEXTO ═══════════════════════════════════════════════════ */
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}
.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ═══ TECLA Y CÓDIGO ════════════════════════════════════════════════════════ */
.kbd {
  display: inline-block;
  padding: 2px 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  color: var(--fg-muted);
  white-space: nowrap;
}

.code-block {
  padding: var(--s-3) var(--s-4);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  overflow-x: auto;
  white-space: pre;
}

/* ═══ VISTA PREVIA DEL TICKET ═══════════════════════════════════════════════
   El ticket se muestra dentro de un iframe para que sus estilos (milímetros,
   fuente monoespaciada, @page) no se mezclen con los de la aplicación. */
.ticket-preview-host { display: flex; justify-content: center; }
.ticket-preview {
  width: 302px;              /* 80 mm a 96 ppp */
  min-height: 200px;
  border: 0;
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--shadow-md);
}

/* ═══ CUADRÍCULA RESPONSIVA ═════════════════════════════════════════════════
   `auto-fit` + `minmax` evita escribir un punto de corte por cada anchura:
   la rejilla decide sola cuántas columnas caben. */
.grid { display: grid; gap: var(--s-4); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.form-grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.form-grid .span-2 { grid-column: 1 / -1; }
