/* ===== Base ===== */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.45;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Barra superior ===== */
.barra {
  background: #0f172a;
  color: #e2e8f0;
}
.barra-dentro {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  min-height: 56px;
}
.marca {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}
.marca img { display: block; max-height: 48px; height: auto; width: auto; }
.marca:hover { color: #93c5fd; text-decoration: none; }
.menu { display: flex; flex-wrap: wrap; gap: 4px; }
.menu a {
  color: #cbd5e1;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.92rem;
}
.menu a:hover { color: #fff; background: #1e293b; text-decoration: none; }
.menu a.on { color: #fff; background: #1d4ed8; }
.menu-btn {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}
.menu-btn span {
  display: block;
  width: 22px;
  height: 3px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 4px 0;
}
.menu-btn:hover span { background: #93c5fd; }
.menu.abierto { display: flex; }
.usuario {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
  color: #fef08a;
  min-width: 0;
}
.usuario span { min-width: 0; overflow-wrap: anywhere; }
.usuario a { color: #f87171; }

/* ===== Contenido ===== */
.contenido {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.contenido h1 { margin: 4px 0 10px; font-size: 1.25rem; }

.pie {
  background: #0f172a;
  color: #e2e8f0;
  font-size: .85rem;
  text-align: center;
  padding: 12px 16px;
}
.pie a { color: #93c5fd; }

/* ===== Avisos ===== */
.aviso {
  position: relative;
  padding: 10px 36px 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.aviso.ok    { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.aviso.error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.aviso.info  { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.aviso.alerta { background: #dc2626; color: #fff; border-color: #b91c1c; }
.aviso-cerrar {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  user-select: none;
}
.aviso-cerrar:hover { background: rgba(0,0,0,.12); }

/* ===== Tarjetas / formularios ===== */
.tarjeta {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}
.tarjeta h2, .tarjeta h3 { margin-top: 0; }

form label { display: block; margin-bottom: 14px; font-size: 0.9rem; font-weight: 600; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=file],
select, textarea {
  width: 100%;
  max-width: 520px;
  padding: 9px 11px;
  margin-top: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: #1e293b;
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid #93c5fd;
  border-color: #2563eb;
}

.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.92rem;
  cursor: pointer;
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 600;
}
.btn:hover { filter: brightness(0.96); text-decoration: none; }
.btn-primario { background: #2563eb; color: #fff; }
.btn-peligro   { background: #dc2626; color: #fff; }
.btn-suave     { background: #f1f5f9; border-color: #cbd5e1; }
.btn-ancho     { width: 100%; }
.btn-mini      { padding: 2px 8px; font-size: 0.78rem; }
td .acciones { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; align-items: center; }
.acciones .btn, .acciones button { white-space: nowrap; }

/* ===== Botón borrar artículo (cuadro rojo + cruz blanca centrada) ===== */
.col-borrar { text-align: center; white-space: nowrap; }
form.borrar-articulo { display: inline-block; margin: 0; }
.btn-borrar-x {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #dc2626;
  cursor: pointer;
  vertical-align: middle;
}
.btn-borrar-x::before,
.btn-borrar-x::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 13px;
  height: 2.5px;
  border-radius: 1px;
  background: #fff;
}
.btn-borrar-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.btn-borrar-x::after  { transform: translate(-50%, -50%) rotate(-45deg); }
.btn-borrar-x:hover { background: #b91c1c; filter: brightness(1); }
.btn-borrar-x:focus-visible { outline: 2px solid #93c5fd; outline-offset: 1px; }

.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 760px) { .dos-col { grid-template-columns: 1fr; } }
/* Barra fija sin cortes al hacer scroll (logo/barra no se "asoman" arriba) */
body { scroll-padding-top: 0; }
.barra { overflow: hidden; }
.marca img { max-height: 52px; min-height: 0; }
@media (orientation: portrait) and (max-width: 900px) {
  .marca img { max-height: 68px; }
  /* Evitar que la barra quede pegada al notch/estado del teléfono */
  .barra-dentro { padding-top: calc(env(safe-area-inset-top, 0px) + 6px); padding-bottom: 6px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .marca img { max-height: 40px; }
}
@media (orientation: portrait) and (max-width: 900px) {
  /* Modo vertical (teléfono): logo grande + menú hamburguesa */
  .menu-btn { display: block; }
  .menu { display: none; flex-direction: column; width: 100%; gap: 2px; }
  .menu.abierto { display: flex; }
  .marca img { max-height: 52px; }
  .marca { min-width: 0; }
  /* Modo vertical (teléfono): solo Artículo y Precio de venta */
  .cols-admin th:nth-child(1), .cols-admin th:nth-child(2), .cols-admin th:nth-child(4),
  .cols-admin th:nth-child(5), .cols-admin th:nth-child(6),
  .cols-admin td:nth-child(1), .cols-admin td:nth-child(2), .cols-admin td:nth-child(4),
  .cols-admin td:nth-child(5), .cols-admin td:nth-child(6) { display: none; }
  .cols-basico th:nth-child(1), .cols-basico th:nth-child(2), .cols-basico th:nth-child(4),
  .cols-basico td:nth-child(1), .cols-basico td:nth-child(2), .cols-basico td:nth-child(4) { display: none; }
  .cols-proveedor th:nth-child(2), .cols-proveedor th:nth-child(4), .cols-proveedor th:nth-child(6),
  .cols-proveedor td:nth-child(2), .cols-proveedor td:nth-child(4), .cols-proveedor td:nth-child(6) { display: none; }
  .cols-hist th:nth-child(3), .cols-hist th:nth-child(4), .cols-hist th:nth-child(8),
  .cols-hist td:nth-child(3), .cols-hist td:nth-child(4), .cols-hist td:nth-child(8) { display: none; }
  .cols-usuarios th:nth-child(5), .cols-usuarios th:nth-child(6),
  .cols-usuarios td:nth-child(5), .cols-usuarios td:nth-child(6) { display: none; }
  .cols-plantillas th:nth-child(3), .cols-plantillas th:nth-child(5),
  .cols-plantillas td:nth-child(3), .cols-plantillas td:nth-child(5) { display: none; }
}
table.cols-proveedor th, table.cols-proveedor td { white-space: nowrap; }
table.cols-hist th, table.cols-hist td { white-space: nowrap; }
table.cols-usuarios th, table.cols-usuarios td { white-space: nowrap; }
table.cols-plantillas th, table.cols-plantillas td { white-space: nowrap; }
.buscador .dos-col { gap: 2px 24px; }
.buscador label { margin-bottom: 6px; }
.dos-col.mapeo { gap: 0 10px; margin-top: 6px; }
.dos-col.mapeo > .grupo { padding: 6px; border-radius: 10px; }
.dos-col.mapeo > .grupo > * { margin-bottom: 4px; }
.dos-col.mapeo > .grupo > :last-child { margin-bottom: 0; }
.dos-col.mapeo label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 10px; border-radius: 6px; font-size: .8rem; font-weight: 600; }
.dos-col.mapeo > .grupo > :nth-child(odd) { background: #dbeafe; }
.dos-col.mapeo > .grupo > :nth-child(even) { background: #eff6ff; }
.dos-col.mapeo > .grupo + .grupo > :nth-child(odd) { background: #fef9c3; }
.dos-col.mapeo > .grupo + .grupo > :nth-child(even) { background: #fefce8; }
.dos-col.mapeo input { width: 44px; max-width: 44px; margin: 0; padding: 3px 6px; text-align: center; font-size: .9rem; font-weight: 600; background: #fff; }
@media (max-width: 760px) { .dos-col.mapeo .grupo + .grupo { margin-top: 8px; } }
@media (max-width: 760px) { .buscador .dos-col { gap: 6px 0; } }

/* ===== Tablas ===== */
.tabla-envoltura { overflow-x: auto; scrollbar-width: thin; scrollbar-color: #94a3b8 #e2e8f0; }
.tabla-envoltura::-webkit-scrollbar { height: 10px; }
.tabla-envoltura::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 6px; }
.tabla-envoltura::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 6px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.7rem;
}
th, td {
  padding: 2px 6px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  white-space: normal;
  line-height: 1.3;
}
.sortable { color: #fff; cursor: pointer; white-space: nowrap; }
.sortable:hover { color: #dbeafe; text-decoration: underline; }
.sortable.sel { color: #fde047; }
.sortable span { font-size: .68rem; }
/* Tooltip propio del nombre de archivo (fondo rojo, letras blancas) */
.cols-hist td.tooltip-nom {
  position: relative;
  cursor: help;
}
.cols-hist td.tooltip-nom::after {
  content: attr(data-nombre);
  position: absolute;
  left: -4px;
  top: 100%;
  z-index: 50;
  background: #dc2626;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  white-space: nowrap;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.cols-hist td.tooltip-nom:hover::after {
  opacity: 1;
  visibility: visible;
}
th { background: #1e3a8a; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.01em; color: #fff; white-space: nowrap; padding: 8px 6px; }
@media (max-width: 760px) {
  .contenido { padding: 12px 8px 40px; }
  .tarjeta { padding: 12px; }
  .usuario { margin-left: auto; padding: 4px 0 12px; }
}
tr:hover td { background: #f8fafc; }
tbody tr:nth-child(even) td { background: #eef2f7; }
table.cols-admin tbody a, table.cols-basico tbody a { color: #1e293b; font-weight: 600; text-decoration: none; }
table.cols-admin tbody a:hover, table.cols-basico tbody a:hover { text-decoration: underline; text-decoration-color: #6b7280; }
tbody tr:nth-child(even):hover td { background: #f8fafc; }
.precio, .num { text-align: right; }
.precio { font-weight: 700; }
.precio-venta { color: #1e40af; }
.precio-venta a { color: inherit; font-weight: 700; }
/* Ganarle a la regla de enlaces de tabla (table.cols-admin tbody a) por especificidad */
table.cols-admin tbody td.precio-venta a,
table.cols-basico tbody td.precio-venta a,
table.cols-vista tbody td.precio-venta a,
table.cols-proveedor tbody td.precio-venta a,
table.cols-hist tbody td.precio-venta a,
table.cols-usuarios tbody td.precio-venta a,
table.cols-plantillas tbody td.precio-venta a { color: inherit; font-weight: 700; }
.precio-compra { color: #475569; }

.etiqueta {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}
.etiqueta-nuevo    { background: #dcfce7; color: #166534; }
.etiqueta-actual   { background: #e0f2fe; color: #075985; }
.etiqueta-sin      { background: #f1f5f9; color: #64748b; }
.etiqueta-rol-admin { background: #1d4ed8; color: #fff; }
.etiqueta-rol-usr   { background: #e2e8f0; color: #334155; }
.activo-si { color: #16a34a; font-weight: 700; }
.activo-no { color: #b91c1c; font-weight: 700; }

/* ===== Paginación ===== */
.paginacion { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: center; margin-top: 18px; }
.paginacion a, .paginacion span {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
}
.paginacion a:hover { background: #eff6ff; text-decoration: none; }
.paginacion .actual { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ===== Login ===== */
.login-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(rgba(15,23,42,.25), rgba(15,23,42,.25)),
    url("FPaula.jpg") center / cover no-repeat fixed;
}
.login-caja {
  margin: auto;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-caja h1 { margin: 0 0 18px; font-size: 1.25rem; color: #0f172a; text-align: center; }
.login-logo { display: block; max-height: 90px; max-width: 100%; height: auto; width: auto; margin: 0 auto 18px; }

/* ===== Detalle producto ===== */
dl.detalle { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; margin: 0; }
dl.detalle dt { font-weight: 700; color: #475569; }
dl.detalle dd { margin: 0; }
@media (max-width: 560px) { dl.detalle { grid-template-columns: 1fr; } }

.mini-mapa { font-size: 0.86rem; }
.mini-mapa b { color: #b45309; }

/* ===== Todos los textos más grandes SOLO en pantallas mayores a un teléfono apaisado =====
   Un teléfono apaisado nunca supera ~500px de alto, por lo que exigir ambos
   mínimos (ancho > 900px Y alto > 500px) excluye celulares en cualquier formato.
   Todo el CSS usa rem, así que subir el font-size raíz agranda todos los textos
   de todas las páginas en la misma proporción. */
@media (min-width: 901px) and (min-height: 501px) {
  html { font-size: 20px; }
  table { font-size: 0.95rem; }
  th { font-size: 0.78rem; padding: 10px 8px; }
  th, td { padding: 5px 8px; line-height: 1.45; }
  .sortable span { font-size: 0.72rem; }
}