:root {
  --bg-color: #0f172a;
  --surface-color: rgba(30, 41, 59, 0.92);
  --surface-border: rgba(255, 255, 255, 0.1);
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --success-color: #10b981;
  --success-hover: #059669;
  --danger-color: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.15s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  /* Acentos de gradiente integrados en un solo background-image: un único paint,
     sin las dos capas de composición fijas que generaban body::before/::after. */
  background-image:
    radial-gradient(60% 60% at 0% 0%, rgba(59, 130, 246, 0.15) 0%, rgba(15, 23, 42, 0) 70%),
    radial-gradient(60% 60% at 100% 100%, rgba(16, 185, 129, 0.10) 0%, rgba(15, 23, 42, 0) 70%);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

/* Navigation */
nav {
  background-color: rgba(15, 23, 42, 0.95);
  border-right: 1px solid var(--surface-border);
  padding: 1.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  width: 220px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

#brand-logo {
  padding: 0 1.25rem 1.25rem !important;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 0.75rem;
}

.brand {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.15rem;
  padding: 0.25rem 0;
}

.nav-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-left: 3px solid transparent;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
}

.nav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-left-color: rgba(59, 130, 246, 0.4);
}

.nav-btn.active {
  color: var(--text-main);
  background: rgba(59, 130, 246, 0.15);
  border-left: 3px solid var(--primary-color);
}

#btn-logout {
  margin-top: auto;
  border-top: 1px solid var(--surface-border);
}

/* Main Container */
main {
  margin-left: 220px;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem;
}

/* Cards (Glassmorphism) */
.glass-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);
  margin-bottom: 2rem;
  animation: fadeIn 0.15s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typography */
h1,
h2,
h3 {
  margin-bottom: 1rem;
  font-weight: 600;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
  color: var(--text-main);
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Grid Layouts */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  border: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-card.success .stat-value {
  color: var(--success-color);
}

.stat-card.danger .stat-value {
  color: var(--danger-color);
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  /* Como hijo de grid/flex, sin esto hereda min-width:auto y no puede encogerse
     (el contenido intrínseco de un date picker lo empujaba fuera de la caja). */
  min-width: 0;
}

label {
  font-weight: 500;
  color: var(--text-muted);
}

input,
select {
  width: 100%;
  /* min-width: 0 permite que el input se encoja por debajo de su ancho intrínseco
     dentro de grid/flex (los date pickers de Chrome miden ~180px y desbordaban). */
  min-width: 0;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
  height: 3rem;
  /* Forces all inputs including Date to have identical height */
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.btn {
  padding: 1rem 2rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.23);
}

.btn-success {
  background: var(--success-color);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39);
}

.btn-success:hover {
  background: var(--success-hover);
  transform: translateY(-2px);
}

/* Huge buttons for Loaders (Cargadores) */
.loader-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn-huge {
  padding: 2rem 1rem;
  font-size: 1.2rem;
  flex-direction: column;
  gap: 1rem;
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid var(--surface-border);
  color: var(--text-main);
}

.btn-huge:hover,
.btn-huge.selected {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.1);
  transform: scale(1.02);
}

.btn-huge.success:hover,
.btn-huge.success.selected {
  border-color: var(--success-color);
  background: rgba(16, 185, 129, 0.1);
}

/* Table */
.table-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  /* Prevents double vertical scrollbars inside the container */
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS Safari */
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 600px;
  /* Forces horizontal scroll instead of squeezing text */
}

th,
td {
  padding: 1rem;
  border-bottom: 1px solid var(--surface-border);
}

