/* ===================================
   MODERN POS SYSTEM - DESIGN SYSTEM
   =================================== */

/* CSS Variables */
:root {
  /* Colors */
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;

  /* Semantic Colors */
  --success: 142 76% 36%;
  --warning: 38 92% 50%;
  --danger: 0 84% 60%;
  --info: 199 89% 48%;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* iOS Safe Area (para dispositivos con notch) */
  --safe-area-inset-top: env(safe-area-inset-top);
  --safe-area-inset-right: env(safe-area-inset-right);
  --safe-area-inset-bottom: env(safe-area-inset-bottom);
  --safe-area-inset-left: env(safe-area-inset-left);
}

[data-theme="dark"] {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 4.9%;
  --card-foreground: 210 40% 98%;
  --popover: 222.2 84% 4.9%;
  --popover-foreground: 210 40% 98%;
  --primary: 217.2 91.2% 59.8%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  overflow-x: hidden;
  /* iOS Safe Area Support */
  padding-top: var(--safe-area-inset-top);
  padding-right: var(--safe-area-inset-right);
  padding-bottom: var(--safe-area-inset-bottom);
  padding-left: var(--safe-area-inset-left);
}

.antialiased {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===================================
   LOGIN SCREEN
   =================================== */

.login-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(217 91% 45%) 100%);
  padding: 20px;
  overflow: hidden;
}

.login-container::before,
.login-container::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 255 255 / 0.15) 0%, rgb(255 255 255 / 0) 70%);
  pointer-events: none;
}

.login-container::before {
  top: -120px;
  left: -120px;
}

.login-container::after {
  bottom: -150px;
  right: -120px;
}

.login-card {
  position: relative;
  z-index: 1;
  background: hsl(var(--card));
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  animation: slideUp 0.4s ease-out;
  border: 1px solid rgb(255 255 255 / 0.3);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-header {
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(217 91% 45%) 100%);
  color: white;
  padding: 34px 30px;
  text-align: center;
}

.login-icon {
  margin-bottom: 16px;
  display: inline-block;
  animation: bounce 2s infinite;
}

.login-icon svg {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.login-header h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.login-header p {
  opacity: 0.9;
  font-size: 14px;
}

.login-body {
  padding: 26px 30px 28px;
}

.login-intro {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 14px;
  text-align: center;
  font-weight: 500;
}

.login-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.login-step {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / 0.2);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.password-field {
  position: relative;
}

.login-body .form-input,
.login-body .form-select {
  min-height: 46px;
}

.password-field .form-input {
  padding-right: 96px;
}

.btn-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: none;
  border-radius: 8px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-password-toggle:hover {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.login-safe-tip {
  font-size: 12px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.login-body #loginBtn {
  min-height: 48px;
  font-size: 16px;
}

@media (max-width: 520px) {
  .login-body {
    padding: 22px 20px 24px;
  }

  .login-header {
    padding: 28px 20px;
  }

  .login-step {
    font-size: 10px;
  }
}

/* ===================================
   APP CONTAINER
   =================================== */

.app-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: hsl(var(--muted) / 0.3);
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    padding-bottom: 70px;
  }
}

/* ===================================
   SIDEBAR
   =================================== */

.sidebar {
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid hsl(var(--border));
  background: linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--muted) / 0.25) 100%);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid hsl(var(--primary) / 0.35);
  background: linear-gradient(135deg, hsl(var(--primary) / 0.15) 0%, hsl(var(--primary) / 0.05) 100%);
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  font-family: 'Inter', serif;
}

.logo-branding {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.logo-text {
  color: hsl(var(--foreground));
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.05;
}

.logo-subtitle {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-item.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.nav-item svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: hsl(var(--primary) / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--primary));
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

.btn-logout {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: hsl(var(--destructive));
  color: white;
}

/* ===================================
   MAIN CONTENT
   =================================== */

.main-content {
  overflow-y: auto;
  min-height: 100vh;
}

.view-container {
  padding: 24px;
  max-width: 1800px;
  margin: 0 auto;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}

.view-title h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.view-subtitle {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
}

.view-actions {
  display: flex;
  gap: 12px;
}

.user-badge {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

/* ===================================
   POS LAYOUT
   =================================== */

.pos-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  height: calc(100vh - 140px);
}

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

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

/* Products Section */
.pos-products {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
}

.search-box {
  position: relative;
  background: hsl(var(--card));
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 14px 48px 14px 52px; /* Más espacio para lupa (left) y botón limpiar (right) */
  border: 2px solid hsl(var(--border));
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

.categories-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.categories-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  padding: 10px 20px;
  border: 2px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  color: hsl(var(--foreground));
}

.category-chip:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
}

.category-chip.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.products-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 4px;
  align-content: start;
}

