/* =============================================================================
   Producción en vivo · Semco (P08)
   Estilo "hoja de papel": tonos tierra (crema, arena, taupe, café), títulos en
   Fredoka redondeada, texto en Lora con serifa, tablas con encabezado café,
   formas orgánicas en los bordes. Fuentes locales (carpeta fonts/).
   ============================================================================= */
@font-face { font-family: "Fredoka"; src: url("../fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Lora"; src: url("../fonts/lora.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("../fonts/lora-italic.woff2") format("woff2"); font-weight: 400 700; font-style: italic; font-display: swap; }

:root {
  --fondo: #e9e3da; --papel: #f7f3ee; --crema: #efe8de; --arena: #d8cbbb; --taupe: #b3a291;
  --cafe: #5c4a3e; --cafe-2: #7b6657; --tinta: #3b302a; --mut: #7d6e63; --mut-2: #a69a8e;
  --sobre-cafe: #f7f3ee;
  --ok: #6b7d52; --warn: #c08636; --bad: #b4533c; --off: #a69a8e;
  --ok-suave: #e3e6d6; --warn-suave: #f3e5cf; --bad-suave: #f2dcd4;
  --radio: 18px; --borde: 2px solid var(--cafe);
  --titulo: "Fredoka", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  --texto: "Lora", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
/* Variante oscura "espresso": solo si se pone <html data-tema="oscuro">.
   Por defecto siempre es la hoja clara (la identidad visual del dashboard). */
:root[data-tema="oscuro"] {
  --fondo: #1b1612; --papel: #241e19; --crema: #2c251f; --arena: #40362e; --taupe: #6a5a4d;
  --cafe: #d9c6b0; --cafe-2: #bba58f; --tinta: #efe7dc; --mut: #b3a596; --mut-2: #85776b;
  --sobre-cafe: #241e19;
  --ok: #a6b884; --warn: #e0ad62; --bad: #e08468; --off: #85776b;
  --ok-suave: #2f3324; --warn-suave: #3a2d1a; --bad-suave: #3d221b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.oculto { position: absolute; width: 0; height: 0; overflow: hidden; }
html, body { margin: 0; }
body { background: var(--fondo); color: var(--tinta); font: 15px/1.55 var(--texto); -webkit-font-smoothing: antialiased; }
h1, h2, p, dl, dd, figure { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cafe); outline-offset: 3px; border-radius: 6px; }

/* ---------- formas orgánicas ---------- */
.decor { position: fixed; pointer-events: none; z-index: 0; }
/* (sin prefijo .decor: las formas se reutilizan con <use> y toman el estilo del original) */
.f-crema { fill: var(--crema); }
.f-arena { fill: var(--arena); }
.f-taupe { fill: var(--taupe); }
.f-cafe  { fill: var(--cafe-2); }
.trazo   { fill: none; stroke: var(--cafe-2); stroke-width: 2.2; stroke-linecap: round; }
.decor-login-a { width: 520px; top: -140px; left: -150px; opacity: .9; }
.decor-login-b { width: 560px; bottom: -170px; right: -160px; opacity: .9; transform: rotate(180deg); }
.decor-app-a { width: 360px; top: -170px; right: -140px; opacity: .45; }
.decor-app-b { width: 340px; bottom: -180px; left: -150px; opacity: .35; transform: rotate(160deg); }

/* ---------- piezas comunes ---------- */
.etiqueta { font-family: var(--titulo); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--cafe); }
.sub { display: block; color: var(--mut); font-size: 12.5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot-ok { background: var(--ok); animation: latido 2.2s infinite; }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); animation: parpadeo 1.2s infinite; }
@keyframes latido { 50% { transform: scale(1.5); opacity: .55; } }
@keyframes parpadeo { 50% { opacity: .3; } }
.aviso { padding: 12px 16px; border-radius: 12px; font-size: 14px; color: var(--bad); background: var(--bad-suave); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.enlace { background: none; border: 0; padding: 2px; color: var(--mut); cursor: pointer; font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.enlace:hover { color: var(--cafe); }
.btn { font-family: var(--titulo); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 13px;
  padding: 10px 20px; border-radius: 10px; border: var(--borde); background: var(--cafe); color: var(--sobre-cafe); cursor: pointer; }
.btn:hover { background: var(--cafe-2); border-color: var(--cafe-2); }
.btn-sec { background: transparent; color: var(--cafe); }
.btn-sec:hover { background: var(--crema); color: var(--cafe); border-color: var(--cafe); }

/* =============================================================================
   LOGIN · una "hoja" con marco orgánico
   ============================================================================= */
.login { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 48px 16px; overflow: hidden; }
.hoja { position: relative; z-index: 1; width: 100%; max-width: 520px; background: var(--papel); border: var(--borde); border-radius: var(--radio);
  box-shadow: 0 30px 60px -30px rgba(59, 48, 42, .35); }
.hoja-titulo { font-family: var(--titulo); font-weight: 600; font-size: clamp(40px, 9vw, 60px); letter-spacing: .08em; text-transform: uppercase;
  color: var(--cafe); text-align: center; padding: 26px 16px 18px; border-bottom: var(--borde); line-height: 1; }
.hoja-cuerpo { padding: 26px 30px 28px; display: grid; gap: 20px; }
.hoja-datos { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--mut); }
.hoja-datos .etiqueta { margin-bottom: 4px; }
.hoja-meta { display: grid; gap: 4px; font-size: 12.5px; }
.hoja-meta div { display: flex; justify-content: space-between; gap: 18px; }
.hoja-meta dt { font-family: var(--titulo); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: 11px; color: var(--cafe); }
.hoja-meta dd { font-variant-numeric: tabular-nums; }
.hoja-pie { border-top: var(--borde); padding: 14px 20px; text-align: center; font-size: 12.5px; color: var(--mut); }
.hoja-pie .etiqueta { font-size: 11px; margin-right: 4px; }

.ecualizador { display: flex; align-items: flex-end; gap: 4px; height: 46px; padding: 0 2px; border-bottom: 1px solid var(--arena); }
.ecualizador i { flex: 1; height: 20%; background: var(--arena); border-radius: 3px 3px 0 0; animation: subir 1.8s ease-in-out infinite; }
.ecualizador i:nth-child(3n) { animation-duration: 2.1s; background: var(--taupe); }
.ecualizador i:nth-child(4n) { animation-duration: 1.4s; }
.ecualizador i:nth-child(5n) { animation-duration: 2.5s; background: var(--cafe-2); }
.ecualizador i:nth-child(odd) { animation-delay: -.7s; }
.ecualizador i:nth-child(7n) { animation-delay: -1.2s; }
@keyframes subir { 0%, 100% { height: 18%; } 50% { height: 100%; } }

.btn-login { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 15px 20px; border-radius: 12px;
  border: var(--borde); background: var(--cafe); color: var(--sobre-cafe); cursor: pointer;
  font-family: var(--titulo); font-weight: 600; font-size: 15px; letter-spacing: .05em; }
.btn-login span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-login svg { flex: none; background: #fff; padding: 2px; border-radius: 3px; }
.btn-login:hover:not(:disabled) { background: var(--cafe-2); border-color: var(--cafe-2); }
.btn-login:disabled { opacity: .55; cursor: wait; }
#btn-otra-cuenta { justify-self: center; }

/* =============================================================================
   APP
   ============================================================================= */
#app { position: relative; min-height: 100vh; overflow-x: hidden; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--fondo) 88%, transparent); backdrop-filter: blur(10px); border-bottom: var(--borde); }
.logo { font-family: var(--titulo); font-weight: 600; font-size: 22px; letter-spacing: .1em; text-transform: uppercase; color: var(--cafe); }
.tabs { display: flex; border: var(--borde); border-radius: 10px; overflow: hidden; }
.tab { border: 0; background: transparent; padding: 7px 20px; cursor: pointer; color: var(--cafe);
  font-family: var(--titulo); font-weight: 600; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.tab + .tab { border-left: var(--borde); }
.tab[aria-selected="true"] { background: var(--cafe); color: var(--sobre-cafe); }
.usuario { display: flex; align-items: center; gap: 14px; }
.reloj { font-family: var(--titulo); font-size: 15px; color: var(--cafe); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--arena); color: var(--cafe);
  font-family: var(--titulo); font-weight: 600; font-size: 14px; border: var(--borde); }

.wrap { position: relative; z-index: 1; max-width: 1380px; margin: 0 auto; padding: 32px 28px 48px; }
.vista { display: grid; gap: 26px; }
.pie-vista { color: var(--mut); font-size: 12.5px; text-align: center; font-style: italic; }
.pie-vista:empty { display: none; }
.actualizado.viejo { color: var(--warn); }

/* ---------- EN VIVO ---------- */
.resumen { font-family: var(--titulo); font-size: clamp(20px, 2.6vw, 28px); font-weight: 400; color: var(--mut); letter-spacing: .01em; }
.resumen b { color: var(--cafe); font-weight: 600; }
.resumen .sep { margin: 0 .5em; color: var(--mut-2); }
.resumen-alerta { color: var(--warn); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 22px; align-items: start; }
.tile { background: var(--papel); border: var(--borde); border-radius: var(--radio); overflow: hidden; display: grid; align-content: start;
  box-shadow: 0 18px 40px -28px rgba(59, 48, 42, .45); }
.tile-off { opacity: .62; }
.tile-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: var(--borde); }
.tile-cab h2 { font-family: var(--titulo); font-weight: 600; font-size: 17px; letter-spacing: .1em; text-transform: uppercase; color: var(--cafe); }
.estado { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 3px 10px; border-radius: 999px;
  background: var(--crema); color: var(--mut); font-variant-numeric: tabular-nums; }
.tile-ok .estado { background: var(--ok-suave); color: var(--ok); }
.tile-warn .estado { background: var(--warn-suave); color: var(--warn); }
.tile-bad .estado { background: var(--bad-suave); color: var(--bad); }

.ring { position: relative; width: min(78%, 220px); aspect-ratio: 1; margin: 22px auto 8px; }
.anillo { width: 100%; height: 100%; display: block; }
.anillo circle { fill: none; stroke-width: 9; }
.anillo-fondo { stroke: var(--crema); }
.anillo-vacio { stroke: var(--arena); stroke-dasharray: 1 11; stroke-linecap: round; stroke-width: 6; }
.anillo-valor { stroke: var(--cafe); stroke-linecap: round; }
.tile-ok .anillo-valor { stroke: var(--cafe); }
.tile-warn .anillo-valor { stroke: var(--warn); }
.tile-bad .anillo-valor { stroke: var(--bad); }
.tile-off .anillo-valor { stroke: var(--off); }
.ring-centro { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0; }
.ring-num { font-family: var(--titulo); font-size: clamp(42px, 4.6vw, 54px); font-weight: 500; line-height: 1; color: var(--tinta); font-variant-numeric: tabular-nums; }
.ring-sub { color: var(--mut); font-size: 13px; font-style: italic; margin-top: 4px; }
.ring-pct { margin-top: 8px; justify-self: center; font-family: var(--titulo); font-weight: 600; font-size: 13px; letter-spacing: .06em;
  padding: 1px 10px; border-radius: 6px; background: var(--cafe); color: var(--sobre-cafe); }
.tile-warn .ring-pct, .tile-bad .ring-pct, .tile-off .ring-pct { background: var(--arena); color: var(--cafe); }

.tile-prod { text-align: center; display: grid; gap: 3px; padding: 4px 22px 18px; min-width: 0; }
.prod { font-family: var(--titulo); font-weight: 500; font-size: 16px; letter-spacing: .02em; line-height: 1.3; color: var(--tinta);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile-prod .sub { font-size: 13px; font-style: italic; }
/* ficha del lote (como el encabezado de la factura) */
.ficha { margin: 0 18px 14px; border: 1.5px solid var(--cafe); border-radius: 8px; overflow: hidden; }
.ficha-fila { display: grid; grid-template-columns: 74px 1fr; align-items: center; }
.ficha-fila + .ficha-fila { border-top: 1px solid var(--arena); }
.ficha dt { align-self: stretch; display: flex; align-items: center; padding: 6px 10px; background: var(--cafe); color: var(--sobre-cafe);
  font-family: var(--titulo); font-weight: 600; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; }
.ficha-fila + .ficha-fila dt { border-top: 1px solid color-mix(in srgb, var(--sobre-cafe) 22%, transparent); margin-top: -1px; }
.ficha dd { margin: 0; padding: 6px 12px; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ficha .ficha-pendiente { color: var(--mut); font-style: italic; font-size: 13px; }
.chip-fuente { display: inline-block; font-family: var(--titulo); font-weight: 600; font-size: 11px; letter-spacing: .04em;
  padding: 2px 9px; border-radius: 6px; background: var(--ok-suave); color: var(--ok); }
.chip-calidad { background: var(--warn-suave); color: var(--warn); }

/* franja de validación */
.franja { margin: 0 18px 14px; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; text-align: center; }
.franja-ok { background: var(--ok-suave); color: var(--ok); }
.franja-mal { background: var(--bad-suave); color: var(--bad); }

/* control de peso */
.peso { margin: 0 18px 14px; border: 1.5px dashed var(--arena); border-radius: 10px; padding: 10px 12px; background: var(--fondo); }
.peso-titulo { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--titulo); font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--cafe); }
.peso-titulo span { font-family: var(--texto); font-weight: 400; font-size: 12px; letter-spacing: 0; text-transform: none; font-style: italic; color: var(--mut); }
.peso-datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.peso-dato { display: grid; gap: 1px; }
.peso-dato span { font-size: 11px; color: var(--mut); }
.peso-dato b { font-family: var(--titulo); font-weight: 500; font-size: 19px; color: var(--tinta); font-variant-numeric: tabular-nums; }
.peso-ok b { color: var(--ok); }
.peso-bajo b { color: var(--bad); }
.peso-alto b { color: var(--warn); }
.tile-prod { padding-bottom: 12px; }

/* fuente del producto/lote y validación con calidad */
.fuente { justify-self: center; margin-top: 4px; font-family: var(--titulo); font-weight: 600; font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; padding: 2px 9px; border-radius: 6px; background: var(--crema); color: var(--mut); }
.fuente-calidad { background: var(--warn-suave); color: var(--warn); }
.cal { margin: 4px 0 0; font-size: 12.5px; color: var(--mut); }
.cal:empty { display: none; }
.cal-ok { color: var(--ok); }
.cal-mal { color: var(--bad); font-weight: 600; background: var(--bad-suave); border-radius: 8px; padding: 6px 10px; }

/* tabla de 3 datos, como el encabezado de una factura */
.tile-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 18px; border: 1.5px solid var(--cafe); border-radius: 8px; overflow: hidden; }
.tile-stats div { display: grid; grid-template-rows: auto 1fr; text-align: center; }
.tile-stats div + div { border-left: 1.5px solid var(--cafe); }
.tile-stats dt { background: var(--cafe); color: var(--sobre-cafe); font-family: var(--titulo); font-weight: 600; font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; padding: 5px 4px; }
.tile-stats dd { padding: 8px 4px; font-size: 15px; font-variant-numeric: tabular-nums; align-self: center; }

.pulso { display: block; width: 100%; height: 42px; margin-top: 16px; }
.pulso-area { fill: var(--crema); }
.pulso-linea { fill: none; stroke: var(--taupe); stroke-width: 1.5; stroke-linejoin: round; }
.tile-ok .pulso-area { fill: var(--arena); }
.tile-ok .pulso-linea { stroke: var(--cafe-2); }

/* ---------- tarjeta clicable ---------- */
/* sin desplazamiento al pasar el mouse (la tarjeta no "salta" mientras se lee): solo sombra y pie */
.tile { cursor: pointer; transition: box-shadow .18s ease; }
.tile:hover { box-shadow: 0 22px 44px -24px rgba(59, 48, 42, .55); }
.tile:focus-visible { outline: 3px solid var(--cafe); outline-offset: 3px; }
.tile-ver { display: block; text-align: center; padding: 9px; border-top: 1.5px solid var(--arena); font-family: var(--titulo); font-weight: 600;
  font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--cafe-2); }
.tile:hover .tile-ver { background: var(--cafe); color: var(--sobre-cafe); border-top-color: var(--cafe); }

/* ---------- DESGLOSE DE UNA LÍNEA (ventana) ---------- */
/* (.detalle.desglose para ganarle a las reglas de .detalle; display solo con [open] o la ventana cerrada se vería) */
.detalle.desglose { width: min(900px, calc(100vw - 24px)); padding: 0; }
.detalle.desglose[open] .graficas-cuerpo { padding-bottom: 22px; }
.detalle.desglose[open] { display: grid; gap: 16px; }
.desglose > :not(.desglose-cab) { margin: 0 24px; }
/* color de acento por área (se aplica con data-area en la ventana) */
.desglose { --area: var(--cafe); --area-suave: var(--crema); }
.desglose[data-area="costos"]    { --area: #a8742d; --area-suave: #f3e5cf; }
.desglose[data-area="calidad"]   { --area: #5f7448; --area-suave: #e3e6d6; }
.desglose[data-area="historial"] { --area: #8a7868; --area-suave: #ece5dc; }

.desglose-cab { display: grid; gap: 14px; padding: 18px 24px 0; border-bottom: var(--borde);
  position: sticky; top: 0; background: var(--papel); z-index: 1; }
.desglose-cab-fila { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* 4 cifras clave siempre visibles */
.hero { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--cafe); border-radius: 10px; overflow: hidden; }
.hero-dato { display: grid; gap: 1px; padding: 9px 14px; border-left: 4px solid var(--taupe); background: var(--fondo); }
.hero-dato + .hero-dato { border-left: 4px solid var(--taupe); box-shadow: -1.5px 0 0 var(--arena); }
.hero-dato span { font-family: var(--titulo); font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--mut); }
.hero-dato b { font-family: var(--titulo); font-weight: 500; font-size: 20px; color: var(--tinta); font-variant-numeric: tabular-nums; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-dato small { font-size: 11.5px; color: var(--mut); font-style: italic; }
.hero-ok { border-left-color: var(--ok) !important; } .hero-ok b { color: var(--ok); }
.hero-warn { border-left-color: var(--warn) !important; } .hero-warn b { color: var(--warn); }
.hero-bad { border-left-color: var(--bad) !important; } .hero-bad b { color: var(--bad); }

/* pestañas de área */
.areas { display: flex; gap: 2px; margin-bottom: -1.5px; overflow-x: auto; }
.areas button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border: 1.5px solid transparent; border-bottom: 0;
  border-radius: 10px 10px 0 0; background: transparent; cursor: pointer; color: var(--mut); white-space: nowrap;
  font-family: var(--titulo); font-weight: 600; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; }
.areas button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.areas button:hover { color: var(--cafe); background: var(--fondo); }
.areas button[aria-selected="true"] { color: var(--area); background: var(--area-suave); border-color: var(--cafe); border-bottom: 1.5px solid var(--area-suave); }

/* cuerpo de cada área */
.bloque-area { display: grid; gap: 8px; margin: 0; padding: 14px 16px 12px; border: 1.5px solid var(--arena); border-radius: 12px; background: var(--papel); }
.titulo-bloque { margin: 0; display: flex; align-items: center; gap: 8px; font-family: var(--titulo); font-weight: 600; font-size: 12px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--area); }
.titulo-bloque::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--area); }
.desglose .graficas-cuerpo { background: var(--area-suave); margin: 0 !important; padding: 18px 24px 4px; gap: 14px; }
.vacio-area { padding: 40px 20px; text-align: center; color: var(--mut); font-style: italic; border: 1.5px dashed var(--arena); border-radius: 12px; background: var(--papel); }
.segmentos-chicos { justify-self: start; }
.segmentos-chicos button { padding: 5px 14px; font-size: 11px; }
.costos-2 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.costos-3 { grid-template-columns: repeat(3, 1fr); }
.ficha-ancha { margin: 0; }
.ficha-ancha .ficha-fila { grid-template-columns: 88px 1fr; }
.franja-grande { margin: 0; font-size: 13.5px; padding: 10px 14px; border: 1.5px solid currentColor; }
.franja-grande.franja-ok { background: var(--papel); }
.lm-pok { background: var(--ok); }
.franja-info { background: var(--papel); color: var(--mut); border: 1.5px dashed var(--arena); font-weight: 500; }

