* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f5f6f8;
  color: #1f2430;
  margin: 0;
}
header {
  background: #14213d;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
}
header a {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  opacity: 0.85;
}
header a:hover { opacity: 1; text-decoration: underline; }
header .brand { font-weight: 700; font-size: 16px; opacity: 1; }
header .header-carrito { margin-left: auto; }
main {
  max-width: 1800px;
  margin: 24px auto;
  padding: 0 20px;
}
.tabla-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
h1 { font-size: 22px; margin-bottom: 4px; }
.subtitle { color: #666; margin-top: 0; margin-bottom: 20px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #eceef1;
  font-size: 14px;
}
th { background: #eef1f6; font-weight: 600; }
tr:last-child td { border-bottom: none; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: #dcf5e3; color: #1a7d3a; }
.badge-error { background: #fbdcdc; color: #a3231f; }
.badge-pendiente { background: #fdecc8; color: #8a5a00; }
.badge-en_progreso { background: #dbe9fb; color: #1a4f9c; }
.badge-none { background: #ececec; color: #666; }
form.filtros { margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select, button, input[type=submit], input[type=text], input[type=number] {
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #d5d9e0;
  color: #14213d;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.chip:hover { border-color: #14213d; }
.chip-active {
  background: #14213d;
  color: #fff;
  border-color: #14213d;
}
button, input[type=submit] {
  background: #14213d;
  color: #fff;
  border: none;
  cursor: pointer;
}
button:hover, input[type=submit]:hover { background: #223362; }
button.secondary, a.secondary {
  background: #fff;
  color: #14213d;
  border: 1px solid #14213d;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
}
.checklist {
  background: #fff;
  border-radius: 6px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.checklist label {
  display: block;
  padding: 6px 0;
  font-size: 14px;
}
.flash {
  background: #fdecc8;
  color: #8a5a00;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
}
.error-box {
  background: #fbdcdc;
  color: #a3231f;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
}
#log {
  background: #0d1117;
  color: #c9d1d9;
  font-family: Consolas, monospace;
  font-size: 13px;
  padding: 14px;
  border-radius: 6px;
  height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.progress-status { margin-bottom: 10px; font-size: 14px; }

/* Tienda pública */
.tienda-body { background: #f5f6f8; }
.tienda-header {
  background: #14213d;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.tienda-brand {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
}
.tienda-brand-logo {
  max-height: 40px;
  max-width: 200px;
  object-fit: contain;
}
.tienda-header-cuenta {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.tienda-header-cuenta a { color: #fff; }
.tienda-header-saludo { color: #cfd6e6; font-size: 14px; }
.tienda-main {
  max-width: 1800px;
  margin: 24px auto;
  padding: 0 20px;
}
.tienda-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.tienda-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.tienda-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.tienda-card-img {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f1f4;
}
.tienda-card-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tienda-card-noimg { color: #999; font-size: 13px; }
.tienda-card-body { padding: 12px 14px; }
.tienda-card-cat { font-size: 11px; color: #888; text-transform: uppercase; margin-bottom: 4px; }
.tienda-card-nombre {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}
.tienda-card-precio { font-size: 18px; font-weight: 700; color: #14213d; margin-bottom: 6px; }
.tienda-detalle { display: flex; gap: 32px; flex-wrap: wrap; background: #fff; border-radius: 8px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.tienda-detalle-img { flex: 1; min-width: 280px; display: flex; align-items: center; justify-content: center; background: #f0f1f4; border-radius: 6px; padding: 20px; }
.tienda-detalle-img img { max-width: 100%; max-height: 360px; object-fit: contain; }
.tienda-detalle-info { flex: 1; min-width: 280px; }
.tienda-detalle-precio { font-size: 28px; font-weight: 700; color: #14213d; margin: 12px 0; }

.tienda-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #25d366;
  color: #fff !important;
  padding: 8px 14px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.tienda-whatsapp-btn:hover { background: #1fb959; }

/* Pantalla de bienvenida al entrar a la tienda */
.tienda-bienvenida {
  max-width: 720px;
  margin: 40px auto;
  text-align: center;
  background: #fff;
  border-radius: 10px;
  padding: 48px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.tienda-bienvenida h1 { font-size: 28px; margin: 0 0 8px 0; }
.tienda-bienvenida-sub { color: #666; font-size: 15px; margin: 0 0 28px 0; }
.tienda-bienvenida-buscar {
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 0 auto 24px auto;
}
.tienda-bienvenida-buscar input[type=text] {
  flex: 1;
  padding: 10px 14px;
}
.tienda-bienvenida-acciones {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.tienda-bienvenida-btn-principal {
  background: #14213d;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.tienda-bienvenida-btn-principal:hover { background: #223362; }
.tienda-bienvenida-categorias-titulo {
  font-size: 14px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 32px 0 14px 0;
}
.tienda-bienvenida-categorias {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.tienda-bienvenida-categoria {
  background: #eef1f6;
  color: #14213d;
  padding: 8px 16px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  border: 1px solid #dde2ea;
}
.tienda-bienvenida-categoria:hover { background: #dde2ea; }
.tienda-bienvenida-categoria span { color: #888; font-size: 12px; }

@media (max-width: 600px) {
  .tienda-bienvenida { margin: 16px; padding: 32px 20px; }
  .tienda-bienvenida h1 { font-size: 22px; }
  .tienda-bienvenida-buscar { flex-direction: column; }
}

/* Panel de filtros estilo Amazon */
.tienda-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tienda-toolbar input[type=text] {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
}
.tienda-btn-movil { display: none; }

.chips-activos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
}
.chip-activo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef1f6;
  color: #14213d;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid #dde2ea;
}
.chip-activo:hover { background: #dde2ea; }
.chip-activo span { font-weight: 700; }
.chip-limpiar {
  font-size: 12px;
  color: #a3231f;
  text-decoration: underline;
  margin-left: 4px;
}

.tienda-resultado-conteo {
  font-size: 13px;
  color: #555;
  margin: 4px 0 18px 0;
}

.tienda-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.tienda-contenido {
  flex: 1;
  min-width: 0;
}
#tienda-sin-resultados {
  background: #fff;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  color: #666;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tienda-sidebar {
  width: 280px;
  flex-shrink: 0;
}
.tienda-sidebar-overlay { display: none; }
.tienda-sidebar-panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 4px 0;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.tienda-sidebar-header { display: none; }

.faceta {
  border-bottom: 1px solid #eceef1;
  padding: 12px 18px;
}
.faceta:last-child { border-bottom: none; }
.faceta summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #14213d;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faceta summary::-webkit-details-marker { display: none; }
.faceta summary::after {
  content: '+';
  font-size: 16px;
  color: #888;
  font-weight: 400;
}
.faceta[open] summary::after { content: '\2212'; }

.faceta-opciones {
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.faceta-opcion {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: #333;
}
.faceta-opcion input { flex-shrink: 0; }
.faceta-opcion-texto { flex: 1; }
.faceta-conteo { color: #999; font-size: 12px; }

/* Móvil: la toolbar muestra el botón "Filtros" y el sidebar se convierte en drawer */
@media (max-width: 860px) {
  .tienda-btn-movil { display: inline-block; }

  .tienda-layout { display: block; }
  .tienda-contenido { width: 100%; }

  .tienda-sidebar { width: auto; }
  .tienda-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .tienda-sidebar.abierto .tienda-sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  .tienda-sidebar-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 88%;
    max-width: 340px;
    max-height: none;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1001;
    box-shadow: -2px 0 12px rgba(0,0,0,0.2);
  }
  .tienda-sidebar.abierto .tienda-sidebar-panel {
    transform: translateX(0);
  }
  .tienda-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid #eceef1;
    position: sticky;
    top: 0;
    background: #fff;
  }
  .tienda-sidebar-header h3 { margin: 0; font-size: 16px; }
  #btn-cerrar-filtros {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
  }

  .tienda-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  main, .tienda-main { padding: 0 12px; margin: 16px auto; }
  header, .tienda-header { padding: 12px 16px; gap: 10px 16px; }
  .header-carrito { margin-left: 0; }
  .tienda-header-cuenta { margin-left: 0; width: 100%; }

  .tabla-scroll table { min-width: 640px; }

  .tienda-detalle { padding: 16px; gap: 20px; }
}

@media (max-width: 480px) {
  h1 { font-size: 19px; }
  .tienda-toolbar input[type=text] { min-width: 0; }
  form.filtros { flex-direction: column; align-items: stretch; }
}