@media (max-width: 640px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

.product-card {
  background: hsl(var(--card));
  border: 2px solid hsl(var(--border));
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-card:hover {
  border-color: hsl(var(--primary) / 0.3);
  box-shadow: var(--shadow-sm);
}

.product-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.product-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: hsl(var(--foreground));
}

.product-stock {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.stock-ok {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
}

.stock-low {
  background: hsl(var(--warning) / 0.1);
  color: hsl(var(--warning));
}

.stock-out {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.product-price {
  font-size: 20px;
  font-weight: 800;
  color: hsl(var(--primary));
  flex: 1;
}

.btn-add-product {
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: hsl(var(--primary));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-add-product:hover {
  background: hsl(var(--primary) / 0.9);
  transform: scale(1.05);
}

.btn-add-product.btn-granel {
  opacity: 0.5;
  cursor: not-allowed;
  font-size: 20px;
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.3);
}

.btn-add-product:active {
  transform: translateY(0);
}

.btn-add-product:disabled {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
  opacity: 0.6;
}

/* Cart Section */
.pos-cart {
  background: hsl(var(--card));
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .pos-cart {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    z-index: 1000;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .pos-cart.active {
    transform: translateX(0);
  }
}

.cart-header {
  padding: 20px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-header h3 {
  font-size: 20px;
  font-weight: 700;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.btn-close-cart {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-close-cart:hover {
  background: hsl(var(--destructive));
  color: white;
}

@media (max-width: 1024px) {
  .btn-close-cart {
    display: flex;
  }
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: hsl(var(--muted-foreground));
  text-align: center;
  padding: 40px 20px;
}

.cart-empty svg {
  margin-bottom: 16px;
  opacity: 0.3;
}

.cart-empty p {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.cart-empty span {
  font-size: 13px;
  opacity: 0.7;
}

.cart-item {
  background: hsl(var(--secondary));
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.cart-item-remove {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cart-item-remove:hover {
  background: hsl(var(--destructive));
  color: white;
}

.cart-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: hsl(var(--card));
  border-radius: 8px;
  padding: 4px;
}

.cart-item-controls button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: hsl(var(--primary));
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.cart-item-controls button:hover {
  background: hsl(217 91% 45%);
}

.cart-item-quantity {
  min-width: 32px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.cart-item-price {
  font-size: 16px;
  font-weight: 700;
  color: hsl(var(--primary));
}

.cart-footer {
  padding: 20px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 1024px) {
  .cart-footer {
    padding-bottom: 100px;
  }
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
}

.total-amount {
  font-size: 28px;
  font-weight: 800;
  color: hsl(var(--primary));
}

/* ===================================
   BUTTONS
   =================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
  background: hsl(217 91% 45%);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
  background: hsl(var(--muted));
}

.btn-success {
  background: hsl(var(--success));
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: hsl(142 76% 32%);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: hsl(var(--destructive));
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: hsl(0 84% 50%);
  box-shadow: var(--shadow-md);
}

.btn-block {
  width: 100%;
}

/* ===================================
   FORMS
   =================================== */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: hsl(var(--foreground));
}

.form-input,
.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid hsl(var(--border));
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

.form-input[readonly],
.form-select[disabled] {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
  opacity: 0.7;
}

.form-input[readonly]:focus,
.form-select[disabled]:focus {
  border-color: hsl(var(--border));
  box-shadow: none;
}

.input-helper {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: hsl(var(--foreground));
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  border-radius: 4px;
  border: 2px solid hsl(var(--border));
}

.checkbox-label input[type="checkbox"]:checked {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.checkbox-label span {
  font-weight: 500;
}

/* ===================================
   MODALS
   =================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-large {
  max-width: 600px;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-close:hover {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
}

.modal-footer .btn {
  white-space: nowrap;
}

.modal-footer .btn-danger {
  margin-right: auto;
}

/* Checkout Modal */
.checkout-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: hsl(var(--secondary));
  border-radius: 12px;
  margin-bottom: 24px;
}

.checkout-total span:first-child {
  font-size: 15px;
  font-weight: 600;
}

.checkout-amount {
  font-size: 32px;
  font-weight: 800;
  color: hsl(var(--primary));
}

.payment-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.payment-method {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 2px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: hsl(var(--foreground));
}

.payment-method:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
}

.payment-method.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: white;
}

.payment-method svg {
  width: 32px;
  height: 32px;
}

.payment-method span {
  font-size: 13px;
  font-weight: 600;
}

.cash-input-area {
  display: none;
}

.cash-input-area.visible {
  display: block;
}

.quick-cash {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.cash-btn {
  padding: 12px;
  border: 2px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  color: hsl(var(--foreground));
}

.cash-btn:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
}

.change-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: hsl(var(--success) / 0.1);
  border-radius: 10px;
  margin-top: 16px;
}

.change-display span:first-child {
  font-size: 15px;
  font-weight: 600;
  color: hsl(var(--success));
}

.change-amount {
  font-size: 24px;
  font-weight: 800;
  color: hsl(var(--success));
}

/* Barra de Progreso de Pago Mixto */
.progreso-pago {
  margin-top: 20px;
  padding: 16px;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.1), hsl(var(--primary) / 0.05));
  border-radius: 12px;
  border: 2px solid hsl(var(--primary) / 0.3);
}

.progreso-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progreso-label {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.progreso-contador {
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

.progreso-bar-container {
  width: 100%;
  height: 12px;
  background: hsl(var(--muted));
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progreso-bar {
  height: 100%;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--primary) / 0.8));
  transition: width 0.4s ease, background 0.3s ease;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

.progreso-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progreso-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}

.progreso-info span:first-child {
  color: hsl(var(--success));
}

.texto-pendiente {
  color: hsl(var(--destructive)) !important;
  font-weight: 700;
}

/* Pagos Registrados (Pago Mixto) */
#pagosRegistrados {
  margin-top: 20px;
  padding: 16px;
  background: hsl(var(--secondary));
  border-radius: 12px;
  border: 2px solid hsl(var(--primary) / 0.2);
}

.pagos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pagos-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin: 0;
}

.badge-mixto {
  font-size: 12px;
  font-weight: 700;
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.15);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid hsl(var(--primary) / 0.3);
}

.pagos-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.pago-registrado {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: hsl(var(--card));
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  transition: all 0.2s;
}

.pago-registrado:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}

.pago-numero {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.pago-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.pago-metodo {
  font-size: 14px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.pago-monto {
  font-size: 16px;
  font-weight: 700;
  color: hsl(var(--primary));
  margin-left: auto;
}

.btn-remove-pago {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.btn-remove-pago:hover {
  background: hsl(var(--destructive));
  color: white;
  transform: scale(1.1);
}

.pagos-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: hsl(var(--primary) / 0.1);
  border-radius: 8px;
  margin-top: 8px;
  border-top: 2px solid hsl(var(--primary) / 0.2);
}

.pagos-total span {
  font-size: 14px;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.total-pagado {
  font-size: 18px;
  font-weight: 800;
  color: hsl(var(--primary)) !important;
}

#montoPendiente {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: hsl(var(--destructive) / 0.1);
  border-radius: 10px;
  margin-top: 16px;
  border: 2px solid hsl(var(--destructive) / 0.3);
}

#montoPendiente span:first-child {
  font-size: 15px;
  font-weight: 600;
  color: hsl(var(--destructive));
}

#pendienteAmount {
  font-size: 24px;
  font-weight: 800;
  color: hsl(var(--destructive));
}