th {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  /* Prevents column headers from stacking uncomfortably */
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge.produccion {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.badge.despacho {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.badge.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.badge.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.badge.badge-info {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 2rem;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toast {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-left: 4px solid var(--success-color);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast.exiting {
  animation: slideOut 0.3s ease-in forwards;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 2px;
}

/* Home Grid */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.home-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  color: var(--text-main);
}

.home-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  background: rgba(30, 41, 59, 0.9);
}

.home-card h3 {
  margin: 0;
  font-size: 1.25rem;
}

.home-icon-wrapper {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 50%;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.text-primary {
  color: var(--primary-color);
}

.text-success {
  color: var(--success-color);
}

.text-danger {
  color: var(--danger-color);
}

.text-warning {
  color: #f59e0b;
}

.text-info {
  color: #0ea5e9;
}

/* Thumbnails */
.product-thumbnail {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface-border);
  object-fit: cover;
  /* Como ítem flex (lista de ventas) no debe encogerse si el nombre es largo. */
  flex-shrink: 0;
}

/* Filters */
.filters-container {
  display: flex;
  gap: 1rem;
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filters-container .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

.filters-container input,
.filters-container select {
  padding: 0.75rem;
}

.cursor-pointer {
  cursor: pointer;
}

.mb-2 {
  margin-bottom: 2rem;
}

/* Clickable Table Rows */
.hoverable-table tbody tr {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.hoverable-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.1);
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.92);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
  display: flex !important;
  /* Override the default .hidden which sets display:none to allow fade */
}

/* Modal Card */
.modal-card {
  width: 100%;
  max-width: 800px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.hidden .modal-card {
  transform: scale(0.9);
}

.btn-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: var(--transition);
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.modal-content {
  display: flex;
  gap: 2rem;
}

.modal-images {
  flex: 0 0 300px;
}

.modal-info {
  flex: 1;
}

.img-box {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px dashed var(--surface-border);
}

.img-title {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.img-placeholder {
  width: 100%;
  height: 150px;
  background: rgba(59, 130, 246, 0.05);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.info-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.info-value {
  font-weight: 600;
  font-size: 1.1rem;
}

/* btn-danger */
.btn-danger {
  background: var(--danger-color);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.39);
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

/* Custom Searchable Dropdown */
.search-dropdown-wrapper {
  position: relative;
  width: 100%;
}

.search-dropdown-input {
  width: 100%;
}

.search-dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgb(19, 36, 61);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  margin-top: 0.25rem;
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.search-dropdown-list.show {
  display: block;
}

.search-dropdown-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition);
}

.search-dropdown-item:last-child {
  border-bottom: none;
}

.search-dropdown-item:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* Resaltado por navegación con teclado (flechas) */
.search-dropdown-item.active {
  background: rgba(59, 130, 246, 0.38);
}

.search-dropdown-item-code {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-right: 0.5rem;
}

/* Tabs */
.tabs-container {
  display: flex;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 1rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: 1rem;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.categoria-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.categoria-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--surface-border);
}

.categoria-header h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.categoria-section .table-container {
  border-radius: 0;
  overflow-x: hidden;
}

/* ==============================================
   MANTENIMIENTO DIARIO CNC
   ============================================== */

.mant-hoy-container {
  display: flex;
  flex-direction: column;
}

.mant-scroll-area {
  padding-bottom: 84px;
  /* clear the fixed tab bar */
}

.mant-mode-switcher {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mant-mode-btn {
  padding: 0.38rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
}

.mant-mode-btn.active {
  background: var(--primary-color);
  color: #fff;
}

.mant-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgb(10, 16, 32);
  border-top: 1px solid var(--surface-border);
  z-index: 200;
}

.mant-tab-btn {
  flex: 1;
  padding: 0.85rem 0.4rem 0.65rem;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
}

.mant-tab-btn.active {
  color: var(--primary-color);
  border-top-color: var(--primary-color);
}

.mant-fab {
  position: fixed;
  bottom: 74px;
  right: 1.25rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5);
  z-index: 201;
  transition: var(--transition);
}

.mant-fab:hover {
  background: var(--primary-hover);
  transform: scale(1.08);
}

.mant-machine-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--surface-border);
}

.mant-momento-header {
  padding: 0.55rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid var(--surface-border);
  border-bottom: 1px solid var(--surface-border);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.mant-task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--surface-border);
  border-left: 3px solid transparent;
  transition: border-left-color 0.18s;
}

.mant-task-item.estado-ok {
  border-left-color: #10b981;
}

.mant-task-item.estado-no_realizado {
  border-left-color: #ef4444;
}

.mant-task-item.estado-no_corresponde {
  border-left-color: #f59e0b;
}

.mant-task-desc {
  font-size: 0.92rem;
  line-height: 1.4;
  font-weight: 500;
  margin: 0;
}

.mant-task-estado {
  font-size: 0.78rem;
  margin: 0.25rem 0 0;
}

.mant-task-estado.ok {
  color: #10b981;
}

.mant-task-estado.no_realizado {
  color: #ef4444;
}

.mant-task-estado.no_corresponde {
  color: #f59e0b;
}

.mant-task-estado.pendiente {
  color: var(--text-muted);
}

.mant-task-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.mant-task-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.18s;
  line-height: 1;
}

.mant-task-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.mant-task-btn.active-ok {
  background: rgba(16, 185, 129, 0.28);
  border-color: #10b981;
}

.mant-task-btn.active-no_realizado {
  background: rgba(239, 68, 68, 0.28);
  border-color: #ef4444;
}

.mant-task-btn.active-no_corresponde {
  background: rgba(245, 158, 11, 0.28);
  border-color: #f59e0b;
}

