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

body {
  font-family: 'Roboto', Tahoma, Geneva, Verdana, sans-serif;
  background: #E8F4F8;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 260px;
  background: #ffffff;
  color: #333333;
  flex-shrink: 0;
  overflow-y: auto;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.04);
  border-right: 1px solid #E5F2F7;
  z-index: 10;
}

.sidebar-header {
  padding: 30px 20px;
  background: #ffffff;
  border-bottom: 1px solid #E5F2F7;
}

.sidebar-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #1C5F7B, #2E86AB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  padding: 25px 0;
}

.nav-item {
  margin: 8px 16px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: #5c6c75;
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: #F0F8FC;
  color: #1C5F7B;
  transform: translateX(6px);
  border: 1px solid #E5F2F7;
  box-shadow: 0 4px 12px rgba(28, 95, 123, 0.05);
}

.nav-link.active {
  background: linear-gradient(135deg, #1C5F7B, #2E86AB);
  color: white;
  font-weight: 700;
  box-shadow: 0 6px 15px rgba(28, 95, 123, 0.3);
  border: none;
}

.nav-icon {
  margin-right: 14px;
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  transition: transform 0.3s ease;
}

.nav-link:hover .nav-icon {
  transform: scale(1.1);
}

.main-content {
  flex: 1;
  overflow-y: auto;
  background: #FAFBFC;
}

.content-header {
  background: linear-gradient(90deg, #ffffff, #F0F8FC);
  padding: 25px 30px;
  border-bottom: 2px solid #E5F2F7;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.content-header h2 {
  color: #1C5F7B;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logged-store-badge {
  color: #1C5F7B;
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  padding: 5px 0;
  padding-left: 15px;
  border-left: 4px solid #5DADE2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logged-store-badge .store-icon {
  font-size: 1.4rem;
}

@media (max-width: 480px) {
  .logged-store-badge {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  .content-header h2 {
    font-size: 1.3rem;
  }
}

.content-body {
  padding: 30px;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

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

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

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

.card {
  background: linear-gradient(145deg, #ffffff, #fdfdfd);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  margin-bottom: 25px;
  overflow: visible;
  border: none;
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
}

.card-header {
  padding: 25px;
  background: transparent;
  border-bottom: 2px solid #E5F2F7;
  font-weight: 800;
  color: #1C5F7B;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body {
  padding: 25px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

.form-group label {
  margin-bottom: 8px;
  font-weight: 600;
  color: #2E86AB;
  font-size: 0.9rem;
}

input,
select,
textarea {
  padding: 12px;
  border: 2px solid #E5F2F7;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  background: #fdfdfd;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #5DADE2;
  box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.02);
  background: white;
}

/* Hide spin buttons in number inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.autocomplete-container {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #5DADE2;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.autocomplete-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #E5F2F7;
  transition: background 0.2s ease;
}

.autocomplete-item:hover {
  background: #F0F8FC;
}

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

.autocomplete-code {
  font-weight: 600;
  color: #2E86AB;
}

.autocomplete-name {
  color: #6c757d;
  font-size: 0.85rem;
  margin-top: 2px;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background: #5DADE2;
  color: white;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-warning {
  background: #ffc107;
  color: #212529;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-info {
  background: #17a2b8;
  color: white;
}

.table-container {
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  border: none;
  background: #F0F8FC;
  padding: 10px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

th,
td {
  padding: 12px 15px;
  text-align: left;
  border: none;
}

th {
  background: transparent;
  color: #6c757d;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

tbody tr {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}

tbody tr:hover {
  transform: scale(1.01);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  z-index: 10;
  position: relative;
}

td:first-child {
  border-radius: 8px 0 0 8px;
}

td:last-child {
  border-radius: 0 8px 8px 0;
}

.status-normal {
  background: #d4edda;
  color: #155724;
}

.status-low {
  background: #fff3cd;
  color: #856404;
}

.status-zero {
  background: #f8d7da;
  color: #721c24;
}

.text-success {
  color: #28a745;
  font-weight: 600;
}

.text-danger {
  color: #dc3545;
  font-weight: 600;
}

.text-warning {
  color: #ffc107;
  font-weight: 600;
}

.text-info {
  color: #17a2b8;
  font-weight: 600;
}

.message {
  padding: 12px 15px;
  border-radius: 8px;
  margin: 15px 0;
  font-weight: 500;
}

.message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.message.warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.message.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.loading {
  display: none;
  text-align: center;
  padding: 20px;
  color: #5DADE2;
  font-style: italic;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(145deg, #ffffff, #fdfdfd);
  padding: 25px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
  border-left: 5px solid #5DADE2;
  border-top: 1px solid #E5F2F7;
  border-right: 1px solid #E5F2F7;
  border-bottom: 1px solid #E5F2F7;
  transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #2E86AB;
  margin-bottom: 5px;
}

.stat-label {
  color: #6c757d;
  font-size: 0.9rem;
  font-weight: 500;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: -100%;
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }
}

.login-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #E8F4F8;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h2 {
  color: #2E86AB;
  margin-bottom: 20px;
}

.login-step {
  display: none;
}

.login-step.active {
  display: block;
}

.tools-grid {
  display: flex;
  flex-direction: row;
  gap: 15px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.btn-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 120px;
  aspect-ratio: 1 / 1;
  text-align: center;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border: none;
  cursor: pointer;
  color: white;
}

.btn-tool:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.btn-tool .icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.btn-tool-warning {
  background-color: #f39c12;
}

.btn-tool-danger {
  background-color: #e74c3c;
}

.btn-tool-info {
  background-color: #3498db;
}

.btn-tool-primary {
  background-color: #2E86AB;
}

.btn-tool-secondary {
  background-color: #7f8c8d;
}

.btn-tool-success {
  background-color: #27ae60;
}

/* Estilos Premium para Dashboard de Ventas */
.sales-stat-card {
  padding: 30px 20px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.sales-stat-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.sales-stat-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
  transform: rotate(45deg);
  pointer-events: none;
}

.sales-stat-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.premium-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.premium-table th {
  background: transparent;
  color: #6c757d;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 1px;
  border: none;
  padding: 10px 15px;
}

.premium-table tbody tr {
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.premium-table tbody tr:hover {
  transform: scale(1.02);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  z-index: 10;
  position: relative;
}

.premium-table td {
  border: none;
  padding: 15px;
}

.premium-table td:first-child {
  border-radius: 8px 0 0 8px;
  font-weight: bold;
}

.premium-table td:last-child {
  border-radius: 0 8px 8px 0;
  font-weight: bold;
  color: #2E86AB;
}

.rank-1 {
  color: #f39c12;
  font-size: 1.3rem;
  text-shadow: 0 0 5px rgba(243, 156, 18, 0.4);
}

.rank-2 {
  color: #bdc3c7;
  font-size: 1.2rem;
}

.rank-3 {
  color: #d35400;
  font-size: 1.1rem;
}

/* Mobile Responsive Additions */
.mobile-header {
  display: none;
  background: linear-gradient(180deg, #1C5F7B 0%, #174b62 100%);
  color: white;
  padding: 15px 20px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  z-index: 1001;
}

.mobile-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: 1px;
}

.hamburger-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.sidebar-overlay {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  visibility: visible;
  opacity: 1;
}

#inventario .table-container {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}

#inventario .table-container table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #F0F8FC;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #2E86AB;
}

input:checked+.slider:before {
  transform: translateX(22px);
}

input:focus+.slider {
  box-shadow: 0 0 1px #2E86AB;
}

.toggle-label-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: #f8f9fa;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #e0e0e0;
  transition: all 0.3s;
  user-select: none;
  flex-shrink: 0;
}

.toggle-label-container:hover {
  background: #f1f3f5;
}

.toggle-text {
  font-weight: bold;
  color: #555;
  font-size: 0.9rem;
  transition: color 0.3s;
}

input:checked~.toggle-text {
  color: #2E86AB;
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .content-header {
    padding: 15px 20px;
  }

  .content-body {
    padding: 15px;
  }

  .main-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .tab-content {
    flex: 1;
    overflow-y: auto;
  }

  .table-container {
    padding: 0;
  }

  td,
  th {
    padding: 10px;
    font-size: 0.85rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .card-header>div {
    width: 100%;
    justify-content: space-between;
    margin-top: 10px;
  }
}

/* ==============================================================
   ESTILOS DE IMPRESIÓN (TICKET)
============================================================== */
@media print {
  body * {
    visibility: hidden;
  }
  
  #ticketImpresion, #ticketImpresion * {
    visibility: visible;
  }
  
  #ticketImpresion {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 300px; /* Adaptable pero con un tope razonable para previsualización */
    margin: 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace;
    color: #000;
    font-size: 12px;
  }

  @page {
    margin: 0; /* Quita márgenes del navegador */
  }
  
  #ticketImpresion .ticket-header {
    text-align: center;
    margin-bottom: 10px;
  }
  
  #ticketImpresion .ticket-header h2 {
    margin: 0 0 5px 0;
    font-size: 16px;
  }
  
  #ticketImpresion .ticket-header p {
    margin: 2px 0;
    font-size: 12px;
  }
  
  #ticketImpresion table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
  }
  
  #ticketImpresion th, #ticketImpresion td {
    text-align: left;
    padding: 3px 1px;
    font-size: 11px;
  }
  
  #ticketImpresion th {
    border-bottom: 1px dashed #000;
    border-top: 1px dashed #000;
  }
  
  #ticketImpresion .ticket-total {
    border-top: 1px dashed #000;
    margin-top: 5px;
    padding-top: 5px;
    text-align: right;
    font-weight: bold;
    font-size: 14px;
  }

  #ticketImpresion .ticket-footer {
    text-align: center;
    margin-top: 15px;
    font-size: 12px;
    border-top: 1px dashed #000;
    padding-top: 5px;
  }
}

/* ===== Password Toggle ===== */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  flex: 1;
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #999;
  transition: color 0.2s;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-password:hover {
  color: #1C5F7B;
}

.eye-icon {
  width: 18px;
  height: 18px;
  display: block;
  transition: opacity 0.15s;
}