/* ===================================
   INVENTORY VIEW
   =================================== */

.inventory-content,
.sales-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.inventory-stats,
.sales-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.stat-card {
  background: hsl(var(--card));
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid hsl(var(--border));
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.bg-blue { background: hsl(var(--primary)); }
.bg-green { background: hsl(var(--success)); }
.bg-orange { background: hsl(var(--warning)); }
.bg-red { background: hsl(var(--destructive)); }

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: hsl(var(--foreground));
}

.stat-card-large {
  background: hsl(var(--card));
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid hsl(var(--border));
}

.stat-value-large {
  font-size: 36px;
  font-weight: 800;
  color: hsl(var(--foreground));
}

/* Tables */
.inventory-table-container,
.sales-table-container {
  background: hsl(var(--card));
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid hsl(var(--border));
  overflow: hidden;
}

.inventory-table,
.sales-table {
  width: 100%;
  border-collapse: collapse;
}

.inventory-table thead,
.sales-table thead {
  background: hsl(var(--secondary));
}

.inventory-table th,
.sales-table th {
  padding: 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: hsl(var(--muted-foreground));
}

.inventory-table td,
.sales-table td {
  padding: 16px;
  border-top: 1px solid hsl(var(--border));
  font-size: 14px;
}

.inventory-table tbody tr:hover,
.sales-table tbody tr:hover {
  background: hsl(var(--secondary) / 0.5);
}

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

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.badge-success {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
}

.badge-warning {
  background: hsl(var(--warning) / 0.1);
  color: hsl(var(--warning));
}

.badge-danger {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

/* ===================================
   BOTTOM NAV (Mobile)
   =================================== */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: hsl(var(--card));
  border-top: 1px solid hsl(var(--border));
  padding: 8px;
  z-index: 1000;
}

@media (max-width: 1024px) {
  .bottom-nav {
    display: flex;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--muted-foreground) / 0.3) transparent;
  }

  .bottom-nav::-webkit-scrollbar {
    height: 4px;
  }

  .bottom-nav::-webkit-scrollbar-track {
    background: transparent;
  }

  .bottom-nav::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.3);
    border-radius: 2px;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  min-width: 80px;
  white-space: nowrap;
}

.bottom-nav-item.active {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

/* ===================================
   UTILITIES
   =================================== */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: hsl(var(--muted-foreground));
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-top: 16px;
}

.alert-warning {
  background: hsl(var(--warning) / 0.1);
  color: hsl(var(--warning));
  border: 1px solid hsl(var(--warning) / 0.3);
}

.sack-info {
  background: hsl(var(--secondary));
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.sack-info p {
  margin-bottom: 8px;
  font-size: 14px;
}

.sack-info p:last-child {
  margin-bottom: 0;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
  .view-container {
    padding: 16px;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .view-title h2 {
    font-size: 24px;
  }

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

  .payment-methods {
    grid-template-columns: 1fr;
  }

  .quick-cash {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    margin: 8px;
    max-height: calc(100vh - 16px);
    padding: 16px;
  }

  .modal-large {
    max-width: calc(100vw - 16px);
    width: calc(100vw - 16px);
    margin: 8px;
  }

  .modal-header {
    padding: 12px 16px;
    margin: -16px -16px 16px -16px;
  }

  .modal-header h3 {
    font-size: 16px;
  }

  .modal-body {
    padding: 16px;
    margin: 0 -16px;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    padding: 12px 16px 16px;
    margin: 16px -16px -16px -16px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  }

  /* Checkout Total más compacto */
  .checkout-total {
    padding: 12px 16px;
    margin-bottom: 16px;
  }

  .checkout-amount {
    font-size: 24px;
  }

  /* Botones de pago más compactos */
  .payment-method {
    padding: 12px 8px;
    gap: 6px;
  }

  .payment-method svg {
    width: 24px;
    height: 24px;
  }

  .payment-method span {
    font-size: 11px;
  }

  /* Quick cash más compacto */
  .quick-cash {
    gap: 6px;
    margin-top: 12px;
  }

  .cash-btn {
    padding: 10px 8px;
    font-size: 13px;
  }

  /* Form groups más compactos */
  .form-group {
    margin-bottom: 12px;
  }

  .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .form-input {
    padding: 10px 12px;
    font-size: 14px;
  }

  /* Calculadora optimizada para móvil */
  .btn-calc, .btn-calc-op, .btn-calc-igual {
    padding: 12px !important;
    font-size: 16px !important;
  }

  #displayCalculadora {
    font-size: 20px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
  }

  /* Sección descuento más compacta */
  #seccionDescuento {
    padding: 12px !important;
    margin-bottom: 12px !important;
  }

  #seccionDescuento label {
    font-size: 13px !important;
    margin-bottom: 8px !important;
  }

  #seccionDescuento button {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  /* Change display más compacto */
  .change-display {
    padding: 12px;
    margin-top: 12px;
  }

  .change-amount {
    font-size: 20px;
  }

  /* Alert más compacto */
  .alert {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* Search box en granel más compacto */
  .search-box {
    margin-bottom: 12px;
  }

  .search-input {
    padding: 12px 48px 12px 50px; /* Mantener espacio para íconos en móvil */
    font-size: 14px;
  }
}

