:root {
  color-scheme: dark;
  --bg: #0E0E10;
  --surface: #1B1B1F;
  --surface-raised: #232327;
  --border: #2A2A2E;
  --text: #F5F3EE;
  --text-muted: #9A968D;
  --accent: #C6FF33;
  --accent-dim: #7FA61C;
  --danger: #FF5A5A;
  --warn-bg: #3A2C10;
  --warn-text: #F2B94D;
  --font-body: 'Segoe UI', 'Work Sans', sans-serif;
  --font-mono: 'Consolas', 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 24px; }

label { display: block; font-size: 13px; color: var(--text-muted); margin: 14px 0 6px; }
label.separado { margin-top: 28px; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  margin: 20px 0 8px;
}
.checkbox-label input { width: auto; }

.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 11px 12px;
  font-family: var(--font-body);
  font-size: 14px;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: 4px;
  padding: 11px 18px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primario { background: var(--accent); color: #0E0E10; }
.btn-primario:hover { background: var(--accent-dim); }
.btn-secundario { background: var(--surface-raised); color: var(--text); border-color: var(--border); }
.btn-secundario:hover { border-color: var(--accent); }
.btn-texto { background: none; color: var(--text-muted); border: none; text-decoration: underline; }
.btn-ancho { width: 100%; margin-top: 20px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mensaje-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

/* Login */
.pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
}
.login-logo { height: 56px; margin-bottom: 20px; }
.login-title { font-size: 16px; margin: 0 0 20px; color: var(--text-muted); font-weight: 500; }

/* Header admin */
.admin-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  margin-bottom: 24px;
}
.admin-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-logo { height: 44px; }
.admin-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.tab-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
}
.tab-btn.activa { border-color: var(--accent); color: var(--text); }

.estado { padding: 40px 0; text-align: center; color: var(--text-muted); }
.estado-error { color: var(--danger); }