.mant-no-checklist {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.mant-obs-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

/* ─── MÓDULO VENTAS POS ─────────────────────────────────────────────────────── */

.ventas-main-card {
  max-width: 1200px;
  margin: 0 auto;
}

.ventas-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  max-width: 360px;
}

.ventas-mode-btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  background: transparent;
  font-family: var(--font-family);
}

.ventas-mode-btn.active {
  background: var(--primary-color);
  color: #fff;
}

.ventas-pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.25rem;
  min-height: 460px;
  align-items: start;
}

.ventas-product-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.ventas-product-item {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}


.ventas-product-item:hover,
.ventas-product-item.ventas-highlighted {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.1);
}

.ventas-cart-panel {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ventas-cart-items {
  flex: 1;
  min-height: 200px;
  max-height: 340px;
  overflow-y: auto;
}

.ventas-cart-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--surface-border);
}

.ventas-cart-item:last-child {
  border-bottom: none;
}

.ventas-cart-item.devolucion {
  opacity: 0.8;
}

.ventas-cart-footer {
  border-top: 1px dashed var(--surface-border);
  padding-top: 1rem;
  margin-top: 0.75rem;
}

@media (max-width: 900px) {
  .ventas-pos-layout {
    grid-template-columns: 1fr;
  }

  .ventas-cart-panel {
    order: -1;
  }
}

/* ── Mobile top bar ───────────────────────────────────────────── */
#mobile-header {
  display: none;
}

#nav-toggle {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

#nav-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

#nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
}

/* ─── MÓDULO CONTROL DE CALIDAD ─────────────────────────────────────────────── */

.qc-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.qc-insp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

/* ==============================================================
   RESPONSIVE MÓVIL/TABLET (≤768px) — SECCIÓN ÚNICA CONSOLIDADA
   Todas las reglas de este breakpoint viven acá, agrupadas por
   área, en el mismo orden relativo que tenían antes de unificarse
   (el orden importa: p. ej. main{padding} debe preceder a
   main{padding-top}). Agregar futuras reglas ≤768px SOLO acá.
   ============================================================== */