@media (max-width: 640px) {
  .products-grid {
    grid-template-columns: 1fr;
  }

  .product-card {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 8px;
  }

  .product-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .product-name {
    font-size: 16px;
    font-weight: 700;
    -webkit-line-clamp: 3;
  }

  .product-footer {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .product-price {
    font-size: 22px;
    flex: 1;
  }

  .btn-add-product {
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-size: 26px;
  }

  .modal-footer {
    flex-direction: column;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    padding: 12px 16px;
  }

  /* Botones más compactos en general */
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .btn-secondary {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Grid de 2 columnas para payment methods en muy pequeños */
  .payment-methods {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

/* ===================================
   BARCODE SYSTEM
   =================================== */

/* Barcode Search in POS */
.barcode-search {
  border: 2px solid hsl(var(--primary) / 0.3);
  background: hsl(var(--primary) / 0.05);
}

.barcode-search .search-input {
  background: hsl(var(--primary) / 0.05);
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.barcode-search .search-input:focus {
  background: white;
  border-color: hsl(var(--primary));
}

/* Asignar Códigos View */
.asignar-content {
  max-width: 1200px;
}

.product-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.product-row:hover {
  border-color: hsl(var(--primary));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Codigo de barras badges */
.codigo-asignado {
  color: hsl(var(--success));
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sin-codigo {
  color: hsl(var(--warning));
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Scanner Modal Enhancements */
#reader {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
}

#escanerStatus {
  margin-top: 16px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
}

/* ===================================
   DASHBOARD
   =================================== */

/* Dashboard */
.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.kpi-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 16px;
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.kpi-icon.bg-green { background: hsl(142 76% 36% / 0.1); }
.kpi-icon.bg-blue { background: hsl(217 91% 60% / 0.1); }
.kpi-icon.bg-purple { background: hsl(271 91% 65% / 0.1); }
.kpi-icon.bg-orange { background: hsl(25 95% 53% / 0.1); }

.kpi-content {
    flex: 1;
}

.kpi-label {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    margin: 0 0 4px 0;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
    color: hsl(var(--foreground));
}

.kpi-change {
    font-size: 13px;
    font-weight: 600;
    margin: 4px 0 0 0;
    color: hsl(142 76% 36%);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.chart-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 16px;
    padding: 24px;
}

.chart-card-wide {
    grid-column: span 2;
}

.chart-card-small {
    grid-column: span 1;
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
}

.chart-header p {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    margin: 0 0 20px 0;
}

.chart-container {
    position: relative;
    height: 300px;
}

.vendedores-table {
    width: 100%;
    border-collapse: collapse;
}

.vendedores-table th,
.vendedores-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid hsl(var(--border));
}

.vendedores-table th {
    font-weight: 600;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.alert-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.stock-alerts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stock-alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid;
}

.stock-alert-item.critico {
    background: hsl(0 84% 60% / 0.1);
    border-color: hsl(0 84% 60% / 0.3);
}

.stock-alert-item.bajo {
    background: hsl(38 92% 50% / 0.1);
    border-color: hsl(38 92% 50% / 0.3);
}

.stock-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-card-wide,
    .chart-card-small {
        grid-column: span 1;
    }
}

/* ===================================
   SALES VIEW TUNING
   =================================== */

#salesView .view-header {
  margin-bottom: 18px;
}

#salesView .view-actions {
  align-items: center;
  gap: 10px;
}

#salesView #periodoVentas {
  min-width: 180px !important;
  min-height: 42px;
}

#salesView .sales-content {
  gap: 20px;
}

#salesView .kpi-grid {
  gap: 18px !important;
  margin-bottom: 0 !important;
}

#salesView .kpi-card {
  padding: 18px !important;
  border-radius: 14px !important;
}

#salesView .charts-grid {
  gap: 18px !important;
  margin-bottom: 0 !important;
}

#salesView .chart-card {
  padding: 18px !important;
  border-radius: 14px !important;
}

#salesView #rankingVendedores,
#salesView #historialTransacciones,
#salesView #historialDevoluciones {
  margin-bottom: 0 !important;
  padding: 18px !important;
  border-radius: 14px !important;
}

#salesView #tablaVendedores {
  margin-top: 4px;
}

#salesView .sales-table-container {
  margin-top: 6px;
  border-radius: 10px;
}

#salesView .sales-table th {
  padding: 14px 12px;
}

#salesView .sales-table td {
  padding: 13px 12px;
  vertical-align: top;
}

#salesView #tablaDevoluciones > div {
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
}

@media (max-width: 1024px) {
  #salesView .charts-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  #salesView .kpi-card,
  #salesView .chart-card,
  #salesView #rankingVendedores,
  #salesView #historialTransacciones,
  #salesView #historialDevoluciones {
    padding: 14px !important;
  }

  #salesView .sales-table th,
  #salesView .sales-table td {
    padding: 10px 8px;
    font-size: 13px;
  }
}


/* =============================================
   BOTÓN DE ACTUALIZACIÓN FORZADA
   ============================================= */

.btn-link {
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    font-size: 13px;
    padding: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
}

.btn-link:hover {
    color: hsl(var(--primary));
    text-decoration: underline;
}

.btn-link:active {
    transform: scale(0.98);
}

.btn-force-update {
  margin-top: 14px;
    width: 100%;
    text-align: center;
  border: 1px dashed hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--muted) / 0.45);
  padding: 10px 12px;
}

/* ===================================
   ANIMACIONES REALTIME
   =================================== */

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 hsl(var(--primary) / 0.4);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 10px hsl(var(--primary) / 0);
  }
}

/* Tabla de precios editable */
.tabla-precios thead th {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: hsl(var(--muted-foreground));
}

.tabla-precios tbody tr:hover {
  background: hsl(var(--muted) / 0.3);
}

.input-precio-editable:hover {
  border-color: hsl(var(--primary)) !important;
}

/* ===================================
   CONNECTION STATUS BADGE
   =================================== */
.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
  margin-right: 12px;
  cursor: default;
}