/* Lista de productos */
.lista-productos { display: flex; flex-direction: column; gap: 10px; padding-bottom: 60px; }
.producto-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}
.producto-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.producto-miniatura {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.producto-miniatura-vacia {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}
.producto-info { flex: 1; min-width: 160px; }
.producto-flags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.flag {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}
.flag-oferta { background: var(--accent); color: #0E0E10; }
.flag-defecto { background: var(--danger); color: #0E0E10; }
.producto-nombre { font-weight: 600; font-size: 15px; }
.producto-meta { color: var(--text-muted); font-size: 13px; }
.producto-costos {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}
.producto-costos b { color: var(--text); }

.producto-acciones { display: flex; gap: 8px; margin-top: 10px; }
.btn-chico { padding: 6px 12px; font-size: 13px; }

.form-titulo { font-size: 16px; color: var(--text-muted); font-weight: 500; margin: 0 0 16px; }
.acciones-form { display: flex; align-items: center; gap: 16px; margin-top: 28px; }

.tallas-admin { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.talla-admin {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.talla-admin .talla-num { font-family: var(--font-mono); font-weight: 700; }
.talla-admin .talla-existencia { color: var(--text-muted); font-size: 12px; }
.talla-admin button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
}

/* Formulario de producto */
.form-producto { max-width: 640px; padding-bottom: 60px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lista-dinamica { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fila-dinamica { display: flex; gap: 8px; align-items: center; }
.fila-dinamica .input { flex: 1; }
.fila-dinamica input[type="number"] { max-width: 110px; }
.fila-foto { align-items: center; }
.fila-foto .foto-archivo { flex: 1; color: var(--text-muted); font-size: 13px; }
.fila-foto .foto-estado {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 90px;
}
.foto-preview {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.foto-marcar-portada-nueva {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
}
.foto-marcar-portada-nueva:hover { border-color: var(--accent); color: var(--accent); }
.foto-marcar-portada-nueva.activa { color: #F5C518; border-color: #F5C518; }


.fotos-existentes { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.foto-existente {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.foto-existente img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-existente button.foto-borrar-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(6,6,7,0.75);
  color: var(--danger);
  border: none;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  line-height: 1;
  cursor: pointer;
  font-size: 12px;
}
.foto-portada-tag,
.foto-portada-btn {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  padding: 3px 0;
  font-family: var(--font-mono);
  font-weight: 700;
}
.foto-portada-tag {
  background: var(--accent);
  color: #0E0E10;
}
.foto-portada-btn {
  background: rgba(6,6,7,0.85);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
}
.foto-portada-btn:hover { color: var(--text); }
.foto-existente.es-portada {
  border: 2px solid var(--accent);
}
.fila-dinamica button {
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
}

/* Modal */
[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6,6,7,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}
.modal-card h2 { font-size: 16px; margin: 0 0 8px; }
.modal-acciones { display: flex; gap: 10px; margin-top: 20px; }
.modal-acciones .btn { flex: 1; }

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

/* Buscador de producto */
.buscador-producto { position: relative; max-width: 480px; margin-bottom: 20px; }
.resultados-busqueda {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
}
.resultado-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.resultado-item:last-child { border-bottom: none; }
.resultado-item:hover { background: var(--surface-raised); }
.resultado-item img { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.resultado-item .sin-foto-chica {
  width: 36px; height: 36px; border-radius: 4px; background: var(--surface-raised);
  flex-shrink: 0;
}
.resultado-nombre { font-size: 14px; }
.resultado-meta { font-size: 12px; color: var(--text-muted); }

/* Seleccion de venta */
.venta-seleccion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  max-width: 480px;
}
.venta-producto-info { font-weight: 600; margin-bottom: 4px; }
.tallas-seleccionables { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.talla-seleccionable {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
}
.talla-seleccionable.seleccionada { border-color: var(--accent); background: var(--accent); color: #0E0E10; }
.talla-seleccionable.bloqueada { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-muted); cursor: not-allowed; text-decoration: line-through; }
.talla-etiqueta-bloqueo {
  font-size: 9px;
  text-transform: uppercase;
  text-decoration: none;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.tipo-venta { display: flex; gap: 8px; margin: 16px 0; }
.tipo-btn {
  flex: 1;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
}
.tipo-btn.activa { border-color: var(--accent); color: var(--text); }

.mensaje-exito { color: var(--accent); font-size: 13px; margin-top: 10px; }

/* Apartados */
.lista-apartados { display: flex; flex-direction: column; gap: 10px; }
.apartado-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.apartado-info { font-size: 14px; }
.apartado-meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.apartado-saldo { font-family: var(--font-mono); font-weight: 700; }
.apartado-vencido { border-color: var(--danger); }
.abono-saldo { color: var(--text-muted); font-size: 13px; margin: -8px 0 14px; }

/* Bitacora / revision */
.alerta-vencidos {
  background: var(--warn-bg, #3A2C10);
  color: var(--warn-text, #F2B94D);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
}
.lista-bitacora { display: flex; flex-direction: column; gap: 8px; }
.bitacora-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
}
.bitacora-row.alerta-precio { border-color: var(--warn-text, #F2B94D); }
.bitacora-meta { color: var(--text-muted); }

/* Pestañas internas (dentro de Productos) */
.tabs-internas { margin-top: 4px; margin-bottom: 20px; }
.tab-btn-interna {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  margin-right: 8px;
}
.tab-btn-interna.activa { border-color: var(--accent); color: var(--text); }

/* Filtro de fechas (revision / mis ventas) */
.filtro-fechas {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filtro-fechas label { margin: 0 0 6px; }
.filtro-fechas .input { width: auto; }

.resultado-corte {
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  margin-top: 20px;
}
.corte-renglon {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.corte-renglon.corte-diferencia {
  border-bottom: none;
  border-top: 2px solid var(--accent);
  margin-top: 8px;
  font-size: 16px;
}
.corte-conteo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.form-gasto { max-width: 480px; }

/* Header de seleccion de venta, con boton cancelar */
.venta-seleccion-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

/* Formulario de pedido */
.form-pedido {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  max-width: 480px;
  margin-top: 16px;
}

.bitacora-row.cancelada { opacity: 0.6; }
.bitacora-row .btn { margin-left: 8px; }

/* Layout de dos columnas en Nueva venta: la venta a la izquierda, el pedido
   a la derecha, para que quede claro que son dos cosas separadas y el
   formulario de pedido no se vea como si fuera parte del bloque de venta. */
.venta-layout {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 340px);
  gap: 24px;
  align-items: start;
}
.venta-layout-col-pedido {
  padding-top: 32px;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}
.separado-cero { margin-top: 0; }
@media (max-width: 860px) {
  .venta-layout { grid-template-columns: 1fr; }
  .venta-layout-col-pedido {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 8px;
  }
}

/* Leyenda de agotado en el buscador de productos */
.badge-agotado {
  display: inline-block;
  background: var(--danger);
  color: #0E0E10;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 2px 6px;
  margin-left: 6px;
  font-family: var(--font-mono);
  vertical-align: middle;
}

/* Desglose de abonos (trazabilidad) en Revision */
.abonos-desglose {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.abonos-desglose-titulo { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.abono-linea { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.bitacora-row.fila-abono { border-left: 3px solid var(--accent); padding-left: 10px; }
.checkbox-linea { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox-linea input { width: auto; }
.ayuda-campo { font-size: 12px; color: var(--text-muted); margin-top: -6px; }
.tallas-existentes { margin: 12px 0; }
.talla-existente-estado { font-size: 12px; color: var(--accent); min-width: 80px; }

.bitacora-fecha { font-family: var(--font-mono); color: var(--text-muted); }