/* reparto del tiempo (barra horizontal) */
.reparto { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--crema); }
.reparto i { display: block; height: 100%; }
.reparto-prod { background: var(--cafe-2); }
.reparto-parada { background: var(--bad); }
.reparto-leyenda { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--mut); }
.reparto-leyenda i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* barras lentas y gráfico de pesos */
.graf .barra.b-lento { fill: var(--warn); }
.lm-lento { background: var(--warn); }
.lm-objetivo { background: transparent; border-top: 2px dashed var(--ok); height: 0 !important; border-radius: 0 !important; }
.graf-pesos .palito { stroke-width: 2; }
.graf-pesos .punto { stroke: var(--papel); stroke-width: 2; }
.graf-pesos .p-ok { stroke: var(--ok); fill: var(--ok); }
.graf-pesos .p-alto { stroke: var(--warn); fill: var(--warn); }
.graf-pesos .p-bajo { stroke: var(--bad); fill: var(--bad); }
.graf-pesos .palito.p-ok, .graf-pesos .palito.p-alto, .graf-pesos .palito.p-bajo { fill: none; }
.graf-pesos .punto.p-ok, .graf-pesos .punto.p-alto, .graf-pesos .punto.p-bajo { stroke: var(--papel); }
@media (max-width: 640px) {
  .hero { grid-template-columns: repeat(2, 1fr); }
  .costos-3 { grid-template-columns: 1fr; }
}
.desglose .desglose-titulo { font-family: var(--titulo); font-weight: 600; font-size: 26px; letter-spacing: .1em; text-transform: uppercase; color: var(--cafe); margin: 0; }
.cerrar { flex: none; width: 36px; height: 36px; border-radius: 50%; border: var(--borde); background: transparent; color: var(--cafe); cursor: pointer; font-size: 15px; }
.cerrar:hover { background: var(--cafe); color: var(--sobre-cafe); }
.desglose .segmentos { justify-self: start; }
.graf-fig { display: grid; gap: 6px; margin: 0; }
.graf-fig .etiqueta, .desglose > .etiqueta { font-size: 11px; }
.tabla-compacta td, .tabla-compacta th { padding: 8px 12px; font-size: 13px; }
.tabla-compacta tbody tr { cursor: default; }