.connection-badge.online {
  background: hsl(142 76% 36% / 0.1);
  color: hsl(142 76% 36%);
  border: 1.5px solid hsl(142 76% 36% / 0.2);
}

.connection-badge.offline {
  background: hsl(0 84% 60% / 0.1);
  color: hsl(0 84% 60%);
  border: 1.5px solid hsl(0 84% 60% / 0.2);
  animation: pulse-offline 2s ease-in-out infinite;
}

.connection-badge.syncing {
  background: hsl(38 92% 50% / 0.1);
  color: hsl(38 92% 50%);
  border: 1.5px solid hsl(38 92% 50% / 0.2);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.connection-badge.online .connection-dot {
  background: hsl(142 76% 36%);
  box-shadow: 0 0 8px hsl(142 76% 36% / 0.5);
}

.connection-badge.offline .connection-dot {
  background: hsl(0 84% 60%);
  box-shadow: 0 0 8px hsl(0 84% 60% / 0.5);
}

.connection-badge.syncing .connection-dot {
  background: hsl(38 92% 50%);
  animation: spin 1s linear infinite;
}

@keyframes pulse-offline {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Badge de usuario mejorado */
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-badge::before {
  content: "👤";
  font-size: 18px;
}

/* ===================================
   LOGOUT BUTTON (Header)
   =================================== */

.btn-logout-header {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 8px;
  margin-left: 12px;
}

.btn-logout-header:hover {
  background: hsl(var(--destructive) / 0.1);
  color: #ef4444;
  transform: scale(1.05);
}

.btn-logout-header:active {
  transform: scale(0.95);
}

.btn-logout-header svg {
  width: 24px;
  height: 24px;
}

/* Responsive: Aumentar área clicable en móvil */
@media (max-width: 768px) {
  .btn-logout-header {
    width: 44px;
    height: 44px;
    padding: 10px;
  }

  .btn-logout-header svg {
    width: 24px;
    height: 24px;
  }
}

/* Animación suave al hover */
@keyframes logout-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.btn-logout-header:hover svg {
  animation: logout-pulse 1.5s ease-in-out infinite;
}

/* ===================================
   CAJA Y GASTOS VIEW
   =================================== */

.caja-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.caja-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .caja-grid {
    grid-template-columns: 1fr;
  }
}

.caja-panel {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin: 0 0 4px 0;
}

.panel-subtitle {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin: 0;
}

/* Stats Summary */
.stats-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: hsl(var(--muted) / 0.3);
  border-radius: 10px;
  transition: all 0.2s;
}

.stat-row:hover {
  background: hsl(var(--muted) / 0.5);
  transform: translateX(4px);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.stat-label svg {
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: hsl(var(--foreground));
}

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

.stat-transbank .stat-value {
  color: hsl(var(--info));
}

.stat-transferencia .stat-value {
  color: hsl(var(--warning));
}

.stat-gastos {
  color: hsl(var(--destructive)) !important;
}

.stat-total {
  background: hsl(var(--primary) / 0.1);
  border: 2px solid hsl(var(--primary) / 0.3);
  margin-top: 8px;
}

/* Filas editables de caja */
.stat-row-editable:hover {
  background: hsl(var(--primary) / 0.15) !important;
  border-left: 4px solid hsl(var(--primary));
  padding-left: 12px;
  transform: translateX(0) !important;
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.2);
}

.stat-row-editable:active {
  transform: scale(0.98);
}

.stat-total .stat-value {
  color: hsl(var(--primary));
  font-size: 22px;
}

/* Badge Pendientes Boletear */
#badgePendientesBoletear {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: hsl(38 92% 50% / 0.15);
  color: hsl(38 92% 50%);
  margin-bottom: 6px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Botón Ver Detalle en Stat Row */
.stat-row-editable button {
  font-size: 11px;
  padding: 6px 12px;
  margin-top: 8px;
  border: none;
  background: hsl(var(--primary));
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.stat-row-editable button:hover {
  background: hsl(var(--primary) / 0.9);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.3);
}

.stat-row-editable button:active {
  transform: translateY(0);
}

/* Arqueo Section */
.arqueo-section {
  background: hsl(var(--accent));
  padding: 20px;
  border-radius: 12px;
  border: 2px dashed hsl(var(--border));
}

.arqueo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 15px;
  color: hsl(var(--foreground));
}

.arqueo-value {
  font-size: 18px;
  font-weight: 700;
}

.arqueo-diferencia {
  margin-top: 16px;
  padding: 16px;
  background: hsl(var(--card));
  border-radius: 10px;
  border: 2px solid;
}

.arqueo-diferencia.sobrante {
  border-color: hsl(var(--success));
  background: hsl(var(--success) / 0.1);
}

.arqueo-diferencia.sobrante #diferenciaLabel,
.arqueo-diferencia.sobrante .arqueo-value {
  color: hsl(var(--success));
}

.arqueo-diferencia.faltante {
  border-color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.1);
}

.arqueo-diferencia.faltante #diferenciaLabel,
.arqueo-diferencia.faltante .arqueo-value {
  color: hsl(var(--destructive));
}

.input-efectivo-real {
  border: 2px solid hsl(var(--primary)) !important;
  background: hsl(var(--primary) / 0.05);
}

/* Toggle Switch para Cierre Automático */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  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: hsl(var(--muted));
  transition: 0.3s;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background-color: hsl(var(--primary));
}

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

.switch input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-efectivo-real:focus {
  border-color: hsl(var(--primary)) !important;
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}

/* Form Gastos */
.form-gastos {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Gastos List */
.gastos-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gasto-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  transition: all 0.2s;
}