@media (max-width: 768px) {

  /* ── Layout general: modales, nav, grillas ── */
  .modal-content {
    flex-direction: column;
  }

  .modal-images {
    flex: none;
  }

  nav {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }

  .loader-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Tabs: scroll horizontal cuando no entran (Producción, Salidas, etc.) ── */
  .tabs-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .tab-btn {
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ── Contenido principal y tarjetas ── */
  main {
    padding: 1rem;
  }

  .glass-card {
    padding: 1.25rem;
  }

  /* ── Barra de reportes por rango de fechas ── */
  .report-range-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    padding: 0.75rem !important;
  }

  .report-range-bar .form-group {
    margin-bottom: 0;
  }

  .report-range-bar .btn {
    width: 100% !important;
    height: auto !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
  }

  /* ── Grillas de formularios ── */
  .user-form-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .prod-top-grid,
  .prod-item-grid,
  .desp-item-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Tablas: compactas, y columnas secundarias ocultas por vista ── */
  .table-container table {
    min-width: 0;
  }

  .table-container th,
  .table-container td {
    padding: 0.6rem 0.5rem;
    font-size: 0.875rem;
  }

  #view-stock table thead tr th:nth-child(1),
  #view-stock table tbody tr td:nth-child(1) {
    display: none;
  }

  #view-productos table thead tr th:nth-child(1),
  #view-productos table tbody tr td:nth-child(1),
  #view-productos table thead tr th:nth-child(5),
  #view-productos table tbody tr td:nth-child(5) {
    display: none;
  }

  #prod-activas table thead tr th:nth-child(4),
  #prod-activas table tbody tr td:nth-child(4),
  #prod-activas table thead tr th:nth-child(6),
  #prod-activas table tbody tr td:nth-child(6) {
    display: none;
  }

  #prod-anuladas table thead tr th:nth-child(5),
  #prod-anuladas table tbody tr td:nth-child(5) {
    display: none;
  }

  #salidas-activas table thead tr th:nth-child(5),
  #salidas-activas table tbody tr td:nth-child(5),
  #salidas-anuladas table thead tr th:nth-child(5),
  #salidas-anuladas table tbody tr td:nth-child(5) {
    display: none;
  }

  #view-historial-insumos table thead tr th:nth-child(3),
  #view-historial-insumos table tbody tr td:nth-child(3),
  #view-historial-insumos table thead tr th:nth-child(7),
  #view-historial-insumos table tbody tr td:nth-child(7) {
    display: none;
  }

  /* ── Insumos ── */
  .insumos-header {
    flex-direction: column;
  }

  .insumos-header .btn-success {
    width: 100% !important;
    padding: 0.75rem 1.5rem !important;
  }

  #view-insumos table thead tr th:nth-child(2),
  #view-insumos table tbody tr td:nth-child(2),
  #view-insumos table thead tr th:nth-child(4),
  #view-insumos table tbody tr td:nth-child(4) {
    display: none;
  }

  /* ── Filtros ── */
  .filters-container {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .filters-container .form-group {
    min-width: 100%;
  }

  /* ── Mantenimiento CNC ── */
  .mant-task-btn {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }

  .mant-task-item {
    padding: 0.85rem 0.75rem;
    gap: 0.5rem;
  }

  /* ── Barra superior móvil y navegación lateral ── */
  #mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 1rem;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid var(--surface-border);
    z-index: 150;
  }

  nav {
    transform: translateX(-220px);
    top: 0;
  }

  nav.nav-open {
    transform: translateX(0);
  }

  main {
    margin-left: 0;
    padding-top: calc(52px + 1.5rem);
  }

  #nav-overlay.nav-open {
    display: block;
  }

  /* ── Control de Calidad ── */

  /* Tabs: equal width, fit on screen */
  #view-qc .tab-btn {
    flex: 1;
    padding: 0.65rem 0.2rem;
    font-size: 0.8rem;
    text-align: center;
    white-space: nowrap;
  }

  /* Hoy header: stack button */
  #qc-tab-hoy>div:first-child {
    flex-direction: column;
    align-items: stretch !important;
  }

  #qc-tab-hoy>div:first-child .btn {
    width: 100% !important;
    justify-content: center;
  }

  /* Inspection card: stack info + button */
  .qc-insp-header {
    flex-direction: column;
  }

  .qc-insp-header>.btn {
    width: 100% !important;
    justify-content: center;
  }

  /* Config tab: stack columns */
  .qc-config-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* QC modals: bottom sheet */
  #qc-inspeccion-modal,
  #qc-muestra-modal {
    align-items: flex-end;
    padding: 0;
  }

  #qc-inspeccion-modal .modal-card,
  #qc-muestra-modal .modal-card {
    max-width: 100% !important;
    max-height: 92vh;
    border-radius: 1rem 1rem 0 0;
  }

  /* Historial filters: stack */
  #qc-tab-historial>div:first-child {
    flex-direction: column;
    align-items: stretch !important;
  }

  #qc-tab-historial .form-group {
    min-width: 0 !important;
  }

  #qc-tab-historial .btn {
    width: 100% !important;
  }

  /* OK/NO OK: bigger tap targets */
  .qc-okbtn,
  .qc-nokbtn {
    min-height: 44px;
    padding: 0.5rem 1.25rem !important;
    font-size: 0.95rem !important;
  }

  /* Dashboard: 2 columns */
  #qc-dashboard-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ==============================================================
   RESPONSIVE TELÉFONOS (≤480px) — ajustes extra sobre los de 768px
   Pantallas de 360-430px usadas en planta. Solo afinar densidad;
   los cambios de layout ya ocurren en el bloque de 768px.
   ============================================================== */
@media (max-width: 480px) {

  /* Contenido y tarjetas: menos aire, más espacio útil */
  main {
    padding: 0.75rem;
    padding-top: calc(52px + 1rem);
  }

  .glass-card {
    padding: 1rem 0.85rem;
  }

  /* Tablas más compactas todavía */
  .table-container th,
  .table-container td {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
  }

  /* Inputs y selects: altura y tipografía de dedo, sin zoom de iOS
     (16px evita que Safari haga zoom automático al enfocar) */
  input,
  select {
    font-size: 16px;
    padding: 0.6rem 0.75rem;
  }

  /* Botones de acción a ancho completo dentro de formularios */
  .loader-grid .btn,
  .form-group .btn {
    width: 100%;
  }

  /* Formularios de usuario: una sola columna en pantallas muy chicas */
  .user-form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Filtros: sin fondo ni padding extra, ocupan menos alto */
  .filters-container {
    gap: 0.4rem;
    padding: 0.5rem;
  }

  /* Modales: usar todo el ancho disponible */
  .modal-card,
  .modal-content {
    max-width: 100%;
  }

  /* Títulos de vista algo más chicos para que no partan en 3 líneas */
  h1 {
    font-size: 1.35rem;
  }

  h2 {
    font-size: 1.15rem;
  }
}

/* ─── Banner de nueva versión disponible ─── */
#version-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #f59e0b;
  color: #1a1a1a;
  text-align: center;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* Respeta a usuarios/equipos que piden menos movimiento. No cambia el comportamiento
   por defecto: SOLO se activa si el sistema operativo tiene "reducir movimiento". */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}