.segmentos { display: flex; border: var(--borde); border-radius: 10px; overflow: hidden; }
.segmentos button { border: 0; background: transparent; padding: 6px 16px; cursor: pointer; color: var(--cafe);
  font-family: var(--titulo); font-weight: 600; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.segmentos button + button { border-left: var(--borde); }
.segmentos button[aria-selected="true"] { background: var(--cafe); color: var(--sobre-cafe); }
.graficas-cuerpo { display: grid; gap: 18px; }

.graf-datos { display: flex; flex-wrap: wrap; border: 1.5px solid var(--cafe); border-radius: 8px; overflow: hidden; }
.graf-datos div { flex: 1 1 140px; display: grid; }
.graf-datos div + div { border-left: 1.5px solid var(--cafe); }
.graf-datos dt { background: var(--cafe); color: var(--sobre-cafe); font-family: var(--titulo); font-weight: 600; font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; padding: 4px 10px; }
.graf-datos dd { padding: 7px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }

/* costos y fabricación */
.costos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.costo { display: grid; gap: 2px; align-content: start; padding: 12px 14px; border: 1.5px solid var(--arena); border-top: 4px solid var(--taupe);
  border-radius: 10px; background: var(--papel); }
.costo .etiqueta { font-size: 10px; }
.costo-valor { font-family: var(--titulo); font-weight: 500; font-size: 26px; line-height: 1.15; color: var(--tinta); font-variant-numeric: tabular-nums; }
.costo-valor small { font-size: 13px; font-weight: 600; color: var(--mut); }
.costo-nota { font-size: 11.5px; color: var(--mut); font-style: italic; line-height: 1.35; }
.costo-destacado { background: var(--cafe); border-color: var(--cafe); }
.costo-destacado .etiqueta, .costo-destacado .costo-valor, .costo-destacado .costo-valor small, .costo-destacado .costo-nota { color: var(--sobre-cafe); }
.costo-ok { border-top-color: var(--ok); } .costo-ok .costo-valor { color: var(--ok); }
.costo-warn { border-top-color: var(--warn); } .costo-warn .costo-valor { color: var(--warn); }
.costo-bad { border-top-color: var(--bad); } .costo-bad .costo-valor { color: var(--bad); }

/* cifras grandes del desglose */
.cifras-desglose { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.cifra { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border: 1.5px solid var(--arena);
  border-left: 5px solid var(--cafe); border-radius: 12px; background: var(--fondo); min-width: 0; }
.cifra-ok { border-left-color: var(--ok); } .cifra-warn { border-left-color: var(--warn); } .cifra-bad { border-left-color: var(--bad); }
.cifra-txt { display: grid; gap: 2px; min-width: 0; }
.cifra-txt .etiqueta { font-size: 10.5px; }
.cifra-valor { font-family: var(--titulo); font-weight: 500; font-size: 30px; line-height: 1.1; color: var(--tinta); font-variant-numeric: tabular-nums; }
.cifra-nota { display: grid; gap: 5px; font-size: 12.5px; color: var(--mut); font-style: italic; }
.tend { font-style: normal; font-family: var(--titulo); font-weight: 600; font-size: 12px; letter-spacing: .02em; }
.tend-sube { color: var(--ok); } .tend-baja { color: var(--bad); } .tend-igual { color: var(--mut); }
.mini-progreso { display: block; height: 5px; border-radius: 5px; background: var(--arena); overflow: hidden; }
.mini-progreso i { display: block; height: 100%; background: var(--cafe); border-radius: 5px; }
.dona { width: 46px; height: 46px; flex: none; }
.dona circle { fill: none; stroke-width: 5; }
.dona-fondo { stroke: var(--arena); }
.dona-valor { stroke: var(--cafe); stroke-linecap: round; }
.cifra-ok .dona-valor { stroke: var(--ok); } .cifra-warn .dona-valor { stroke: var(--warn); } .cifra-bad .dona-valor { stroke: var(--bad); }

/* línea de tiempo y leyendas */
.lt-prod { fill: var(--cafe-2); }
.lt-parada { fill: var(--bad); }
.lt-encurso { fill: var(--bad); animation: parpadeo 1.6s infinite; }
.leyenda-mini { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--mut); font-style: italic; margin: 0; }
.leyenda-mini i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -8px; vertical-align: middle; }
.lm-prod { background: var(--cafe-2); } .lm-parada { background: var(--bad); }
.lm-alto { background: var(--cafe); } .lm-bajo { background: var(--arena); } .lm-cero { background: var(--bad); } .lm-actual { background: var(--warn); }
.lm-marca { background: var(--papel); border: 2.5px solid var(--cafe); border-radius: 50% !important; }
.nota-graf { margin: 0; font-size: 13px; color: var(--cafe); font-style: italic; }