.gasto-item:hover {
  border-color: hsl(var(--primary) / 0.5);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.gasto-info {
  flex: 1;
}

.gasto-descripcion {
  font-size: 15px;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 0 0 4px 0;
}

.gasto-meta {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  gap: 12px;
}

.gasto-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gasto-monto {
  font-size: 18px;
  font-weight: 700;
  color: hsl(var(--destructive));
  margin-right: 12px;
}

.gasto-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.btn-icon:hover {
  background: hsl(var(--primary));
  color: white;
  transform: scale(1.1);
}

.btn-icon.btn-delete:hover {
  background: hsl(var(--destructive));
}

.btn-icon-delete {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.btn-icon-delete:hover {
  background: hsl(var(--destructive));
  color: white;
  transform: scale(1.1);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: hsl(var(--muted-foreground));
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* Animaciones */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gasto-item {
  animation: slideInUp 0.3s ease-out;
}

/* Scrollbar personalizado para lista de gastos */
.gastos-list::-webkit-scrollbar {
  width: 8px;
}

.gastos-list::-webkit-scrollbar-track {
  background: hsl(var(--muted));
  border-radius: 10px;
}

.gastos-list::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 10px;
}

.gastos-list::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

/* Responsive */
@media (max-width: 768px) {
  .caja-content {
    padding: 16px;
  }

  .caja-panel {
    padding: 16px;
  }

  .panel-header h3 {
    font-size: 16px;
  }

  .stat-value {
    font-size: 16px;
  }

  .gasto-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .gasto-monto {
    font-size: 20px;
  }

  .gasto-actions {
    align-self: flex-end;
  }
}
/* ===================================
   BADGES DE ESTADO - ASISTENCIA
   =================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-completed {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
  border: 1px solid hsl(var(--success) / 0.3);
}

.status-pending {
  background: hsl(var(--warning) / 0.1);
  color: hsl(var(--warning));
  border: 1px solid hsl(var(--warning) / 0.3);
}

.status-canceled {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.3);
}

/* Estilos específicos de asistencia */
.asistencia-content .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: hsl(var(--muted-foreground));
}

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

/* ===================================
   MEJORAS M�VIL - ESC�NER PRINCIPAL
   =================================== */

/* Campo de esc�ner principal */
.barcode-search-main {
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--primary) / 0.8) 100%);
  border: 2px solid hsl(var(--primary));
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.2);
  margin-bottom: 12px;
  position: relative;
}

.barcode-search-main .search-icon {
  color: white;
  width: 28px;
  height: 28px;
}

.barcode-search-main .barcode-input {
  background: white;
  color: hsl(var(--foreground));
  border: none;
  font-size: 16px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: 8px;
}

.barcode-search-main .barcode-input::placeholder {
  color: hsl(var(--muted-foreground));
  font-weight: 400;
}

.barcode-search-main .barcode-input:focus {
  outline: 3px solid hsl(var(--ring));
  outline-offset: 2px;
}

.search-secondary {
  opacity: 0.85;
  border: 1px solid hsl(var(--border));
  margin-bottom: 16px;
}

.search-secondary:hover {
  opacity: 1;
}

/* Asegurar padding correcto en search-secondary */
.search-secondary .search-input {
  padding-right: 48px; /* Espacio para botón de limpiar */
}

.btn-clear-search {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: hsl(var(--destructive) / 0.1);
  border: none;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.btn-clear-search:hover {
  background: hsl(var(--destructive) / 0.2);
}

.btn-clear-search svg {
  color: hsl(var(--destructive));
}

.product-card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  transition: all 0.15s ease;
}

.product-card:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.15);
}

@media (hover: none) {
  .product-card:active {
    background: hsl(var(--primary) / 0.05);
    border-color: hsl(var(--primary));
  }
}

@media (max-width: 768px) {
  .barcode-search-main {
    padding: 14px 16px;
  }

  .barcode-search-main .barcode-input {
    font-size: 16px;
  }

  .search-secondary .search-input {
    font-size: 16px;
    padding: 12px 48px 12px 50px; /* Asegurar espacio para íconos en tablets */
  }
}

/* Media query específico para móviles pequeños */
@media (max-width: 480px) {
  .search-icon {
    left: 14px; /* Acercar un poco el ícono en móviles */
  }
  
  .search-input {
    padding: 11px 46px 11px 48px; /* Ajuste fino para móviles pequeños */
    font-size: 16px; /* Evitar zoom en iOS */
  }
  
  .search-secondary .search-input {
    padding: 11px 46px 11px 48px;
  }
}

/* ===============================================
   MÓDULO DE BODEGA VIRTUAL Y REPOSICIÓN
   =============================================== */

.bodega-layout {
  display: grid;
  grid-template-columns: 2.5fr 1fr;
  gap: 24px;
  height: calc(100vh - 180px);
}

