:root {
  color-scheme: light;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  
  --success: #10b981;
  --success-light: #d1fae5;
  
  --danger: #ef4444;
  --danger-light: #fee2e2;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 25px -5px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 40px -10px rgba(0,0,0,0.15);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.animate-fade { animation: fadeIn 0.35s ease forwards; }
.animate-pop { animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}

.btn.primary { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3); }
.btn.primary:hover { background: var(--primary-hover); transform: translateY(-2px); }

.btn.secondary { background: var(--surface-alt); color: var(--text-main); border: 1px solid var(--border); }
.btn.secondary:hover { background: #e2e8f0; }

.btn.accent { background: var(--accent); color: #451a03; }
.btn.danger { background: var(--danger-light); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: white; }

.btn.sm { padding: 0.4rem 0.8rem; font-size: 0.825rem; border-radius: var(--radius-sm); }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

legend {
  font-weight: 700;
  padding: 0 0.5rem;
  color: var(--primary);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: var(--transition);
  font-family: inherit;
}

.radio-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.radio-group input[type="radio"] {
  width: 1.2rem;
  height: 1.2rem;
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  background: var(--bg-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  color: white;
}

.hero-header {
  text-align: center;
  max-width: 650px;
  margin-bottom: 3rem;
}

.hero-badge {
  background: rgba(255,255,255,0.1);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-header h1 {
  font-size: 2.8rem;
  font-weight: 900;
  margin: 0.8rem 0;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-align: center;
  transition: var(--transition);
}

.role-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.role-pill.comprador { background: #dbeafe; color: #1e40af; }
.role-pill.vendedor { background: #fef3c7; color: #92400e; }
.role-pill.banco { background: #d1fae5; color: #065f46; }
.role-pill.coordinador { background: #f3e8ff; color: #6b21a8; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.user-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.main-shell {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.dashboard-banner {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
}

.dashboard-banner h1 { font-size: 1.8rem; font-weight: 800; }

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-link {
  padding: 0.8rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tab-link:hover { color: var(--primary); }
.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: slideInRight 0.3s ease;
}

.stores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.store-card-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  width: 100%;
  color: inherit;
}

.store-card-item:hover, .store-card-item.selected {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.store-logo {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 0.5rem;
  display: block;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

/* Tarjeta y Marcadores Visuales de la Imagen del Producto */
.product-card-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
}

.product-card-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.product-img-wrapper {
  position: relative;
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: #0f172a;
}

.product-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card-item:hover .product-img-wrapper img {
  transform: scale(1.08);
}

/* Etiqueta Flotante sobre la Imagen */
.product-img-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  text-transform: uppercase;
}

/* Indicador Señalizador de Descripción en la Imagen */
.product-img-desc-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.4));
  color: #f1f5f9;
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.product-img-desc-tag strong {
  color: #60a5fa;
  font-weight: 700;
}

.product-details {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-details h4 { font-size: 1.1rem; margin-bottom: 0.25rem; }

/* Caja Visual Destacada para la Descripción */
.product-desc-box {
  background: var(--surface-alt);
  border-left: 3px solid var(--primary);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--text-main);
  margin-bottom: 0.8rem;
  line-height: 1.35;
}

.product-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.product-price { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.stock-tag { font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 4px; background: var(--surface-alt); }
.stock-tag.low { background: var(--danger-light); color: var(--danger); }

/* Tarjetas de Pedidos del Vendedor */
.vendor-orders-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.vendor-order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.vendor-order-card.pending {
  border-left: 5px solid var(--accent);
}

.vendor-order-card.completed {
  border-left: 5px solid var(--success);
}

.vendor-order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Lista Visual de Productos dentro de la Orden del Vendedor */
.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}

.order-item-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface-alt);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.order-item-img {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.order-item-info {
  flex: 1;
}

.order-item-info strong {
  font-size: 0.95rem;
  color: var(--text-main);
  display: block;
}

.order-item-desc-badge {
  display: inline-block;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.25rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.cart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.cart-list { list-style: none; padding: 0; }
.cart-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.cart-controls { display: flex; align-items: center; gap: 0.5rem; }

.cart-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.4rem;
  font-weight: 800;
  margin: 1.5rem 0;
  padding-top: 1rem;
  border-top: 2px dashed var(--border);
}

.data-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: var(--surface-alt);
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.custom-modal {
  margin: auto;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: transparent;
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
}

.custom-modal::backdrop {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.custom-modal form, .custom-modal .modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 100;
}

.toast {
  background: var(--surface);
  color: var(--text-main);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

.hidden { display: none !important; }

@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 1rem; align-items: flex-start; }
  .dashboard-banner { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .nav-tabs { overflow-x: auto; max-width: 100%; }
  .order-item-row { flex-direction: column; align-items: flex-start; }
}