:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #7c3aed;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 260px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== LAYOUT ========== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary) 0%, #3730a3 100%);
  color: white;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-brand .brand-logo {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.4);
  margin-bottom: 0.75rem;
  display: block;
}
.sidebar-brand h2 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  color: white;
}
.sidebar-brand .cupo-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: white;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.1rem 0.6rem;
  margin-top: 0.3rem;
}

.sidebar-nav { padding: 1rem 0; flex: 1; }

.sidebar-nav .nav-section {
  padding: 0.25rem 1.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
  margin-top: 0.75rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.18s;
  position: relative;
}
.sidebar-nav a .icon { font-size: 1.1rem; flex-shrink: 0; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.12); color: white; }
.sidebar-nav a.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: white;
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sidebar-footer a:hover { color: white; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ========== CARDS ========== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
}

.card-stat { text-align: center; }
.card-stat .stat-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
}
.card-stat .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.card-stat .stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
  font-weight: 500;
}

.card-stat.green .stat-value { color: var(--success); }
.card-stat.orange .stat-value { color: var(--warning); }
.card-stat.red .stat-value { color: var(--danger); }

/* ========== SECTION HEADER ========== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* ========== TABLES ========== */
.table-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbff; }
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ========== FORMS ========== */
.form-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.form-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--text); }

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

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.18s;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; border-radius: 6px; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: #065f46; }
.badge-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info    { background: var(--info-light);    color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: var(--text-muted); }

/* ========== ALERTS ========== */
.alert {
  padding: 0.9rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: var(--danger-light);  color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light);    color: #1e40af; border: 1px solid #bfdbfe; }

/* ========== LOGIN / REGISTRO PÚBLICOS ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  padding: 2rem;
}
.auth-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem 2rem;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
}
.auth-card .auth-logo {
  text-align: center;
  margin-bottom: 1rem;
}
.auth-card .auth-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}
.auth-card .auth-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}
.auth-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.auth-links a { font-weight: 600; }

/* ========== REGISTRO — CUPOS GRID ========== */
.registro-page {
  background: var(--bg);
  min-height: 100vh;
  padding: 2rem;
}
.registro-container {
  max-width: 960px;
  margin: 0 auto;
}
.registro-header {
  text-align: center;
  margin-bottom: 2rem;
}
.registro-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}
.registro-header p { color: var(--text-muted); margin-top: 0.25rem; }

.cupos-section {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.cupos-section h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.cupos-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.8rem;
}
.cupos-legend span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}
.legend-dot {
  width: 14px; height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.legend-dot.libre      { background: #d1fae5; border: 1px solid #6ee7b7; }
.legend-dot.ocupado    { background: #f1f5f9; border: 1px solid #cbd5e1; }
.legend-dot.seleccionado { background: #dbeafe; border: 1px solid #93c5fd; }

.cupos-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.5rem;
}
.cupo-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.18s;
  user-select: none;
}
.cupo-cell.libre {
  background: var(--success-light);
  color: #065f46;
  border-color: #6ee7b7;
}
.cupo-cell.libre:hover {
  background: #a7f3d0;
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.cupo-cell.ocupado {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
  border-color: #e2e8f0;
}
.cupo-cell.seleccionado {
  background: var(--info-light);
  color: #1d4ed8;
  border-color: #93c5fd;
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.registro-form-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.registro-form-card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1.5rem; }

/* ========== LOGO MINI ========== */
.logo-mini {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.logo-lg {
  width: 80px; height: 80px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--border);
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #e2e8f0; }

/* ========== FILTERS BAR ========== */
.filters-bar {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.filter-group input,
.filter-group select {
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 160px;
}
.filter-group input:focus,
.filter-group select:focus { outline: none; border-color: var(--primary); }

/* ========== PRODUCTOS — CATALOG CARDS ========== */
.products-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.product-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  border: 2px solid var(--border);
  transition: all 0.18s;
  cursor: pointer;
}
.product-card:hover { border-color: var(--primary); }
.product-card.selected { border-color: var(--primary); background: var(--primary-light); }
.product-card h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.35rem; }
.product-card .price { color: var(--primary); font-weight: 700; font-size: 1.1rem; }
.product-card .stock { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }
.product-card .qty-input {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.4rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  text-align: center;
}

/* ========== MANUAL VENTA ========== */
.manual-line {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.manual-line input {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.875rem;
}
.manual-line input:focus { outline: none; border-color: var(--primary); }

/* ========== TOTAL BAR ========== */
.total-bar {
  background: var(--primary);
  color: white;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ========== VENTA DETAIL ========== */
.venta-detail-table th { background: #f8fafc; }

/* ========== CHART SIMPLE ========== */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 120px;
  padding: 0.5rem 0;
}
.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}
.chart-label { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.25rem; }
.chart-val { font-size: 0.65rem; color: var(--primary); font-weight: 600; margin-bottom: 0.15rem; }

/* ========== EMPRENDEDOR CARD ========== */
.emprendedor-row-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.cupo-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ========== TABS ========== */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.6rem 1.2rem;
  background: #f1f5f9;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.18s;
}
.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.tab-btn:hover:not(.active) { background: var(--primary-light); color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 1.25rem; }
  .cupos-grid { grid-template-columns: repeat(5, 1fr); }
  .mobile-menu-btn {
    display: flex;
    position: fixed;
    top: 1rem; left: 1rem;
    z-index: 200;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
    cursor: pointer;
  }
}
@media (min-width: 901px) {
  .mobile-menu-btn { display: none; }
}

/* ========== MISC ========== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