.bodega-panel {
  background: hsl(var(--card));
  border-radius: 12px;
  border: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bodega-panel-main {
  display: flex;
  flex-direction: column;
}

.bodega-panel-historial {
  max-height: 100%;
  overflow-y: auto;
}

.bodega-panel .panel-header {
  padding: 20px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: hsl(var(--muted) / 0.3);
}

.bodega-panel .panel-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

/* Lista de Solicitudes */
.solicitudes-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.solicitud-card {
  background: hsl(var(--card));
  border: 2px solid hsl(var(--border));
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.solicitud-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.solicitud-disponible {
  border-left: 4px solid hsl(var(--success));
}

.solicitud-agotado {
  border-left: 4px solid hsl(var(--danger));
  opacity: 0.8;
}

.solicitud-advertencia {
  border-left: 4px solid hsl(47, 100%, 50%);
}

.solicitud-critico {
  border-left: 4px solid hsl(var(--danger));
  background: hsl(var(--danger) / 0.05);
}

.solicitud-info {
  flex: 1;
}

.solicitud-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.solicitud-header h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: hsl(var(--foreground));
}

.solicitud-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-item svg {
  stroke: hsl(var(--muted-foreground));
}

/* Indicador de Stock (Semáforo) */
.solicitud-stock {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stock-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 2px solid;
}

.stock-indicator.stock-disponible {
  background: hsl(var(--success) / 0.1);
  border-color: hsl(var(--success));
}

.stock-indicator.stock-agotado {
  background: hsl(var(--danger) / 0.1);
  border-color: hsl(var(--danger));
}

.stock-indicator.stock-advertencia {
  background: hsl(47, 100%, 50% / 0.1);
  border-color: hsl(47, 100%, 50%);
}

.stock-indicator.stock-critico {
  background: hsl(var(--danger) / 0.15);
  border-color: hsl(var(--danger));
}

.stock-icon {
  font-size: 24px;
  line-height: 1;
}

/* Acciones de solicitud */
.solicitud-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.solicitud-actions .btn {
  white-space: nowrap;
}

.solicitud-actions .btn-danger {
  padding: 6px 10px;
  min-width: auto;
  font-size: 0.875rem;
}

.stock-indicator div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stock-indicator strong {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.stock-indicator span {
  font-size: 11px;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

/* Historial de Sacos */
.historial-list {
  padding: 12px;
}

.historial-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: hsl(var(--muted) / 0.3);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: background 0.2s;
}

.historial-item:hover {
  background: hsl(var(--muted) / 0.5);
}

.historial-icon {
  font-size: 24px;
  line-height: 1;
}

.historial-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.historial-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.historial-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.historial-info strong {
  font-size: 14px;
  font-weight: 600;
}

.historial-info span {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

.historial-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
}

.meta-user {
  font-weight: 500;
  color: hsl(var(--foreground));
}

.meta-time {
  color: hsl(var(--muted-foreground));
}

/* Panel de Gestión de Stock */
.panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
}

.panel-content {
  background: hsl(var(--background));
  border-radius: 16px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease-out;
}

.panel-large {
  width: 95%;
  max-width: 1200px;
}

.panel-header-sticky {
  position: sticky;
  top: 0;
  background: hsl(var(--card));
  padding: 20px 24px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.panel-header-sticky h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.panel-body {
  padding: 24px;
}

/* Tabla de Stock */
.stock-bodega-table-container {
  overflow-x: auto;
  margin-top: 20px;
}

.table-striped {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-striped thead {
  background: hsl(var(--muted) / 0.5);
}

.table-striped th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: hsl(var(--foreground));
  border-bottom: 2px solid hsl(var(--border));
}

.table-striped td {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

.table-striped tbody tr:hover {
  background: hsl(var(--muted) / 0.3);
}

/* Búsqueda de Productos para Reposición */
.productos-busqueda-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
}

.producto-busqueda-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  transition: background 0.2s;
}

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

.producto-busqueda-item:hover {
  background: hsl(var(--muted) / 0.3);
}

.producto-info-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.producto-info-mini strong {
  font-size: 14px;
  font-weight: 600;
}

/* Información de Producto en Modal */
.producto-info-card {
  background: hsl(var(--muted) / 0.3);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.producto-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid hsl(var(--border));
}

.producto-detail-row:last-child {
  border-bottom: none;
}

.producto-detail-row strong {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}

.producto-detail-row span {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.stock-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  background: hsl(var(--muted));
}

.stock-badge.stock-disponible {
  background: hsl(var(--success) / 0.15);
  color: hsl(var(--success));
}

/* Info Cards */
.info-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid;
}

.info-card svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.info-card div {
  flex: 1;
}

.info-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.info-card p {
  margin: 0;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
}

.info-warning {
  background: hsl(var(--warning) / 0.1);
  border-color: hsl(var(--warning));
  color: hsl(var(--warning));
}

.info-warning svg {
  stroke: hsl(var(--warning));
}

/* Estados Visuales */
.empty-state-small {
  padding: 40px 20px;
  text-align: center;
  color: hsl(var(--muted-foreground));
}

.empty-state-small p {
  font-size: 14px;
  margin: 0;
}

