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

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --primary: #e85d5d;
  --primary-hover: #d44a4a;
  --primary-light: #fde8e8;
  --secondary: #f0b429;
  --secondary-light: #fef3d5;
  --tertiary: #3b82b9;
  --tertiary-light: #dbeafe;
  --text: #1a1a2e;
  --text-secondary: #6b6b8a;
  --border: #e8e6e1;
  --success: #34a853;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --sidebar-width: 240px;
  --transition: 0.25s ease;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== Shared ===== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(232, 93, 93, 0.35);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--bg);
  color: var(--text);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 93, 93, 0.15);
  background: var(--surface);
}

.form-input::placeholder { color: #b0b0c0; }

select.form-input { cursor: pointer; }

textarea.form-input { resize: vertical; }

.form-error {
  font-size: 0.82rem;
  color: var(--primary);
  margin-top: 6px;
}

/* ===== Logo ===== */

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: opacity var(--transition);
}

.logo-link:hover { opacity: 0.85; }

.logo-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 80px;
  background: var(--primary);
  border-radius: var(--radius-sm);
}

.logo-img {
  display: block;
  width: 180px;
  height: auto;
}

/* ===== Loading ===== */

.admin-loading {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-loading-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Login ===== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card .logo-link {
  justify-content: center;
  margin-bottom: 28px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.login-form {
  text-align: left;
}

/* ===== Layout ===== */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.sidebar-header .logo-bg {
  width: 180px;
  height: 70px;
}

.sidebar-header .logo-img {
  width: 160px;
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 16px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

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

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.logout-btn:hover {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
}

/* ===== Top bar ===== */

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* ===== Main content ===== */

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.admin-content {
  padding: 32px;
  max-width: 960px;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.content-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.content-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

/* ===== Stats ===== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 36px;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-gold { background: var(--secondary-light); color: var(--secondary); }
.stat-icon-coral { background: var(--primary-light); color: var(--primary); }
.stat-icon-blue { background: var(--tertiary-light); color: var(--tertiary); }

.stat-body { display: flex; flex-direction: column; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ===== Quick actions ===== */

.quick-actions h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

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

.action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition);
}

.action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  color: var(--text);
  transform: translateY(-2px);
}

/* ===== Form card ===== */

.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.form-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== Cartones list ===== */

.cartones-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.carton-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.carton-card:hover {
  box-shadow: var(--shadow);
}

.carton-info h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.carton-formato {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-right: 12px;
}

.carton-fecha {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.carton-status {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 50px;
}

.carton-status.publicado {
  background: var(--success);
  color: #fff;
}

.carton-status.borrador {
  background: var(--border);
  color: var(--text-secondary);
}

.carton-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== Empty state ===== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state svg {
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ===== Profile ===== */

.profile-card {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  border: 1px solid var(--border);
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-info p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.profile-info strong {
  color: var(--text);
}

/* ===== Carton chip ===== */
.carton-estado-chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 50px;
  background: var(--border);
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== Flash message ===== */
.flash-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: var(--success);
  color: #fff;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: flashIn 0.3s ease;
  white-space: nowrap;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* ===== Numeros grid ===== */
.numeros-leyenda {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.ley-item {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 50px;
}

.ley-item strong {
  font-size: 1rem;
  font-weight: 800;
  margin-left: 4px;
}

.ley-disp { background: #e6f7ee; color: #2e7d32; }
.ley-pend { background: #fef3d5; color: #8a6a00; }
.ley-vend { background: #fde8e8; color: #c62828; }

.btn-group {
  display: flex;
  gap: 8px;
}

.numeros-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-bottom: 24px;
}

.numero-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
}

.numero-cell:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.num-disponible {
  background: #e6f7ee;
  border-color: #c8e6c9;
}

.num-disponible:hover {
  border-color: var(--success);
}

.num-pendiente {
  background: #fef3d5;
  border-color: #ffe082;
  cursor: default;
}

.num-vendido {
  background: #fde8e8;
  border-color: #ef9a9a;
  cursor: default;
  opacity: 0.7;
}

.num-valor {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.num-accion {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition);
}

.num-accion:hover {
  transform: scale(1.2);
}

.num-venta {
  position: absolute;
  bottom: -4px;
  left: -4px;
  width: 22px;
  height: 22px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.num-venta:hover {
  transform: scale(1.2);
}

.num-cancel {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.num-cancel:hover {
  transform: scale(1.2);
}

.num-comprobante {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: var(--surface);
  border-radius: 50%;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: transform var(--transition);
}

.num-comprobante:hover {
  transform: scale(1.2);
}

/* ===== Reserva panel ===== */
.reserva-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  border: 2px solid var(--success);
  margin-bottom: 24px;
}

.reserva-panel h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--success);
}

.reserva-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.reserva-info p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.reserva-link-box {
  display: flex;
  gap: 8px;
}

.reserva-link-box .form-input {
  flex: 1;
}

.reserva-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ===== Pago preview ===== */
.pago-preview {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.8;
}

.pago-preview label {
  font-weight: 700;
  color: var(--primary);
  display: block;
  margin-top: 8px;
}

.pago-preview label:first-child {
  margin-top: 0;
}

.pago-preview span {
  display: block;
  color: var(--text);
}

/* ===== Batch mode ===== */
.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.yolo-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 6px 14px;
  border-radius: 50px;
  border: 2px solid var(--border);
  transition: all var(--transition);
}

.yolo-toggle.active {
  border-color: var(--secondary);
  background: var(--secondary-light);
  color: #8a6a00;
}

.yolo-toggle input { display: none; }



.num-selected {
  outline: 3px solid var(--primary);
  outline-offset: -1px;
  background: #fde8e8 !important;
}

.num-check {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.batch-count {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}

/* ===== Timer countdown ===== */
.num-timer {
  position: absolute;
  top: -4px;
  left: -4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: #fef3d5;
  color: #c62828;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.3;
}

.num-timer.timer-expired {
  background: #fde8e8;
  color: #c62828;
}

/* ===== Timeout buttons ===== */
.timeout-btns {
  display: flex;
  gap: 8px;
}

.timeout-btns .btn {
  flex: 1;
  justify-content: center;
}

/* ===== Pagos table ===== */
.search-bar {
  margin-bottom: 20px;
}

.search-bar .form-input {
  max-width: 360px;
}

.pagos-table-wrap {
  overflow-x: auto;
}

.pagos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pagos-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

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

.pagos-table tbody tr:hover {
  background: var(--bg);
}

.fila-pendiente td {
  background: #fefae6;
}

.ref-cell {
  font-family: monospace;
  font-weight: 600;
  font-size: 0.8rem;
}

.fecha-cell {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.estado-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.chip-pendiente {
  background: #fef3d5;
  color: #8a6a00;
}

.chip-vendido {
  background: #e6f7ee;
  color: #34a853;
}

.link-comprobante {
  text-decoration: none;
  font-size: 1.1rem;
}

.sin-comprobante {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* ===== Barra busqueda + paginacion ===== */
.barra-busqueda {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.barra-busqueda .form-input {
  flex: 1;
  min-width: 0;
}

.paginacion {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.paginacion button {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.paginacion button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.paginacion button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.paginacion span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 60px;
  text-align: center;
}

/* ===== Limit warning ===== */
.limit-msg {
  background: var(--secondary-light);
  border: 1px solid var(--secondary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: #5a4200;
  line-height: 1.6;
}

.limit-msg strong {
  color: #5a4200;
}

