/* Estilos del ERP. Pensado para PC y tablet (botones grandes). */
:root {
  --fondo: #f4f6f9;
  --tarjeta: #ffffff;
  --texto: #1c2430;
  --suave: #5b6675;
  --borde: #d9dee6;
  --primario: #1f3a5f;
  --primario-hover: #2b4f80;
  --error-fondo: #fdecec;
  --error-texto: #a61b1b;
  --radio: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #12161c; --tarjeta: #1b212a; --texto: #e6eaf0; --suave: #9aa5b4;
    --borde: #2c3542; --primario: #4f7fbf; --primario-hover: #6b97d1;
    --error-fondo: #3a1c1c; --error-texto: #ffb3b3;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* lo oculto, siempre oculto */
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { margin: 0 0 .25rem; font-size: 1.6rem; }
.subtitulo { color: var(--suave); margin: 0 0 1.5rem; }

/* Barra superior */
.barra {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--primario); color: #fff;
}
.barra form { margin: 0; }
.marca { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.barra-derecha { display: flex; gap: 1rem; align-items: center; }
.barra .enlace { color: #fff; }
.usuario { opacity: .9; }

.contenido { max-width: 1320px; margin: 0 auto; padding: 1.5rem 1rem; }

/* Login */
.pantalla-login .contenido { min-height: 100vh; display: grid; place-items: center; }
.tarjeta-login {
  width: 100%; max-width: 380px; background: var(--tarjeta);
  border: 1px solid var(--borde); border-radius: var(--radio); padding: 2rem;
}
.tarjeta-login label { display: block; margin: 1rem 0 .35rem; font-weight: 600; }
.tarjeta-login input {
  width: 100%; padding: .8rem; font-size: 1rem; border-radius: 8px;
  border: 1px solid var(--borde); background: var(--fondo); color: var(--texto);
}
.aviso-error {
  background: var(--error-fondo); color: var(--error-texto);
  padding: .75rem; border-radius: 8px; margin-bottom: .5rem;
}

/* Botones */
.boton-principal {
  display: block; width: 100%; margin-top: 1.5rem; padding: .9rem;
  border: 0; border-radius: 8px; background: var(--primario); color: #fff;
  font-size: 1rem; font-weight: 600; cursor: pointer; text-align: center;
  text-decoration: none;
}
.boton-principal:hover { background: var(--primario-hover); }
.boton-secundario {
  padding: .45rem .9rem; border-radius: 8px; border: 1px solid rgba(255,255,255,.6);
  background: transparent; color: #fff; cursor: pointer; font-size: .95rem;
}

/* Módulos del inicio */
.rejilla-modulos {
  display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.modulo {
  display: flex; flex-direction: column; gap: .25rem; padding: 1.25rem;
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  min-height: 150px;
}
.modulo span { color: var(--suave); }
.modulo-icono { font-size: 2rem; }
.modulo-pronto { opacity: .65; }
.modulo em { margin-top: auto; font-size: .85rem; color: var(--suave); }

/* --- Barra: empresa y botón Registros ------------------------------------ */
.barra-izquierda { display: flex; align-items: center; gap: 1rem; }
.barra .boton-barra { color: #fff; text-decoration: none; padding: .3rem .75rem; border: 1px solid rgba(255,255,255,.45); border-radius: 8px; }
.barra .boton-barra:hover { background: rgba(255,255,255,.12); }
.boton-cuenta { display: inline-flex; align-items: center; gap: .4rem; }
.icono-cuenta { font-size: 1.05rem; line-height: 1; }
.empresa-actual { opacity: .8; font-size: .9rem; }
.barra .enlace { text-decoration: none; }
.boton-registros { position: relative; }
.globo {
  display: inline-block; min-width: 1.3rem; padding: 0 .35rem; margin-left: .25rem;
  border-radius: 999px; background: #e0483e; color: #fff; font-size: .75rem;
  font-weight: 700; text-align: center; line-height: 1.3rem;
}
@media (max-width: 640px) {
  .barra { flex-wrap: wrap; gap: .5rem; }
  .barra-derecha { gap: .6rem; flex-wrap: wrap; }
  span.usuario { display: none; }
  .boton-cuenta { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* --- Avisos ---------------------------------------------------------------- */
.aviso { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.aviso-error { background: var(--error-fondo); color: var(--error-texto); }
.aviso-success { background: #e6f5ea; color: #1e6b34; }
@media (prefers-color-scheme: dark) { .aviso-success { background: #16301f; color: #9be0b0; } }

/* --- Formularios ----------------------------------------------------------- */
.formulario fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.formulario legend { font-weight: 700; margin-bottom: .25rem; color: var(--suave); }
.campo { margin-top: .9rem; }
.campo label { display: block; font-weight: 600; margin-bottom: .3rem; }
.campo input:not([type=checkbox]), .campo select {
  width: 100%; padding: .75rem; font-size: 1rem; border-radius: 8px;
  border: 1px solid var(--borde); background: var(--fondo); color: var(--texto);
}
.campo-check { display: flex; align-items: center; gap: .6rem; flex-direction: row-reverse; justify-content: flex-end; }
.campo-check label { margin: 0; }
.campo-check input { width: 1.3rem; height: 1.3rem; }
.campo .ayuda { display: block; color: var(--suave); margin-top: .25rem; }
.campo .error { display: block; color: var(--error-texto); margin-top: .25rem; }
.campo-error input, .campo-error select { border-color: var(--error-texto); }
.trampa { position: absolute; left: -9999px; }
.tarjeta-login .campo label { margin: 0 0 .35rem; }
.tarjeta-ancha { max-width: 480px; }
.enlaces-login { display: flex; flex-direction: column; gap: .75rem; margin-top: 1.25rem; text-align: center; }
.enlaces-login a { color: var(--primario); }
.boton-contorno {
  display: block; padding: .8rem; border-radius: 8px; border: 1px solid var(--primario);
  text-decoration: none; font-weight: 600;
}
.nota { color: var(--suave); font-size: .92rem; }
.tabla td.fecha { white-space: nowrap; color: var(--suave); font-size: .9rem; }
.fechas-ficha { margin: -.4rem 0 1rem; }

/* --- Tarjetas, tablas y botones -------------------------------------------- */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 1.25rem; margin-bottom: 1rem;
}
.tarjeta-formulario { max-width: 520px; }
.cabecera-pagina { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cabecera-pagina .subtitulo { margin: 0; }
.boton-auto { width: auto; margin: 0; padding: .75rem 1.25rem; }
.tabla-contenedor { overflow-x: auto; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--borde); }
.tabla th { font-size: .85rem; color: var(--suave); font-weight: 600; }
.tabla th.ordenable a { color: inherit; text-decoration: none; white-space: nowrap; }
.tabla th.ordenable a:hover { color: var(--texto, inherit); text-decoration: underline; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla-compacta { margin-top: .75rem; font-size: .92rem; }
.acciones { text-align: right; white-space: nowrap; }
.acciones form { display: flex; gap: .5rem; }
.boton-pequeno, .boton-ok, .boton-peligro {
  display: inline-block; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--borde);
  background: var(--tarjeta); color: var(--texto); text-decoration: none; cursor: pointer; font-size: .95rem;
}
.boton-ok { background: #1e7a3c; border-color: #1e7a3c; color: #fff; }
.boton-peligro { background: transparent; border-color: #c0392b; color: #c0392b; }
@media (prefers-color-scheme: dark) { .boton-peligro { color: #ff8a80; border-color: #ff8a80; } }
.etiqueta { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--fondo); border: 1px solid var(--borde); color: var(--suave); }
.estado { font-size: .8rem; padding: .15rem .55rem; border-radius: 999px; font-weight: 600; vertical-align: middle; }
.estado-activa { background: #e6f5ea; color: #1e6b34; }
.estado-pendiente { background: #fff4d6; color: #7a5a00; }
.estado-suspendida { background: var(--error-fondo); color: var(--error-texto); }
@media (prefers-color-scheme: dark) {
  .estado-activa { background: #16301f; color: #9be0b0; }
  .estado-pendiente { background: #3a2f10; color: #f3d27a; }
}
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filtros a {
  padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--borde);
  text-decoration: none; color: var(--texto); background: var(--tarjeta);
}
.filtros a.activo { background: var(--primario); border-color: var(--primario); color: #fff; }
.empresa-cabecera { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.empresa-cabecera h2 { margin: 0; font-size: 1.2rem; }
.empresa-cabecera .subtitulo { margin: .25rem 0 0; font-size: .9rem; }
details { margin-top: .75rem; }
summary { cursor: pointer; color: var(--primario); }
a.modulo { text-decoration: none; color: var(--texto); }
a.modulo:hover { border-color: var(--primario); }
.modulo .destacado { color: #b35c00; font-style: normal; font-weight: 600; }

/* Tablas en móvil/tablet vertical: cada fila como tarjeta */
@media (max-width: 700px) {
  .tabla thead { display: none; }
  .tabla tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--borde); }
  .tabla td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem .8rem; }
  .tabla td[data-titulo]::before { content: attr(data-titulo); color: var(--suave); font-size: .85rem; }
  .acciones { text-align: left; }
}
.contenido a:not([class]) { color: var(--primario); }
.rejilla-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.rejilla-campos .ancho-total { grid-column: 1 / -1; }
@media (max-width: 640px) { .rejilla-campos { grid-template-columns: 1fr; } }
.tarjeta-formulario.ancha { max-width: 760px; }
.pasos { padding-left: 1.2rem; margin: 0 0 1rem; }
.pasos li { margin-bottom: .6rem; }
.pasos ul { margin: .4rem 0 0; padding-left: 1.1rem; }
code { background: var(--fondo); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }
.fila-error td { background: color-mix(in srgb, var(--error-fondo) 60%, transparent); }
.error-fila { color: var(--error-texto); font-size: .9rem; }
.botonera { display: flex; gap: .75rem; justify-content: flex-end; align-items: center; margin-top: 1rem; }
.botonera form { margin: 0; }
.boton-ok { padding: .7rem 1.2rem; font-weight: 600; }
.campo input[type=file] { padding: .6rem; }

/* --- Selector de empresa (arriba a la izquierda) --------------------------- */
.selector-empresa { position: relative; }
.selector-empresa summary {
  list-style: none; cursor: pointer; color: #fff; padding: .3rem .75rem;
  border: 1px solid rgba(255,255,255,.45); border-radius: 8px; white-space: nowrap;
}
.selector-empresa summary::-webkit-details-marker { display: none; }
.selector-empresa summary:hover { background: rgba(255,255,255,.12); }
.menu-empresas {
  position: absolute; top: calc(100% + .4rem); left: 0; z-index: 20; min-width: 240px;
  background: var(--tarjeta); color: var(--texto); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: .4rem;
}
.menu-empresas form { margin: 0; }
.menu-empresas .fila-empresa { display: flex; gap: .2rem; }
.menu-empresas .fila-empresa button.datos-empresa { width: auto; flex: none; padding: .6rem .7rem; text-align: center; opacity: .75; }
.menu-empresas .fila-empresa button.datos-empresa:hover { opacity: 1; }
.menu-empresas button, .menu-empresas a {
  display: block; width: 100%; text-align: left; padding: .6rem .75rem; border: 0;
  border-radius: 8px; background: none; color: var(--texto); font-size: .95rem;
  cursor: pointer; text-decoration: none;
}
.menu-empresas button:hover, .menu-empresas a:hover { background: var(--fondo); }
.menu-empresas button.actual { font-weight: 700; }
.menu-empresas a.nueva { color: var(--primario); border-top: 1px solid var(--borde); margin-top: .3rem; border-radius: 0 0 8px 8px; }
.empresas-usuario { margin-top: 1.2rem !important; }
.fila-empresa { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--borde); }
.fila-empresa label { font-weight: 600; }
.fila-empresa select { padding: .5rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); min-width: 9rem; }

/* --- Catálogo -------------------------------------------------------------- */
.buscador { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.buscador input[type=search] { flex: 1 1 280px; padding: .7rem .8rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font-size: 1rem; }
.buscador select { padding: .6rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); }
.tabla .num { text-align: right; white-space: nowrap; }
.tabla tr.inactivo td { opacity: .5; }
.miniatura { width: 48px; }
.miniatura img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 6px; display: block; }
.paginacion { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }
.resumen-precios { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-top: 1rem; }
.resumen-precios div { background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; padding: .55rem .75rem; display: flex; flex-direction: column; }
.resumen-precios span { font-size: .8rem; color: var(--suave); }
.resumen-precios strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.resumen-precios .destacado { border-color: var(--primario); }
.foto-ficha { max-width: 160px; border-radius: 8px; margin-top: .75rem; border: 1px solid var(--borde); }
.campo textarea { width: 100%; padding: .75rem; font-size: 1rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font-family: inherit; }
.dos-columnas { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.dos-columnas h2 { margin-top: 0; font-size: 1.1rem; }
@media (max-width: 800px) {
  .dos-columnas { grid-template-columns: 1fr; }
  .resumen-precios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .miniatura { display: none; }
}

/* Sin flechitas en los números ni triángulo de sugerencias (se escribe directamente) */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[list]::-webkit-calendar-picker-indicator { display: none !important; opacity: 0; }

.bloque-foto { display: flex; gap: 1rem; align-items: flex-start; margin-top: 1rem; flex-wrap: wrap; }
.vista-foto { width: 160px; height: 160px; border-radius: 10px; border: 1px dashed var(--borde); background: var(--fondo);
  display: grid; place-items: center; overflow: hidden; flex: none; font-size: 2.5rem; color: var(--suave); }
.vista-foto img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.bloque-foto .campo { margin-top: 0; }
.campo input[type=file] { padding: .6rem; background: var(--fondo); }

/* --- Compras ---------------------------------------------------------------- */
.pestanas { margin-bottom: 1rem; }
.relaciones { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: -.4rem 0 1rem; }
.rejilla-cabecera { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .rejilla-cabecera { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .rejilla-cabecera { grid-template-columns: 1fr; } }
.titulo-lineas { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.tabla-lineas { min-width: 860px; }
.tabla-lineas td { padding: .35rem .4rem; vertical-align: top; }
.tabla-lineas input { width: 100%; padding: .5rem; font-size: .95rem; border-radius: 6px;
  border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.tabla-lineas input.num { text-align: right; max-width: 7rem; }
.tabla-lineas input:disabled { border-color: transparent; background: transparent; color: var(--texto); }
.tabla-lineas .col-articulo { width: 13rem; }
.tabla-lineas .importe, .tabla-lineas .recibido { padding-top: .8rem; }
.tabla-lineas .importe { font-weight: 600; }
.tabla-lineas input.con-articulo { border-color: var(--primario); font-weight: 600; }
.buscador-articulo { position: relative; }
.buscador-articulo .resultados { position: fixed; z-index: 30; width: 30rem; max-width: 80vw;
  margin: 0; padding: .3rem; list-style: none; background: var(--tarjeta); border: 1px solid var(--borde);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-height: 20rem; overflow-y: auto; }
.buscador-articulo .resultados li { padding: .45rem .6rem; border-radius: 6px; cursor: pointer; }
.buscador-articulo .resultados li:hover, .buscador-articulo .resultados li:first-child { background: var(--fondo); }
.buscador-articulo .resultados small { color: var(--suave); }
.ayuda-lineas { margin: .5rem 0; }
.totales { margin: 1rem 0 0 auto; max-width: 320px; display: grid; gap: .25rem; }
.totales div { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.totales span { color: var(--suave); }
.totales .total-final { border-top: 1px solid var(--borde); padding-top: .4rem; font-size: 1.2rem; }
.zona-borrar { display: flex; justify-content: flex-end; margin-top: .5rem; }
.casilla { width: 1.2rem; height: 1.2rem; }
@media (max-width: 700px) {
  .tabla-lineas { min-width: 0; }
  .tabla-lineas input.num { max-width: none; }
  .tabla-lineas .col-articulo { width: auto; }
}
.negativo { color: var(--error-texto); }
.regularizar { max-width: 760px; }
.dato-stock { display: flex; gap: 1rem; align-items: baseline; margin: .55rem 0 0; font-size: 1.1rem; }
.dato-stock a { font-size: .9rem; }
.campo-check { flex-wrap: wrap; }
.campo-check .ayuda { order: 1; flex-basis: 100%; margin-top: 0; }

/* --- Mover las cartas del inicio ------------------------------------------ */
.rejilla-modulos .modulo { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.modulo-fantasma { opacity: .35; border-style: dashed; }
.modulo-elegido { border-color: var(--primario); box-shadow: 0 10px 28px rgba(0,0,0,.25); }
.pie-modulos { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; font-size: .88rem; }
.pie-modulos form { margin: 0; }
.boton-enlace { background: none; border: 0; padding: 0; color: var(--primario); cursor: pointer; font: inherit; text-decoration: underline; }

/* --- Seleccionar filas y borrar ------------------------------------------- */
.col-casilla { width: 2.4rem; text-align: center !important; }
.col-casilla input { width: 1.2rem; height: 1.2rem; cursor: pointer; vertical-align: middle; }
.barra-seleccion { display: none; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem;
  padding: .55rem .8rem; border-radius: 10px; background: var(--tarjeta); border: 1px solid var(--primario); }
.barra-seleccion.activa { display: flex; position: sticky; top: .5rem; z-index: 15; }
.barra-seleccion button:disabled { opacity: .5; cursor: default; }
.tabla tr.seleccionada td { background: color-mix(in srgb, var(--primario) 14%, transparent); }
@media (max-width: 700px) { .tabla td.col-casilla { justify-content: flex-start; } }

/* --- Base de datos (superusuario) ----------------------------------------- */
.tabla-bd { font-size: .85rem; }
.tabla-bd td, .tabla-bd th { white-space: nowrap; padding: .45rem .6rem; }
.tabla-bd td { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nulo { color: var(--suave); font-style: italic; opacity: .7; }
.consola-sql textarea { width: 100%; margin-top: .5rem; padding: .75rem; border-radius: 8px; border: 1px solid var(--borde);
  background: var(--fondo); color: var(--texto); font: .95rem/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; }
.consola-sql .botonera { justify-content: space-between; }
@media (max-width: 700px) { .tabla-bd td { display: table-cell; } .tabla-bd thead { display: table-header-group; } .tabla-bd tr { display: table-row; } }

/* --- Inventario ------------------------------------------------------------ */
.nuevo-inventario { display: flex; gap: .5rem; flex-wrap: wrap; }
.nuevo-inventario input { padding: .7rem .8rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); min-width: 16rem; }
.descripcion-inventario input { margin-top: .4rem; padding: .45rem .6rem; border-radius: 8px; border: 1px solid var(--borde);
  background: var(--tarjeta); color: var(--texto); min-width: 20rem; max-width: 100%; }
.resumen-inventario { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.resumen-inventario div { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 10px; padding: .6rem .8rem; display: flex; flex-direction: column; }
.resumen-inventario span { font-size: .8rem; color: var(--suave); }
.resumen-inventario strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .resumen-inventario { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.escaner .fila-escaner { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.escaner #codigo { flex: 1 1 280px; padding: .8rem; font-size: 1.15rem; border-radius: 8px; border: 2px solid var(--primario); background: var(--fondo); color: var(--texto); }
.campo-check-linea { display: flex; gap: .4rem; align-items: center; cursor: pointer; }
.campo-check-linea input { width: 1.2rem; height: 1.2rem; }
.ultimo-escaneado { margin-top: .75rem; padding: .6rem .8rem; border-radius: 8px; background: var(--fondo); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ultimo-escaneado input { width: 7rem; padding: .5rem; text-align: right; font-size: 1.1rem; border-radius: 6px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); }
.tabla-inventario .conteo { width: 6.5rem; padding: .5rem; text-align: right; font-size: 1rem; border-radius: 6px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.tabla-inventario .conteo.error { border-color: var(--error-texto); }
.tabla-inventario tr.contado td:first-child { box-shadow: inset 3px 0 0 var(--primario); }
.tabla-inventario tr.guardado td { background: color-mix(in srgb, #1e7a3c 18%, transparent); transition: background .3s; }
.positivo { color: #1e7a3c; }
@media (prefers-color-scheme: dark) { .positivo { color: #9be0b0; } }
.caja-buscar { flex: 1 1 320px; }
.caja-buscar #buscar { width: 100%; padding: .8rem; font-size: 1.15rem; border-radius: 8px; border: 2px solid var(--primario); background: var(--fondo); color: var(--texto); }
.buscador-articulo .resultados li.marcado { background: var(--primario); color: #fff; }
.buscador-articulo .resultados li.marcado small { color: #e6eaf0; }
.ayuda-inventario { margin: .6rem 0 0; }
.vacio-inventario { padding: 1rem; margin: 0; }

/* --- Ventas ----------------------------------------------------------------- */
.titulo-ventas { font-size: 1rem; font-weight: 400; }
.rejilla-cabecera .doble { grid-column: span 2; }
@media (max-width: 640px) { .rejilla-cabecera .doble { grid-column: auto; } }
.aviso-recargo { text-align: right; margin: .5rem 0 0; }

/* --- TPV ----------------------------------------------------------------------- */
.pagina-tpv .contenido { max-width: none; }
.tpv { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.tpv-arriba { display: flex; gap: .6rem; margin-bottom: .75rem; }
.tpv-buscar { flex: 1; }
.tpv-buscar input { width: 100%; padding: .9rem 1rem; font-size: 1.2rem; border-radius: 10px; border: 2px solid var(--primario); background: var(--tarjeta); color: var(--texto); }
#cliente { max-width: 280px; padding: .6rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font-size: 1rem; }
.tpv-lineas { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); min-height: 55vh; overflow: auto; }
.tabla-tpv td { vertical-align: middle; padding: .45rem .6rem; }
.tabla-tpv input { width: 5.5rem; padding: .45rem; text-align: right; border-radius: 6px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font-size: 1rem; }
.tabla-tpv input.dto { width: 3.8rem; }
.tpv-cant { display: inline-flex; align-items: center; gap: .25rem; }
.tpv-cant input { width: 4rem; }
.tabla-tpv input.total { width: 4.5rem; }
.tpv-cant button { width: 2rem; height: 2rem; border-radius: 6px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); cursor: pointer; font-size: 1.1rem; }
.tabla-tpv .importe { font-weight: 700; font-size: 1.05rem; }
.tpv-vacio { padding: 2rem; text-align: center; }
.tpv-derecha { display: flex; flex-direction: column; gap: .75rem; position: sticky; top: 1rem; }
.tpv-total { background: var(--primario); color: #fff; border-radius: var(--radio); padding: 1rem 1.2rem; display: flex; flex-direction: column; }
.tpv-total span { opacity: .85; }
.tpv-total strong { font-size: 2.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tpv-total .nota { color: #e6eaf0; }
.tpv-desglose div { display: flex; justify-content: space-between; color: var(--suave); font-size: .9rem; font-variant-numeric: tabular-nums; }
.boton-cobrar { padding: 1.1rem; font-size: 1.4rem; font-weight: 700; border: 0; border-radius: var(--radio); background: #1e7a3c; color: #fff; cursor: pointer; }
.boton-cobrar:disabled { opacity: .45; cursor: default; }
kbd { font-size: .75rem; padding: .05rem .35rem; border-radius: 4px; border: 1px solid currentColor; opacity: .7; margin-left: .3rem; font-family: inherit; }
.tpv-opcion { font-size: .9rem; }
.tpv-ultimo { background: var(--tarjeta); border: 1px solid #1e7a3c; border-radius: var(--radio); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .4rem; }
.tpv-cambio-grande { font-size: 1.6rem; font-weight: 700; color: #1e7a3c; }
@media (prefers-color-scheme: dark) { .tpv-cambio-grande { color: #9be0b0; } }
.tpv-ultimo-botones { display: flex; gap: .5rem; }
.tpv-modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; }
.tpv-modal[hidden] { display: none; }
.tpv-modal-caja { background: var(--tarjeta); border-radius: 14px; padding: 1.4rem 1.6rem; width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.tpv-modal-caja h2 { margin: 0 0 .6rem; }
.tpv-a-pagar { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.1rem; }
.tpv-a-pagar strong { font-size: 2.2rem; }
.tpv-rapidos { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0; }
.tpv-medios { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
#modal-cobro .tpv-modal-caja { width: min(560px, 94vw); box-sizing: border-box; }
.tpv-medios label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; min-width: 0; }
.tpv-medios input, .tpv-medios output { width: 100%; box-sizing: border-box; min-width: 0; padding: .6rem; font-size: 1.25rem; text-align: right; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.tpv-cambio { margin-top: .8rem; font-size: 1.6rem; font-weight: 700; text-align: right; color: #1e7a3c; min-height: 2rem; }
.tpv-cambio.falta { color: var(--error-texto); }
.tpv-medios select { width: 100%; box-sizing: border-box; padding: .6rem; font-size: 1.15rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.mc-deuda { margin-top: .8rem; padding: .8rem 1rem; border-radius: 10px; border: 2px solid #b7791f; background: color-mix(in srgb, #b7791f 12%, var(--fondo)); }
.mc-deuda-texto { margin: 0 0 .6rem; font-size: 1.25rem; font-weight: 700; }
.mc-deuda input { width: 100%; box-sizing: border-box; padding: .6rem; font-size: 1.05rem; border-radius: 8px; border: 2px solid var(--primario); background: var(--fondo); color: var(--texto); margin: .3rem 0; }
.mc-deuda .lista-clientes { max-height: 40vh; overflow-y: auto; }
.total-deudas { font-size: 1.1rem; } .total-deudas strong { font-size: 1.6rem; color: var(--error-texto); margin-left: .4rem; }
@media (max-width: 900px) { .tpv { grid-template-columns: 1fr; } }
.tpv-ultimo[hidden] { display: none; }
#tipo-doc { padding: .6rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font-size: 1rem; }
.mc-parcial { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; margin-top: .6rem; }
.mc-parcial input { width: 100%; box-sizing: border-box; padding: .6rem; font-size: 1.25rem; text-align: right; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.pendiente-cobro { color: #b35c00; font-weight: 600; }
@media (prefers-color-scheme: dark) { .pendiente-cobro { color: #f3b26b; } }
details.cobros { margin: -.4rem 0 1rem; }
details.cobros table { max-width: 520px; }
.boton-cobrar.boton-doc { background: var(--primario); }
.boton-espera { padding: 1.1rem; font-size: 1.4rem; font-weight: 700; border: 0; border-radius: var(--radio); background: #b7791f; color: #fff; cursor: pointer; }
.boton-espera .globo { position: static; display: inline-block; vertical-align: middle; }
.caja-espera { width: min(720px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.lista-espera { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.lista-espera li { display: grid; grid-template-columns: 6.5rem 1fr auto auto auto; align-items: center; gap: .7rem; padding: .5rem .7rem; border: 1px solid var(--borde); border-radius: 8px; background: var(--fondo); }
.lista-espera li.nota { display: block; }
.lista-espera .quien { display: flex; flex-direction: column; }
.lista-espera .esp-total { font-weight: 700; }
.tpv-cliente-caja { display: flex; gap: .4rem; }
.tpv-cliente { display: flex; align-items: center; gap: .4rem; max-width: 340px; padding: .6rem .9rem; border-radius: 10px;
  border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font-size: 1rem; cursor: pointer; white-space: nowrap; }
.tpv-cliente span { overflow: hidden; text-overflow: ellipsis; }
.tpv-cliente.con-cliente { border-color: var(--primario); font-weight: 600; }
.caja-clientes { width: min(620px, 94vw); }
.caja-clientes input { width: 100%; padding: .8rem; font-size: 1.1rem; border-radius: 8px; border: 2px solid var(--primario); background: var(--fondo); color: var(--texto); }
.lista-clientes { list-style: none; margin: .6rem 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.lista-clientes li { padding: .6rem .7rem; border-radius: 8px; cursor: pointer; }
.lista-clientes li:hover { background: var(--fondo); }
.lista-clientes li.marcado { background: var(--primario); color: #fff; }
.lista-clientes li.marcado .nota { color: #e6eaf0; }
.nuevo-campos .ancho-total { grid-column: 1 / -1; }
.nuevo-campos input { text-align: left !important; font-size: 1.05rem !important; }
.tabla-tpv .tpv-ref, .tabla-tpv .tpv-barras { white-space: nowrap; }
.tabla-tpv input.desc { width: 100%; min-width: 12rem; text-align: left; }
.tabla-tpv input:focus { outline: none; border-color: var(--primario); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primario) 35%, transparent); }
.tpv-modal:has(.caja-productos) { place-items: start center; padding-top: 4vh; }
.caja-productos { width: min(1000px, 96vw); height: 88vh; display: flex; flex-direction: column; }
.cabecera-productos { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.filtros-productos { display: flex; gap: .5rem; margin: .4rem 0 .8rem; }
.filtros-productos input { flex: 1; padding: .7rem; font-size: 1.05rem; border-radius: 8px; border: 2px solid var(--primario); background: var(--fondo); color: var(--texto); }
.filtros-productos select { padding: .6rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.rejilla-productos { flex: 1; display: flex; flex-direction: column; gap: .3rem; overflow-y: auto; min-height: 0; }
.producto { display: grid; grid-template-columns: 44px 9rem 1fr 6rem 6rem; align-items: center; gap: .8rem; padding: .35rem .6rem; text-align: left; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font: inherit; width: 100%; }
.producto:hover, .producto:focus { border-color: var(--primario); outline: none; }
.producto.anadido { background: color-mix(in srgb, #1e7a3c 30%, var(--fondo)); }
.pr-foto { width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.4rem; background: #fff1; border-radius: 6px; overflow: hidden; }
.pr-foto img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pr-desc { line-height: 1.2; }
.producto small { text-align: right; }
.pr-precio { font-weight: 700; font-size: 1.05rem; text-align: right; }
@media (max-width: 640px) { .producto { grid-template-columns: 44px 1fr 5rem; } .producto strong, .producto small { display: none; } }

#marco-imprimir { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; }
.menu-usuario .menu-empresas { left: auto; right: 0; }
.menu-empresas button.salir-menu { border-top: 1px solid var(--borde); margin-top: .3rem; border-radius: 0 0 8px 8px; }
.cuenta-rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 560px)); gap: 1rem; align-items: start; }
.cuenta-rejilla .tarjeta h2 { margin-top: 0; font-size: 1.15rem; }
.lista-cuenta { list-style: none; padding: 0; margin: 0 0 .8rem; display: flex; flex-direction: column; gap: .4rem; }
.fila-accion { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--borde); }
.fila-accion:first-of-type { border-top: 0; }
.fila-accion p { margin: .2rem 0 0; }
.fila-accion button { white-space: nowrap; flex: none; }
.zona-peligro { margin-top: 2rem; padding: 1.2rem 1.4rem; border: 2px solid #c0392b; border-radius: var(--radio); background: color-mix(in srgb, #c0392b 8%, var(--tarjeta)); max-width: 900px; }
.zona-peligro h2 { margin: 0 0 .8rem; color: #c0392b; font-size: 1.15rem; }
@media (prefers-color-scheme: dark) { .zona-peligro h2 { color: #ff8a80; } }
.boton-borrar-empresa { display: inline-block; list-style: none; cursor: pointer; padding: .7rem 1.1rem; border-radius: 8px; background: #c0392b; color: #fff; font-weight: 700; }
.boton-borrar-empresa::-webkit-details-marker { display: none; }
.zona-peligro details[open] .boton-borrar-empresa { margin-bottom: 1rem; }
.zona-peligro ul { margin: .4rem 0 .8rem; }
.confirmar-borrado { display: flex; flex-direction: column; gap: .5rem; max-width: 520px; }
.confirmar-borrado input { padding: .7rem; font-size: 1.05rem; border-radius: 8px; border: 2px solid #c0392b; background: var(--fondo); color: var(--texto); }
.boton-borrar-definitivo { padding: .8rem 1.2rem; border: 0; border-radius: 8px; background: #c0392b; color: #fff; font-weight: 700; font-size: 1rem; cursor: pointer; }
.boton-borrar-definitivo:disabled { opacity: .4; cursor: not-allowed; }
.tpv-estado { padding: .6rem .9rem; border-radius: 8px; font-weight: 600; margin: 0 0 .6rem; }
.tpv-estado.sin-conexion { background: #c0392b; color: #fff; }
.tpv-estado.subiendo { background: #b7791f; color: #fff; }
.tpv-estado.subido { background: #1e7a3c; color: #fff; }
.tpv-estado.con-error { background: #7b241c; color: #fff; }
.tpv-sin-conexion .boton-espera { opacity: .5; }
.fila-nuevo-sector { display: flex; gap: .5rem; margin: .8rem 0 1rem; }
.fila-nuevo-sector input { flex: 1; padding: .6rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.fila-sector { display: flex; gap: .5rem; align-items: center; margin: 0; }
.fila-sector input[type=text] { flex: 1; min-width: 12rem; padding: .45rem; border-radius: 6px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.fila-sector input.orden { width: 5rem; padding: .45rem; border-radius: 6px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
/* Publicidad en el TPV (abajo) */
.tpv-publicidad { margin-top: .8rem; }
.publi-anuncio { position: relative; display: flex; align-items: center; justify-content: center; gap: .8rem; min-height: 64px; max-height: 110px;
  overflow: hidden; border-radius: var(--radio); border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto);
  text-decoration: none; padding: .6rem 1rem; animation: publi-entra .5s ease; }
.publi-anuncio img { max-width: 100%; max-height: 100px; object-fit: contain; display: block; }
.publi-anuncio small { color: var(--texto-suave, #888); text-transform: uppercase; letter-spacing: .04em; font-size: .75rem; }
.publi-anuncio strong { font-size: 1.15rem; }
.publi-marca { position: absolute; top: 3px; right: 8px; font-style: normal; font-size: .65rem; opacity: .55; }
@keyframes publi-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Panel de anuncios */
.lista-anuncios { display: flex; flex-direction: column; gap: .8rem; }
.anuncio-fila { display: grid; grid-template-columns: minmax(220px, 1.2fr) 2fr auto; gap: 1rem; align-items: center; }
.anuncio-fila.mini { grid-template-columns: minmax(200px, 1fr) 2fr auto; padding: .5rem 0; border-top: 1px solid var(--borde); }
.publi-muestra { border: 1px dashed var(--borde); border-radius: 8px; padding: .5rem .7rem; min-height: 48px; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.publi-muestra img { max-width: 100%; max-height: 60px; object-fit: contain; }
.publi-proveedor { font-size: .75rem; text-transform: uppercase; opacity: .7; }
.publi-actual { max-width: 100%; max-height: 90px; border-radius: 6px; margin-bottom: .5rem; }
.lista-sectores ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .3rem .8rem; }
.tipo-anuncio ul { list-style: none; padding: 0; display: flex; gap: 1.2rem; }
.proveedor-publi { margin-bottom: 1rem; }
@media (max-width: 760px) { .anuncio-fila, .anuncio-fila.mini { grid-template-columns: 1fr; } }
.tipo-anuncio #id_tipo { display: flex; gap: 1.5rem; }
.lista-sectores #id_sectores { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .35rem .9rem; }
.tipo-anuncio #id_tipo label, .lista-sectores #id_sectores label { display: flex; align-items: center; gap: .45rem; font-weight: 500; margin: 0; cursor: pointer; }
.tipo-anuncio #id_tipo input, .lista-sectores #id_sectores input { width: auto; margin: 0; }
.idiomas-login { display: flex; justify-content: center; gap: 1.2rem; margin: 1.2rem 0; font-size: .9rem; }
.idiomas-login a { color: var(--texto); opacity: .65; text-decoration: none; }
.idiomas-login a.actual { opacity: 1; font-weight: 700; text-decoration: underline; }
/* Publicidad del TPV en tarjetas */
.publi-cabecera { display: flex; justify-content: space-between; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; opacity: .55; margin: 0 .2rem .3rem; }
.publi-rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); grid-auto-rows: 200px; gap: 10px; }
.publi-tarjeta { display: flex; flex-direction: column; justify-content: flex-start; gap: .35rem; padding: .8rem .85rem; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); text-decoration: none;
  animation: publi-entra .45s ease; }
a.publi-tarjeta:hover { border-color: var(--primario); }
.publi-tarjeta small { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.publi-tarjeta strong { font-size: 1.1rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.publi-tarjeta span { font-size: .85rem; opacity: .8; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.publi-tarjeta.con-imagen { padding: 0; gap: 0; justify-content: flex-start; }
.publi-tarjeta.con-imagen img { width: 100%; height: auto; max-height: 140px; flex: none; object-fit: contain; display: block; background: var(--fondo); }
.publi-pie { padding: .3rem .75rem .4rem; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.publi-pie strong { font-size: .92rem !important; -webkit-line-clamp: 1 !important; }
.publi-cabecera { align-items: center; gap: .8rem; }
.publi-cabecera input { flex: 0 1 320px; margin-left: auto; padding: .35rem .6rem; font-size: .85rem; text-transform: none; letter-spacing: 0;
  border-radius: 6px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); opacity: 1; }
.publi-cabecera { opacity: 1; } .publi-cabecera > span:first-child { opacity: .55; }
.publi-boton { border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); border-radius: 6px; padding: 0 .55rem; cursor: pointer; font-size: 1rem; line-height: 1.4; }
button.publi-tarjeta { font: inherit; text-align: left; cursor: pointer; width: 100%; }
button.publi-tarjeta:hover { border-color: var(--primario); }
.caja-publi { width: min(560px, 94vw); }
.caja-publi h2 { margin: .2rem 0 .6rem; }
.pf-proveedor { text-transform: uppercase; letter-spacing: .05em; opacity: .65; }
.caja-publi img { width: 100%; border-radius: 8px; margin-bottom: .6rem; }
.pf-datos { list-style: none; padding: 0; margin: .6rem 0 1rem; display: flex; flex-direction: column; gap: .35rem; font-size: 1.05rem; }