/* Badges adicionales */
.badge-adulto { background: #3b82f6; color: white; }
.badge-cachorro { background: #f59e0b; color: white; }
.badge-senior { background: #8b5cf6; color: white; }
.badge-gato { background: #ec4899; color: white; }
.badge-gatito { background: #f97316; color: white; }
.badge-arena { background: #64748b; color: white; }

/* Animaciones */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive para Bodega */
@media (max-width: 1024px) {
  .bodega-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .bodega-panel-historial {
    max-height: 400px;
  }

  .solicitud-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .solicitud-stock {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 768px) {
  .panel-large {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
  }

  .panel-body {
    padding: 16px;
  }

  .stock-bodega-table-container {
    overflow-x: scroll;
  }

  .table-striped {
    min-width: 600px;
  }
}

/* ===================================
   FILTROS DE INVENTARIO CLICKEABLES
   ================================ */

.stat-card-clickable {
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.stat-card-clickable:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.stat-card-clickable:active {
  transform: translateY(-2px);
}

.stat-card-active {
  border: 2px solid hsl(var(--primary)) !important;
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.2);
  background: linear-gradient(135deg, hsl(var(--card)) 0%, hsl(var(--primary) / 0.05) 100%);
}

.stat-card-active::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  background: hsl(var(--primary));
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

/* ===================================
   CARRITO MÓVIL
   ================================ */

/* Botón Flotante del Carrito */
.btn-cart-float {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.cart-icon {
  display: block;
}

.btn-cart-float:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn-cart-float:active {
  transform: scale(0.95);
}

/* Clase para activar el botón solo cuando está en vista POS */
.btn-cart-float.show {
  display: none;
}

@media (max-width: 1024px) {
  .btn-cart-float.show {
    display: flex !important;
  }
}

/* Badge del Carrito */
.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: hsl(var(--destructive));
  color: white;
  font-size: 12px;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid white;
}

/* Overlay del Carrito Móvil */
.cart-mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cart-mobile-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Botón cerrar en header del carrito móvil */
@media (max-width: 1024px) {
  .cart-header {
    background: hsl(var(--primary));
    color: white;
  }

  .cart-header h3 {
    color: white;
  }

  .cart-header .btn-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
  }

  .cart-header .btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
  }
}

/* Modal Overlay - Estilos para modales dinámicos */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal-content {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 10001;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===================================
   BANNER DE ACTUALIZACIÓN PWA
   =================================== */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, hsl(217 91% 60%), hsl(217 91% 50%));
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  animation: slideDown 0.3s ease-out;
  gap: 12px;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.update-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.update-banner-content svg {
  flex-shrink: 0;
}

.update-banner-content span {
  font-weight: 500;
  font-size: 14px;
}

.update-banner-actions {
  display: flex;
  gap: 8px;
}

.btn-update-dismiss,
.btn-update-now {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-update-dismiss {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-update-dismiss:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-update-now {
  background: white;
  color: hsl(217 91% 50%);
}

.btn-update-now:hover {
  background: hsl(0 0% 95%);
  transform: scale(1.05);
}

@media (max-width: 600px) {
  .update-banner {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .update-banner-content span {
    font-size: 13px;
  }

  .update-banner-actions {
    width: 100%;
  }

  .btn-update-dismiss,
  .btn-update-now {
    flex: 1;
  }
}

/* ===================================
   RESPONSIVE TABLE (Mobile)
   =================================== */

/* Scroll horizontal en mobile */
@media (max-width: 768px) {
  .inventory-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hacer tabla scrolleable horizontalmente */
  .inventory-table {
    min-width: 600px;
    display: table;
  }

  /* Reducir padding en celdas para mobile */
  .inventory-table th,
  .inventory-table td {
    padding: 10px 8px;
    font-size: 13px;
  }

  /* Reducir tamaño de fuente en encabezados */
  .inventory-table th {
    font-size: 12px;
  }
}

/* ===================================
   MÓDULO: DEVOLUCIONES
   =================================== */

/* Radio cards para tipo de reembolso */
.radio-card {
  padding: 16px;
  border: 2px solid hsl(var(--border));
  border-radius: 12px;
  background: white;
  transition: all 0.2s ease;
  cursor: pointer;
  text-align: center;
}

.radio-card:hover {
  border-color: hsl(var(--primary));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.radio-card.selected {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
  box-shadow: 0 4px 16px hsl(var(--primary) / 0.2);
}

.radio-card input[type="radio"] {
  display: none;
}

/* Producto en lista de devolución */
.producto-devolucion-item {
  transition: all 0.2s ease;
}

.producto-devolucion-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

/* Botón de peligro (devolución) */
.btn-danger {
  background: hsl(var(--destructive));
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-danger:hover:not(:disabled) {
  background: hsl(0 84% 50%);
  box-shadow: 0 4px 12px hsl(var(--destructive) / 0.3);
  transform: translateY(-1px);
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger:active:not(:disabled) {
  transform: translateY(0);
}

/* Ventas con devolución - Indicadores visuales sutiles */
.venta-con-devolucion {
  background: hsl(0 84% 60% / 0.05) !important;
}

.venta-con-devolucion:hover {
  background: hsl(0 84% 60% / 0.08) !important;
}

.badge-devolucion {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: hsl(0 84% 60%);
  background: hsl(0 84% 60% / 0.1);
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ========================================
   MERMAS Y PÉRDIDAS
   ======================================== */

.mermas-history-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-warning {
  background: hsl(38 92% 50%);
  color: white;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-warning:hover:not(:disabled) {
  background: hsl(38 92% 45%);
  box-shadow: 0 4px 12px hsl(38 92% 50% / 0.3);
  transform: translateY(-1px);
}

.btn-warning:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mejoras al input de búsqueda */
#mermaBuscadorProducto {
  transition: all 0.2s;
}

#mermaBuscadorProducto:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}

/* Animación suave para resultados de búsqueda */
#mermaResultadosBusqueda {
  animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Producto seleccionado con animación */
#mermaProductoSeleccionado {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Tarjetas de motivo de merma */
.merma-motivo-card {
  background: white;
  border: 2px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.merma-motivo-card:hover {
  border-color: hsl(var(--primary));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.merma-motivo-card.selected {
  border-color: hsl(var(--primary));
  background: linear-gradient(135deg, hsl(var(--primary) / 0.05) 0%, hsl(var(--primary) / 0.1) 100%);
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.15);
  transform: translateY(-2px);
}

.merma-motivo-card.selected::before {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: hsl(var(--primary));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* Input de cantidad mejorado */
.input-cantidad-merma {
  outline: none;
  transition: all 0.15s;
}

.input-cantidad-merma:focus {
  transform: scale(1.02);
}

.input-cantidad-merma:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive para tarjetas de motivo */
@media (max-width: 640px) {
  .merma-motivo-card {
    padding: 8px;
  }
}

/* ===================================
   TEXTAREA IMPORTACIÓN DE STOCK
   =================================== */

#textoImportarStock {
  box-sizing: border-box !important;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--primary) / 0.3) transparent;
}

#textoImportarStock::-webkit-scrollbar {
  width: 10px;
}

#textoImportarStock::-webkit-scrollbar-track {
  background: transparent;
}

#textoImportarStock::-webkit-scrollbar-thumb {
  background: hsl(var(--primary) / 0.3);
  border-radius: 5px;
}

#textoImportarStock::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--primary) / 0.5);
}

#textoImportarStock:focus {
  outline: none;
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}

#textoImportarStock::placeholder {
  color: hsl(var(--muted-foreground) / 0.5);
  font-size: 14px;
  line-height: 2.2;
}

/* ===================================
   ANIMACIONES GLOBALES
   =================================== */

/* Animación de spinner para botones de carga */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Animación de pulso para alertas y notificaciones */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.02);
  }
}