:root {
  --fondo: #f6f5f1;
  --superficie: #ffffff;
  --texto: #1f2421;
  --tenue: #6b716d;
  --borde: #dcdcd4;
  --acento: #2f6b4f;
  --acento-texto: #ffffff;
  --derivado: #eef3f0;
  --rojo: #b3261e;
  --rojo-fondo: #fcebea;
  --ok-fondo: #e7f2ec;
  --medio: #8a5a00;
  --radio: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #161917;
    --superficie: #1f2320;
    --texto: #e6e8e5;
    --tenue: #9aa19c;
    --borde: #353b37;
    --acento: #6fbf97;
    --acento-texto: #10231a;
    --derivado: #232b26;
    --rojo: #ff8a80;
    --rojo-fondo: #3a1f1d;
    --ok-fondo: #1f3328;
    --medio: #e8b64c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--acento); }

.barra {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem 1rem; background: var(--superficie); border-bottom: 1px solid var(--borde);
}
.marca { font-weight: 600; text-decoration: none; color: var(--texto); }
.barra nav { flex: 1; }
.barra nav { display: flex; gap: 1rem; }
.barra nav a { text-decoration: none; font-weight: 500; color: var(--tenue); }
.barra nav a[aria-current="page"] { color: var(--acento); }
.salir { display: flex; align-items: center; gap: .5rem; margin: 0; }
.quien { color: var(--tenue); font-size: .9rem; }

.contenido { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }

.encabezado { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.migas { margin: 0 0 .25rem; color: var(--tenue); font-size: .9rem; }

.tarjeta {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 1.25rem; margin-bottom: 1rem;
}
.login { max-width: 360px; margin: 10vh auto 0; }
.login h1 { margin-bottom: 1rem; }

label { display: block; font-weight: 500; margin: .75rem 0 .25rem; }
input, select {
  font: inherit; color: inherit; background: var(--superficie);
  border: 1px solid var(--borde); border-radius: 6px; padding: .5rem .6rem; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--acento); outline-offset: 2px;
}
input[aria-invalid="true"], fieldset[aria-invalid="true"] { border-color: var(--rojo); }

.boton, .boton-secundario, .boton-peligro, .boton-texto {
  font: inherit; font-weight: 500; border-radius: 6px; padding: .5rem 1rem; cursor: pointer;
  text-decoration: none; display: inline-block; border: 1px solid transparent; line-height: 1.4;
}
.boton { background: var(--acento); color: var(--acento-texto); }
.boton-secundario { background: transparent; color: var(--texto); border-color: var(--borde); }
.boton-peligro { background: transparent; color: var(--rojo); border-color: var(--rojo); }
.boton-texto { background: none; color: var(--tenue); padding: .5rem .25rem; }
.login .boton { margin-top: 1.25rem; width: 100%; }

.aviso { padding: .6rem .8rem; border-radius: 6px; margin: 0 0 1rem; border-left: 4px solid transparent; }
/* Que se note: el éxito es verde con una tilde y el error es rojo con borde; antes era una línea casi del color del fondo. */
.aviso-ok { background: var(--ok-fondo); border-left-color: var(--acento); font-weight: 500; }
.aviso-ok::before { content: "✓ "; color: var(--acento); font-weight: 700; }
.aviso-error { background: var(--rojo-fondo); color: var(--rojo); border-left-color: var(--rojo); }
.aviso-fallo ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.aviso-fallo:focus { outline: none; }

.alerta-viejos { background: var(--rojo-fondo); color: var(--rojo); padding: .6rem .8rem; border-radius: 6px; }
.viejo { color: var(--rojo); font-weight: 500; }

.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.filtros input { flex: 1 1 14rem; width: auto; }
.filtros select { width: auto; }

.tabla-envoltorio { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); }
.tabla th, .tabla td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla th { font-size: .85rem; color: var(--tenue); font-weight: 500; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla tr.inactivo td { color: var(--tenue); }
.tabla tfoot td { font-weight: 600; border-top: 2px solid var(--borde); border-bottom: 0; }

/* Lo derivado se ve distinto de lo que se tipea: fondo propio y sin borde de campo. */
.derivado { background: var(--derivado); }
.derivado-marca {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tenue);
  border: 1px solid var(--borde); border-radius: 4px; padding: 0 .3rem; margin-left: .25rem; font-weight: 500;
}
.derivado-bloque { background: var(--derivado); border-radius: 6px; padding: .75rem 1rem; margin-top: 1rem; }
.derivado-titulo { margin: 0; font-weight: 500; }
.formula { margin: .25rem 0; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.etiqueta { font-size: .75rem; color: var(--tenue); border: 1px solid var(--borde); border-radius: 4px; padding: 0 .3rem; margin-left: .35rem; }
.tenue { color: var(--tenue); }
.vacio { color: var(--tenue); padding: 2rem 0; }
.ayuda { color: var(--tenue); font-size: .9rem; margin: .25rem 0 0; }
.error-campo { color: var(--rojo); font-size: .9rem; margin: .25rem 0 0; }

fieldset.unidad { border: 1px solid var(--borde); border-radius: 6px; margin: 1rem 0 0; padding: .5rem .9rem .75rem; }
fieldset.unidad legend { font-weight: 500; padding: 0 .25rem; }
.opcion { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; margin: .5rem 0; }
.opcion input { width: auto; margin-top: .3rem; }
.fija { margin: .25rem 0 0; }

.fila-numeros { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: 1.25rem; }
.acciones-insumo { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.acciones-insumo h2 { flex-basis: 100%; }
.acciones-insumo form { margin: 0; }
.lista { margin: .5rem 0; padding-left: 1.25rem; }

/* ── Productos y editor de recetas ─────────────────────────────────────── */
.resumen { color: var(--tenue); margin: 0 0 1rem; }
.estado-usa_inactivo { color: var(--rojo); font-weight: 500; }
.estado-completa { color: var(--acento); }
.etiqueta-roja { color: var(--rojo); border-color: var(--rojo); }

.fila-producto { display: grid; grid-template-columns: 1fr 3fr; gap: 0 1rem; }
.presets { margin: .25rem 0 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.presets .boton-texto { padding: .1rem .4rem; font-size: .85rem; border: 1px solid var(--borde); }

.buscador { position: relative; max-width: 32rem; margin-bottom: 1rem; }
.buscador label { margin-top: 0; }
.opciones {
  position: absolute; z-index: 5; left: 0; right: 0; margin: .15rem 0 0; padding: .25rem 0; list-style: none;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: 6px;
  box-shadow: 0 6px 18px rgb(0 0 0 / .12);
}
.opciones li { padding: .4rem .7rem; cursor: pointer; }
.opciones li[aria-selected="true"] { background: var(--derivado); }

.tabla.lineas td { vertical-align: middle; }
.linea-cantidad { display: flex; gap: .4rem; align-items: center; }
.linea-cantidad input { width: 6.5rem; text-align: right; }
.linea-cantidad select { width: auto; }
.linea-en { color: var(--tenue); }
.linea-texto { white-space: nowrap; }
.linea-marcas .etiqueta { margin-left: .35rem; }
.linea-cambiar, .linea-quitar button { font-size: .85rem; padding: .1rem .3rem; }
tr.linea.con-error td { background: var(--rojo-fondo); }
tr.linea.resaltada td { background: var(--derivado); transition: background .3s; }

.totales { display: flex; justify-content: space-between; gap: 1rem; margin: .2rem 0; font-variant-numeric: tabular-nums; }
.marca-completa { margin-top: 1rem; }

/* ── Calculadora ───────────────────────────────────────────────────────── */
.fila-precio { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; max-width: 40rem; }
.fila-precio input { text-align: right; }
.precio-bajo_costo, .precio-bajo_minimo { color: var(--rojo); font-weight: 500; }
.precio-ok { color: var(--acento); }
.precio-sin_precio, .precio-no_se_cotiza { color: var(--tenue); }
/* Los tres niveles de margen (Calculadora). El Costeo sigue con .precio-* (sus cuatro valores congelados). */
.nivel-bajo_costo, .nivel-critico { color: var(--rojo); font-weight: 500; }
.nivel-medio { color: var(--medio); font-weight: 500; }
.nivel-ideal { color: var(--acento); }
.nivel-sin_precio, .nivel-no_se_cotiza { color: var(--tenue); }
/* La miniatura del listado: la foto de verdad, a un tamaño que se ve. */
.producto-celda { display: flex; align-items: center; gap: .75rem; }
.foto-lista { display: block; width: 5rem; height: 5rem; object-fit: cover; border-radius: 6px; flex: none; }
.foto-lista-vacia { display: flex; align-items: center; justify-content: center; text-align: center; background: var(--derivado); color: var(--tenue); font-size: .75rem; }

/* ── Costeo ────────────────────────────────────────────────────────────── */
.separado { margin-top: 1.5rem; }
.congelar input { max-width: 32rem; }
.tabla.comparacion td { vertical-align: top; }

/* ── Proyección ────────────────────────────────────────────────────────── */
.campo-arreglos { width: 7rem; text-align: right; }
.total-principal { font-size: 1.15rem; }
.aportes { margin-top: .25rem; font-size: .9rem; }
.aportes summary { color: var(--tenue); cursor: pointer; }
.aportes ul { margin: .25rem 0 0; padding-left: 1.1rem; }

/* Panel de avisos */
.campana { white-space: nowrap; }
.cuenta { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; font-size: .8rem; text-align: center; background: var(--derivado); color: var(--texto); font-variant-numeric: tabular-nums; }
.cuenta-pendiente { background: var(--rojo); color: var(--superficie); }
.avisos-seccion { margin-top: 1.5rem; }
.avisos-seccion > h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.avisos-lista { list-style: none; margin: 0; padding: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); }
.avisos-lista > li { padding: .65rem .85rem; border-bottom: 1px solid var(--borde); }
.avisos-lista > li:last-child { border-bottom: 0; }
.pendiente { display: flex; gap: .75rem 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; border-left: 3px solid var(--rojo); }
.aviso-titulo { margin: 0; font-weight: 500; }
.aviso-detalle { margin: .15rem 0 0; color: var(--tenue); font-size: .9rem; font-variant-numeric: tabular-nums; }
.aviso-meta { color: var(--tenue); font-size: .85rem; }
.grupo summary { cursor: pointer; display: flex; gap: .5rem 1rem; align-items: baseline; flex-wrap: wrap; }
.grupo summary::-webkit-details-marker { display: none; }
.grupo summary::before { content: "▸"; color: var(--tenue); }
.grupo[open] summary::before { content: "▾"; }
.grupo ul { list-style: none; margin: .5rem 0 0; padding: 0 0 0 1.1rem; }
.grupo ul li { padding: .35rem 0; border-top: 1px solid var(--borde); }
.grupo form { margin: .5rem 0 0 1.1rem; }
.visto { opacity: .7; }

/* Taller: celular, de pie, con las manos ocupadas. Una columna, botones de
   dedo entero, nada que haya que apuntar. */
body.taller { font-size: 18px; }
.taller-contenido { max-width: 34rem; margin: 0 auto; padding: 1rem 1rem 4rem; }
.taller h1 { font-size: 1.5rem; margin: .25rem 0 1rem; }
.taller h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
.taller-volver { margin: 0; font-size: 1rem; }
.taller-mensaje { font-size: 1.1rem; padding: 1rem 0; }
.taller-botones { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.taller-boton { display: flex; align-items: center; justify-content: center; min-height: 4rem; padding: .75rem 1rem;
  border-radius: 12px; border: 2px solid var(--borde); background: var(--superficie); color: var(--texto);
  font-size: 1.3rem; font-weight: 600; text-decoration: none; width: 100%; cursor: pointer; }
.taller-boton-principal { background: var(--acento); color: var(--acento-texto); border-color: var(--acento); margin: .5rem 0 1rem; }
.taller-buscar label, .taller-form label { margin-top: .5rem; }
.taller-buscar input, .taller-form input, .taller-datos input, .taller .buscador input { font-size: 1.1rem; min-height: 3rem; }
.taller-lista { list-style: none; margin: .75rem 0 0; padding: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); }
.taller-lista li a { display: block; padding: .85rem 1rem; border-bottom: 1px solid var(--borde); text-decoration: none; color: var(--texto); }
.taller-lista li:last-child a { border-bottom: 0; }
.taller-codigo { font-weight: 600; font-variant-numeric: tabular-nums; }
.taller-lineas { list-style: none; margin: .5rem 0; padding: 0; }
.taller-lineas li.linea { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: .65rem .8rem; margin-bottom: .5rem; }
.taller-lineas li.linea.con-error { background: var(--rojo-fondo); }
.taller-lineas li.linea.resaltada { background: var(--derivado); }
.linea-cabeza { margin: 0 0 .35rem; font-weight: 600; }
.taller-lineas .linea-cantidad input { width: 7rem; font-size: 1.1rem; min-height: 2.75rem; }
.taller-lineas .linea-cantidad select { font-size: 1rem; min-height: 2.75rem; }
.linea-acciones { display: flex; justify-content: space-between; margin: .25rem 0 0; }
.taller .opciones li { padding: .75rem .9rem; font-size: 1.05rem; }
.taller-datos { margin: 1rem 0; }
.taller-datos summary { cursor: pointer; color: var(--tenue); }

.taller-boton { flex-direction: column; }
.taller-armando { display: block; font-size: .95rem; font-weight: 500; opacity: .85; }
.cronometro { margin: .5rem 0 1rem; }
.cronometro-tiempo { font-size: 3.5rem; font-weight: 700; text-align: center; margin: .25rem 0; font-variant-numeric: tabular-nums; }
.cronometro-ayuda { text-align: center; }
.taller-boton-acabar { background: var(--rojo); border-color: var(--rojo); color: var(--superficie); min-height: 5rem; font-size: 1.6rem; margin-top: .5rem; }

/* Pantalla de Pablo: floristas y celulares */
.fila-accion { display: flex; gap: .5rem 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.fila-accion form { margin: 0; }
.alta-celular .qr { background: #fff; display: inline-block; padding: .5rem; border-radius: 8px; }
.alta-celular .qr svg { display: block; max-width: 100%; height: auto; }
.enlace-alta code { word-break: break-all; font-size: .85rem; }

/* La lista congelada se imprime: sin barra, sin formularios, sin fondos. */
@media print {
  .barra, .no-imprimir, form { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .contenido { max-width: none; padding: 0; }
  .derivado, .tabla { background: none; }
  .tabla th, .tabla td { padding: .2rem .4rem; }
  a { color: inherit; text-decoration: none; }
}

/* Fotos de los productos (009) */
.foto-producto { display: block; max-width: 100%; max-height: 28rem; height: auto; border-radius: var(--radio); margin: .5rem 0; }
.foto-mini { width: 2.5rem; height: 2.5rem; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: .5rem; }
.foto-form input[type="file"] { max-width: 100%; margin: .25rem 0; }
.taller .foto-form input[type="file"] { width: 100%; min-height: 3rem; font-size: 1.05rem; }
.foto-pendiente { border: 2px solid var(--acento); }
.sin-foto { color: var(--tenue); font-size: .9rem; }
/* La receta para imprimir (tramo 4). En pantalla se ve como una tarjeta; al imprimir, una hoja A4. */
.receta-hoja { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.25rem; margin: 0 0 1rem; }
.receta-codigo { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--tenue); }
.receta-nombre { margin: 0 0 .75rem; font-size: 1.6rem; }
.receta-foto { display: block; max-width: 100%; max-height: 22rem; height: auto; margin: .5rem 0 1rem; border-radius: var(--radio); }
.receta-sin-foto { border: 2px dashed var(--borde); padding: 2rem; text-align: center; color: var(--tenue); margin: .5rem 0 1rem; }
.receta-tabla { width: 100%; border-collapse: collapse; font-size: 1.15rem; }
.receta-tabla th, .receta-tabla td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--borde); }
.receta-tabla th { font-size: .85rem; color: var(--tenue); font-weight: 500; }
.receta-tabla td:last-child, .receta-tabla th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.receta-inactivo { color: var(--tenue); font-size: .9rem; }
.receta-aviso { color: var(--rojo); font-weight: 600; margin: 1rem 0 0; }
.receta-pie { margin-top: 1.5rem; font-size: .85rem; color: var(--tenue); }
.receta-controles { margin-bottom: 1rem; }
.barra-seleccion { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 0 0 .75rem; }
.barra-seleccion button:disabled { opacity: .5; cursor: not-allowed; }
.tabla td.seleccion-receta { position: relative; min-width: 5rem; height: 44px; }
.elegir-receta { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; cursor: pointer; }
.elegir-receta input { width: 24px; height: 24px; margin: 0; padding: 0; cursor: inherit; accent-color: var(--acento); }
.elegir-receta:has(input:disabled) { cursor: not-allowed; }

/* Una receta por hoja. break-after Y page-break-after: los navegadores viejos solo
   conocen la segunda. La última no corta: otra hoja en blanco al final es papel
   perdido. :last-of-type y no :last-child, así un <script> después no lo rompe. */
@page { size: A4; margin: 1.5cm; }
@media print {
  /* El tema oscuro no se imprime. */
  :root { --fondo: #fff; --superficie: #fff; --texto: #000; --tenue: #444; --borde: #999; --rojo: #b00020; }
  .receta-hoja { border: 0; padding: 0; margin: 0; border-radius: 0; break-after: page; page-break-after: always; }
  .receta-hoja:last-of-type { break-after: auto; page-break-after: auto; }
  .receta-cabeza { break-after: avoid; page-break-after: avoid; }
  /* El tamaño final de la foto, el margen de la hoja y el @page de las recetas viven en
     receta_impresa.css, que solo cargan las pantallas de receta. Acá queda un tope por si no carga. */
  .receta-foto { max-height: 9cm; }
  .receta-tabla tr { break-inside: avoid; page-break-inside: avoid; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 700px) {
  .fila-numeros { grid-template-columns: 1fr; }
  .fila-producto { grid-template-columns: 1fr; }
  .fila-precio { grid-template-columns: 1fr; }
  .tabla td:not([data-titulo])::before { content: none; }
  .totales { flex-wrap: wrap; gap: 0 1rem; }
  .totales strong { margin-left: auto; }
  .linea-texto { white-space: normal; }
  .quien { display: none; }
  /* Con tres secciones la barra no entra en una fila: la navegación baja a la suya. */
  .barra { flex-wrap: wrap; gap: .25rem 1rem; }
  .barra .marca { flex: 1; }
  .barra nav { order: 3; flex-basis: 100%; flex-wrap: wrap; gap: .25rem 1rem; }
  .tabla thead { display: none; }
  .tabla, .tabla tbody, .tabla tfoot, .tabla tr, .tabla td { display: block; width: 100%; }
  .tabla tr { border-bottom: 1px solid var(--borde); padding: .5rem 0; }
  .tabla td { border: 0; padding: .15rem .75rem; text-align: left; }
  .tabla td::before { content: attr(data-titulo) ": "; color: var(--tenue); font-size: .85rem; }
  .tabla .num { text-align: left; }
  /* «-1.234,56 Bs · -25,3%» con su etiqueta no entra en 360 px: que baje de línea en vez de desbordar la tarjeta. */
  .tabla td.margen { white-space: normal; }
  .foto-lista { width: 4rem; height: 4rem; }
}