/* barras por tramo coloreadas contra el promedio */
.graf .barra.b-alto { fill: var(--cafe); }
.graf .barra.b-bajo { fill: var(--arena); }
.graf .barra.b-cero { fill: var(--bad); }
.graf .barra.b-actual { fill: var(--warn); }

/* paradas más largas + datos */
.desglose-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; align-items: start; }
.desglose-cols > section { align-content: start; }
.top-paradas { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.top-paradas li { display: grid; grid-template-columns: 118px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.tp-hora { color: var(--mut); font-variant-numeric: tabular-nums; }
.tp-barra { height: 10px; border-radius: 5px; background: var(--crema); overflow: hidden; }
.tp-barra i { display: block; height: 100%; background: var(--bad); border-radius: 5px; opacity: .8; }
.top-paradas b { font-family: var(--titulo); font-weight: 600; color: var(--bad); font-variant-numeric: tabular-nums; }
.tp-encurso .tp-hora::after { content: " · en curso"; color: var(--bad); font-style: italic; }
.lista-datos { margin: 0; display: grid; border: 1.5px solid var(--arena); border-radius: 10px; overflow: hidden; }
.lista-datos div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; font-size: 13px; }
.lista-datos div:nth-child(odd) { background: var(--fondo); }
.lista-datos dt { color: var(--mut); }
.lista-datos dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* curva de avance */
.graf .guia { stroke: var(--crema); stroke-width: 1; }
.graf .grad-ini { stop-color: var(--taupe); stop-opacity: .55; }
.graf .grad-fin { stop-color: var(--arena); stop-opacity: .05; }
.graf .ahora { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 3 3; }
.graf .gahora { font: italic 11px "Lora", Georgia, serif; fill: var(--warn); }
.avance-area { stroke: none; }
.avance-linea { fill: none; stroke: var(--cafe); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.graf .plan { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 6 5; }
.graf .gplan { font: 600 11.5px "Fredoka", system-ui, sans-serif; fill: var(--ok); }
.graf .proyeccion { fill: none; stroke: var(--cafe-2); stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; }
.graf .punto-fin { fill: var(--papel); stroke: var(--ok); stroke-width: 2; }
.graf .punto-ahora { fill: var(--cafe); stroke: var(--papel); stroke-width: 2.5; }
.graf .fuera-turno { fill: var(--crema); opacity: .8; }
.graf .gft { font: italic 11px "Lora", Georgia, serif; fill: var(--mut-2); }

/* colores por línea (paleta tierra) */
.serie-0 { --c: #5c4a3e; } .serie-1 { --c: #b3a291; } .serie-2 { --c: #6b7d52; }
.serie-3 { --c: #c08636; } .serie-4 { --c: #b4533c; } .serie-5 { --c: #8a7a9a; }
.graf.graf-apiladas .barra, .graf.graf-apiladas .barra:hover { fill: var(--c); }   /* gana a .graf .barra */
.graf.graf-apiladas .barra:hover { opacity: .8; }
.marca .marca-linea { stroke: var(--c); stroke-width: 1.5; stroke-dasharray: 2 4; }
.marca .marca-punto { fill: var(--papel); stroke: var(--c); stroke-width: 2.5; }
.graf .gm { font: italic 11px "Lora", Georgia, serif; fill: var(--cafe); }
.leyenda { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-serie { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--arena); background: var(--fondo); font-size: 13px; color: var(--tinta); }
.chip-serie i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.chip-serie b { font-family: var(--titulo); font-weight: 600; color: var(--cafe); }
.chip-serie[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }

/* ---------- HISTÓRICO ---------- */
.filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 18px 20px; background: var(--papel); border: var(--borde); border-radius: var(--radio); }
.filtros label { display: grid; gap: 5px; }
.filtros label span { font-family: var(--titulo); font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--cafe); }
.filtros input, .filtros select { height: 40px; padding: 0 12px; border: 1.5px solid var(--arena); border-radius: 10px; background: var(--fondo); min-width: 0; }
.filtros input:focus, .filtros select:focus { border-color: var(--cafe); outline: none; }
.filtros .crece { flex: 1 1 200px; }
.filtros .btn { height: 40px; }

/* cifras como el cuadro de totales de la factura */
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); background: var(--papel); border: var(--borde); border-radius: var(--radio); overflow: hidden; }
.cifras .kpi { padding: 18px 22px; display: grid; gap: 2px; }
.cifras .kpi + .kpi { border-left: 1.5px solid var(--arena); }
.cifras .lbl { font-family: var(--titulo); font-weight: 600; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--cafe); }
.kpi-valor { font-family: var(--titulo); font-size: clamp(30px, 3.4vw, 40px); font-weight: 500; line-height: 1.15; color: var(--tinta); font-variant-numeric: tabular-nums; }
.kpi .nota { color: var(--mut); font-size: 12.5px; font-style: italic; }
.kpi-ok .kpi-valor { color: var(--ok); }
.kpi-warn .kpi-valor { color: var(--warn); }

.bloque { display: grid; gap: 12px; background: var(--papel); border: var(--borde); border-radius: var(--radio); padding: 18px 20px; }
.graf { width: 100%; height: auto; display: block; overflow: visible; }
.graf .eje { stroke: var(--cafe); stroke-width: 1.5; }
.graf .barra { fill: var(--arena); }
.graf .barra:hover, .graf .barra-on { fill: var(--cafe-2); }
.graf .ref { stroke: var(--cafe); stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; }
.graf .gv { font: 600 11px "Fredoka", system-ui, sans-serif; fill: var(--cafe); }
.graf .ge { font: italic 11px "Lora", Georgia, serif; fill: var(--mut); }
.graf .gr { font: 600 11px "Fredoka", system-ui, sans-serif; fill: var(--cafe); }

/* tabla con encabezado café, como la de la factura */
.tabla-scroll { overflow-x: auto; border: 1.5px solid var(--cafe); border-radius: 10px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { background: var(--cafe); color: var(--sobre-cafe); font-family: var(--titulo); font-weight: 600; font-size: 11.5px; letter-spacing: .12em;
  text-transform: uppercase; padding: 10px 14px; text-align: left; cursor: pointer; user-select: none; white-space: nowrap; }
.tabla th + th { border-left: 1px solid color-mix(in srgb, var(--sobre-cafe) 25%, transparent); }
.tabla td { padding: 12px 14px; border-top: 1px solid var(--arena); vertical-align: middle; }
.tabla td + td { border-left: 1px solid var(--arena); }
.tabla th[aria-sort="ascending"]::after { content: " ↑"; }
.tabla th[aria-sort="descending"]::after { content: " ↓"; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla tbody tr { cursor: pointer; transition: background .15s ease; }
.tabla tbody tr:hover, .tabla tbody tr:focus-visible { background: var(--crema); }
.tabla .fila-viva { background: color-mix(in srgb, var(--ok-suave) 60%, transparent); }
.col-linea { white-space: nowrap; font-family: var(--titulo); font-weight: 600; letter-spacing: .04em; color: var(--cafe); }
.col-linea .dot { margin-right: 8px; vertical-align: middle; }
.col-producto { max-width: 420px; }
.prod-celda { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabla td.num .sub { display: inline; }
.cumpl { display: inline-grid; gap: 4px; justify-items: end; font-weight: 600; }
.mini-barra { display: block; width: 64px; height: 4px; border-radius: 4px; background: var(--crema); overflow: hidden; }
.mini-barra i { display: block; height: 100%; background: currentColor; }
.tono-ok { color: var(--ok); }
.tono-warn { color: var(--warn); }
.tono-bad { color: var(--bad); }
.vacio { color: var(--mut); text-align: center; padding: 32px; font-style: italic; }

/* ---------- ACCESOS (solo administradores) ---------- */
.filtros-plano { padding: 0; border: 0; background: none; }
.aviso-ok { color: var(--ok); background: var(--ok-suave); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.fila-inactiva td { color: var(--mut); }
.fila-csv td { background: var(--warn-suave); }
/* marca de agua de quién consulta (histórico y detalle de orden) */
.marca-agua { margin: 4px 0 0; text-align: center; font-size: 11.5px; letter-spacing: .04em; color: var(--mut-2); font-style: italic;
  user-select: none; }
.marca-agua:empty { display: none; }
@media print { .marca-agua { color: #555; font-size: 10px; } }
#vista-accesos .tabla tbody tr { cursor: default; }

/* ---------- detalle ---------- */
.detalle { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: var(--borde); border-radius: var(--radio);
  background: var(--papel); color: var(--tinta); padding: 26px 28px; }
.detalle::backdrop { background: rgba(59, 48, 42, .45); backdrop-filter: blur(2px); }
.detalle .lbl { font-family: var(--titulo); font-weight: 600; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--cafe); }
.detalle h2 { font-family: var(--titulo); font-weight: 500; font-size: 24px; margin: 6px 0 4px; color: var(--tinta); overflow-wrap: anywhere; }
.detalle .meta { color: var(--mut); font-size: 13.5px; font-style: italic; }
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--arena); border: 1.5px solid var(--cafe);
  border-radius: 10px; overflow: hidden; margin-top: 18px; }
.dato { background: var(--papel); padding: 10px 14px; display: grid; gap: 2px; }
.dato .lbl { font-size: 10px; }
.dato b { font-family: var(--titulo); font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.espacio { margin-top: 20px; margin-bottom: 8px; }
/* detalle de una orden: datos agrupados (Avance · Tiempo · Ritmo) con explicación corta */
.det-seccion { margin-top: 20px; }
.det-seccion > .lbl { display: flex; align-items: center; gap: 8px; }
.det-seccion > .lbl::before { content: ""; width: 4px; height: 13px; border-radius: 2px; background: var(--cafe); }
.det-seccion .datos { margin-top: 8px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.dato small { font-size: 11.5px; line-height: 1.35; color: var(--mut); font-style: italic; }
.dato-ok b { color: var(--ok); } .dato-warn b { color: var(--warn); } .dato-bad b { color: var(--bad); }
.det-nota { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  padding: 8px 12px; border: 1.5px dashed var(--arena); border-radius: 10px; font-size: 12.5px; color: var(--mut); font-style: italic; }
.det-nota .btn { padding: 6px 14px; font-size: 11.5px; font-style: normal; }
.nota { color: var(--mut); font-size: 13px; }
.detalle-pie { display: flex; justify-content: flex-end; margin-top: 20px; }

/* ---------- celular ---------- */
@media (max-width: 640px) {
  .top { position: static; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; }
  .wrap { padding: 20px 16px 40px; }
  .cifras .kpi + .kpi { border-left: 0; border-top: 1.5px solid var(--arena); }
  .hoja-cuerpo { padding: 22px 20px; }
  .decor-login-a { width: 360px; } .decor-login-b { width: 380px; }
}
@media (prefers-reduced-motion: reduce) {
  .dot-ok, .dot-bad, .ecualizador i { animation: none; }
  .ecualizador i { height: 60%; }
  .tabla tbody tr { transition: none; }
}
