/* Piezas comunes de todos los departamentos. Una sola forma de hacer cada cosa. */

/* ───────── Iconos de trazo fino: se redibujan al pasar por encima ───────── */
.icono { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; overflow: visible; }
.icono path, .icono circle, .icono rect, .icono line, .icono polyline { vector-effect: non-scaling-stroke; }
@keyframes trazo { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@media (hover: hover) {
  .redibuja:hover .icono path, .redibuja:hover .icono circle { stroke-dasharray: 1; animation: trazo .75s var(--tejer) both; }
}
.glifo { width: 10px; height: 10px; flex: none; fill: currentColor; }
.glifo .hueco { fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ───────── Encabezado de cada vista ───────── */
.vista { display: flex; flex-direction: column; gap: clamp(16px, 2vw, 24px); animation: aparece-suave .4s linear both; }
.cabecera {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding-top: 6px;
}
.cabecera__texto { min-width: 0; max-width: 760px; }
.cabecera__ante { display: flex; align-items: center; gap: 8px; color: var(--oro-texto); font-size: var(--t-xs); letter-spacing: .16em; text-transform: uppercase; font-weight: 650; margin-bottom: 8px; }
.cabecera__ante .icono { width: 16px; height: 16px; }
.cabecera h2 { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -.025em; }
.cabecera p { color: var(--tinta-2); margin-top: 6px; max-width: 640px; }
.cabecera__acciones { display: flex; gap: 8px; flex-wrap: wrap; }
/* En el móvil, los botones de la cabecera llenan su fila: filas parejas, sin huecos sueltos */
@media (max-width: 640px) { .cabecera__acciones > .boton { flex: 1 1 auto; } }

/* ───────── Paneles ───────── */
.panel {
  position: relative; border-radius: var(--r-l); padding: clamp(16px, 1.6vw, 22px);
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b)); border: 1px solid var(--linea);
  box-shadow: var(--panel-sombra), inset 0 1px 0 var(--panel-luz);
  min-width: 0;
}
.panel--filo { border-color: transparent; }
.panel--filo::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: var(--filo); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.panel--plano { background: none; box-shadow: none; }
.panel--clic { cursor: pointer; transition: transform var(--media) var(--suave), border-color var(--rapida) linear, box-shadow var(--media) var(--suave); }
.panel--clic:hover { transform: translateY(-2px); border-color: var(--linea-2); }
.panel__cabeza { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 12px; margin-bottom: 14px; }
/* Si los botones del panel no caben junto al título (en el móvil), bajan a su línea: el título nunca se estrecha a una
   palabra por línea */
.panel__cabeza > .crece { flex: 1 1 240px; }
.panel__cabeza > .fila { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.panel__titulo { font-size: var(--t-m); font-weight: 600; display: flex; align-items: center; gap: 9px; }
.panel__titulo .icono { width: 18px; height: 18px; color: var(--oro); }
.panel__sub { font-size: var(--t-s); color: var(--tinta-3); margin-top: 2px; }
.panel__pie { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--linea); display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--t-s); color: var(--tinta-3); }

/* ───────── Rejillas ───────── */
.rejilla { display: grid; gap: clamp(12px, 1.4vw, 18px); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c-12 { grid-column: span 12; } .c-8 { grid-column: span 8; } .c-7 { grid-column: span 7; } .c-6 { grid-column: span 6; }
.c-5 { grid-column: span 5; } .c-4 { grid-column: span 4; } .c-3 { grid-column: span 3; }
.rejilla-kpi { display: grid; gap: clamp(12px, 1.4vw, 18px); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
@media (max-width: 1180px) { .c-8, .c-7, .c-6, .c-5, .c-4 { grid-column: span 12; } .c-3 { grid-column: span 6; } }
@media (max-width: 640px) { .c-3 { grid-column: span 12; } .rejilla-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* ───────── Cifras clave ───────── */
.kpi { display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow: hidden; }
.kpi__etiqueta { display: flex; align-items: center; gap: 8px; font-size: var(--t-s); color: var(--tinta-2); }
.kpi__etiqueta .icono { width: 16px; height: 16px; color: var(--oro); }
/* El nombre de una cifra, entero: en dos líneas si hace falta, nunca con «…» por unos píxeles */
.kpi__etiqueta .recorta { white-space: normal; text-overflow: clip; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; line-height: 1.25; text-wrap: balance; }
@media (max-width: 640px) { .kpi__etiqueta { align-items: flex-start; min-height: calc(2 * 1.25em); } }
.kpi__valor { font-size: clamp(1.45rem, 1.1rem + 1vw, 2rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.kpi__valor small { font-size: .5em; font-weight: 500; color: var(--tinta-3); letter-spacing: 0; margin-left: 3px; }
.kpi__pie { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: var(--tinta-3); flex-wrap: wrap; }
.kpi__chispa { height: 38px; margin: 2px -4px -6px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.delta .icono { width: 12px; height: 12px; stroke-width: 2.2; }
.delta--sube { color: var(--bien); background: var(--bien-suave); }
.delta--baja { color: var(--mal); background: var(--mal-suave); }
.delta--igual { color: var(--tinta-3); background: var(--fondo-4); }
/* Al pie de una cifra, la comparación va en una línea (en el móvil estrecho, un poco más pequeña) */
.kpi__pie .delta { white-space: nowrap; }
@media (max-width: 400px) { .kpi__pie .delta { font-size: 11px; padding: 2px 5px; } }
.bloqueado { display: inline-flex; align-items: center; gap: 6px; color: var(--tinta-4); font-size: var(--t-s); }
.bloqueado .icono { width: 14px; height: 14px; }

/* ───────── Pastillas de estado (forma + color) ───────── */
.pastilla {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 560; color: var(--tinta-2); background: var(--fondo-4); border: 1px solid transparent;
}
.pastilla--bien { color: var(--bien); background: var(--bien-suave); }
.pastilla--ojo { color: var(--ojo); background: var(--ojo-suave); }
.pastilla--mal { color: var(--mal); background: var(--mal-suave); }
.pastilla--info { color: var(--info); background: var(--info-suave); }
.pastilla--oro { color: var(--oro-texto); background: var(--oro-suave); border-color: var(--oro-borde); }
.pastilla--borde { background: transparent; border-color: var(--linea-2); }
.pastilla--peq { height: 20px; padding: 0 8px; font-size: 11px; }

.etiqueta { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 550; color: var(--tinta-2); background: var(--fondo-4); white-space: nowrap; }

/* ───────── Botones ───────── */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px;
  font-size: var(--t-s); font-weight: 600; white-space: nowrap; border: 1px solid var(--linea-2); color: var(--tinta); background: var(--panel-a);
  transition: transform var(--rapida) var(--suave), background var(--rapida) linear, border-color var(--rapida) linear, box-shadow var(--media) var(--suave), opacity var(--rapida) linear;
}
.boton:hover { border-color: var(--linea-3); }
.boton:active { transform: scale(.97); }
.boton .icono { width: 17px; height: 17px; }
.boton--primario { color: var(--boton-tinta); background: var(--boton); border-color: transparent; box-shadow: var(--sombra); }
.boton--primario:hover { background: var(--boton-2); }
/* El botón «fantasma» ya no se funde con el fondo (pedido de FAAiA el 1/12/2026): lleva el mismo fondo que un botón
   normal y su borde fino; solo su texto es algo más suave */
.boton--fantasma { color: var(--tinta-2); }
.boton--fantasma:hover { color: var(--tinta); }
.boton--peligro { color: var(--mal); border-color: var(--mal-suave); background: var(--mal-suave); }
.boton--oro { color: var(--oro-texto); border-color: var(--oro-borde); background: var(--oro-suave); }
.boton--peq { height: 32px; padding: 0 12px; border-radius: 10px; font-size: var(--t-xs); }
.boton--grande { height: 48px; padding: 0 22px; font-size: var(--t-m); border-radius: 14px; }
.boton--bloque { width: 100%; }
.boton[disabled] { opacity: .45; pointer-events: none; }
.boton.cargando { pointer-events: none; color: transparent !important; position: relative; }
.boton.cargando::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tinta); border-right-color: transparent; animation: gira .7s linear infinite; }
.boton--primario.cargando::after { border-color: var(--boton-tinta); border-right-color: transparent; }

/* ───────── Formularios ───────── */
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > span, .campo__etiqueta { font-size: var(--t-s); color: var(--tinta-2); font-weight: 520; }
.entrada, .selector, .area {
  width: 100%; height: 42px; padding: 0 13px; border-radius: 12px; border: 1px solid var(--linea-2); background: var(--fondo-2);
  font-size: var(--t-m); color: var(--tinta); transition: border-color var(--rapida) linear, box-shadow var(--rapida) linear;
}
:root[data-theme="light"] .entrada, :root[data-theme="light"] .selector, :root[data-theme="light"] .area { background-color: #fff; }
.entrada::placeholder, .area::placeholder { color: var(--tinta-4); }
.entrada:focus, .selector:focus, .area:focus { border-color: var(--oro); box-shadow: 0 0 0 4px var(--oro-suave); outline: none; }
.area { height: auto; min-height: 96px; padding: 11px 13px; resize: vertical; line-height: 1.5; }
.selector { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239D958B' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.entrada--busca { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239D958B' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.9'/%3E%3Cpath d='M20.4 20.4l-4.6-4.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 13px center; }
.formulario { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.formulario .ancho { grid-column: 1 / -1; }
@media (max-width: 640px) { .formulario { grid-template-columns: minmax(0, 1fr); } }

.interruptor { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--t-s); color: var(--tinta-2); }
.interruptor input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interruptor__pista { width: 40px; height: 24px; border-radius: 12px; background: var(--fondo-4); border: 1px solid var(--linea-2); position: relative; transition: background var(--media) var(--suave); flex: none; }
.interruptor__pista::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--tinta-2); transition: transform var(--media) var(--suave), background var(--media) linear; }
.interruptor input:checked + .interruptor__pista { background: var(--oro); border-color: transparent; }
.interruptor input:checked + .interruptor__pista::after { transform: translateX(16px); background: var(--boton-tinta); }
.interruptor input:focus-visible + .interruptor__pista { outline: 2px solid var(--oro); outline-offset: 2px; }

.segmentado { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--fondo-3); border: 1px solid var(--linea); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmentado button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 9px; font-size: var(--t-s); font-weight: 540; color: var(--tinta-3); white-space: nowrap; transition: background var(--rapida) linear, color var(--rapida) linear; }
/* Con icono: a la izquierda del texto, en la misma línea */
.segmentado button .icono { width: 16px; height: 16px; flex: none; }
.segmentado button:hover { color: var(--tinta); }
.segmentado button.activo { background: var(--fondo-2); color: var(--tinta); box-shadow: var(--sombra), inset 0 1px 0 var(--panel-luz); }
:root[data-theme="light"] .segmentado button.activo { background: #fff; box-shadow: var(--sombra); }

.filtros { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filtros .entrada--busca { width: min(320px, 100%); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px; font-size: var(--t-s);
  border: 1px solid var(--linea-2); color: var(--tinta-2); background: none; white-space: nowrap;
}
.chip.activo { color: var(--oro-texto); border-color: var(--oro-borde); background: var(--oro-suave); }
.chip .icono { width: 14px; height: 14px; }

/* ───────── Tablas (en el móvil se convierten en tarjetas) ───────── */
.tabla-caja { overflow-x: auto; margin: 0 -4px; position: relative; }
/* Lo que no cabe y se desliza de lado (tablas, chips, segmentados, pestañas): el borde con más detrás se difumina
   (data-izq, data-der; los pone piezas.js solo si de verdad se desliza) */
[data-desliza][data-izq] { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px); mask-image: linear-gradient(to right, transparent, #000 32px); }
[data-desliza][data-der] { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
[data-desliza][data-izq][data-der] { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
.tabla { font-size: var(--t-s); }
.tabla th { text-align: left; font-weight: 560; color: var(--tinta-3); font-size: 11.5px; letter-spacing: .04em; padding: 9px 12px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 12px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
.tabla tbody tr { transition: background var(--rapida) linear; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr.clic { cursor: pointer; }
.tabla tbody tr.clic:hover { background: var(--panel-a); }
.tabla .num { text-align: right; white-space: nowrap; }
.tabla .acciones { text-align: right; white-space: nowrap; }
@media (max-width: 900px) {
  .tabla--tarjetas thead { display: none; }
  .tabla--tarjetas, .tabla--tarjetas tbody, .tabla--tarjetas tr, .tabla--tarjetas td { display: block; width: 100%; }
  .tabla--tarjetas tr { padding: 12px 4px; border-bottom: 1px solid var(--linea); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 4px 12px; }
  .tabla--tarjetas tbody tr:last-child { border-bottom: 0; }
  .tabla--tarjetas td { border: 0; padding: 0; text-align: left !important; min-width: 0; overflow-wrap: break-word; }
  .tabla--tarjetas td[data-et]::before { content: attr(data-et) " · "; color: var(--tinta-4); font-size: 11px; }
  .tabla--tarjetas td.principal-movil { grid-column: 1; grid-row: 1; font-weight: 560; min-width: 0; }
  .tabla--tarjetas tr:not(:has(.derecha-movil)) td.principal-movil { grid-column: 1 / -1; }
  .tabla--tarjetas td.derecha-movil { text-align: right !important; grid-column: 2; grid-row: 1; }
  .tabla--tarjetas td.derecha-movil::before { display: none; }
  .tabla--tarjetas td.ocultar-movil { display: none; }
  .tabla--tarjetas td.ancha-movil { grid-column: 1 / -1; }
}
/* Con el copiloto o Telegram abiertos al lado, a la tabla le queda poco ancho: sin las columnas que el móvil también quita */
@media (min-width: 1081px) and (max-width: 1760px) { body:is(:has(.cop), :has(.tg)) .tabla .ocultar-movil { display: none; } }

/* ───────── Listas ───────── */
.lista { display: flex; flex-direction: column; }
.lista__fila { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--linea); min-width: 0; }
.lista__fila:last-child { border-bottom: 0; }
.lista__fila.clic { cursor: pointer; border-radius: 12px; margin: 0 -10px; padding: 11px 10px; border-bottom-color: transparent; box-shadow: 0 1px 0 var(--linea); }
.lista__fila.clic:hover { background: var(--panel-a); }
.lista__icono { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--oro-suave); color: var(--oro); flex: none; }
.lista__icono .icono { width: 18px; height: 18px; }
.lista__icono--bien { background: var(--bien-suave); color: var(--bien); }
.lista__icono--ojo { background: var(--ojo-suave); color: var(--ojo); }
.lista__icono--mal { background: var(--mal-suave); color: var(--mal); }
.lista__icono--info { background: var(--info-suave); color: var(--info); }
.lista__texto { min-width: 0; flex: 1 1 auto; }
/* En una lista, el título va entero (si no cabe, en dos líneas) y la línea de debajo, en dos líneas como mucho */
.lista__titulo { font-size: var(--t-s); font-weight: 560; overflow-wrap: break-word; }
.lista__sub { font-size: var(--t-xs); color: var(--tinta-3); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: break-word; }
.lista__fin { flex: none; text-align: right; font-size: var(--t-s); }

/* ───────── Miniaturas, avatares y tejidos ───────── */
/* Fotos de piezas: siempre enteras (contain), mejor más pequeñas que cortadas. El hueco que queda a los lados
   toma el color del fondo de cada foto (js/fotos.js). Telas: al revés, llenan todo su recuadro (cover), porque
   son ornamento y se ven mejor en grande. */
/* max-width: none: el img { max-width: 100% } de base.css dejaba que Safari la estrechara en una fila sin sitio */
.miniatura { width: 44px; height: 54px; max-width: none; border-radius: 9px; object-fit: contain; background: var(--foto-fondo); flex: none; border: 1px solid var(--linea); }
.miniatura--peq { width: 32px; height: 40px; border-radius: 7px; }
.miniatura--grande { width: 72px; height: 90px; border-radius: 12px; }
/* Varias piezas: una al lado de otra, sin montarse (así ninguna foto queda tapada) */
.pila-miniaturas { display: flex; gap: 4px; flex: none; }
/* Casi cuadradas (un poco verticales) y con la pieza llenando el recuadro: se ve mejor que entera y diminuta */
.pila-miniaturas .miniatura { width: 38px; height: 44px; border-radius: 8px; object-fit: cover; object-position: center 42%; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--boton-tinta); background: var(--oro-texto); flex: none; letter-spacing: .02em; }
.avatar--suave { color: var(--oro-texto); background: var(--oro-suave); border: 1px solid var(--oro-borde); }
.avatar--peq { width: 26px; height: 26px; font-size: 10px; }
.tejido { width: 34px; height: 34px; border-radius: 8px; background-color: var(--fondo-4); background-size: cover; background-repeat: no-repeat; background-position: center; border: 1px solid var(--linea-2); flex: none; }
.tejido--grande { width: 56px; height: 56px; border-radius: 12px; }

/* ───────── Pestañas ───────── */
.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--linea); overflow-x: auto; scrollbar-width: none; }
.pestanas button { height: 40px; padding: 0 14px; font-size: var(--t-s); font-weight: 540; color: var(--tinta-3); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.pestanas button:hover { color: var(--tinta); }
.pestanas button.activo { color: var(--tinta); border-bottom-color: var(--oro); }

/* ───────── Barra de tiempo (compras y confecciones) ───────── */
.tiempo { display: flex; flex-direction: column; gap: 7px; }
.tiempo__linea { font-size: var(--t-s); color: var(--tinta-2); }
.tiempo__pista { position: relative; height: 8px; border-radius: 6px; background: var(--fondo-4); overflow: visible; }
.tiempo__relleno { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--bien); transform-origin: left; animation: crece-x 1.1s var(--suave) both; }
.tiempo--ojo .tiempo__relleno { background: var(--ojo); }
.tiempo--mal .tiempo__relleno { background: var(--mal); }
.tiempo__relleno::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent); background-size: 200% 100%; animation: brilla 2.6s linear infinite; opacity: .5; }
.tiempo__hoy { position: absolute; top: -5px; width: 2px; height: 18px; border-radius: 2px; background: var(--tinta); box-shadow: 0 0 0 3px var(--fondo); }
.tiempo__fechas { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--tinta-4); font-variant-numeric: tabular-nums; }
@keyframes crece-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ───────── Fases (pasos de un pedido o una confección) ───────── */
/* Con aire alrededor: el anillo del paso actual no se corta (overflow-x: auto recorta también arriba y abajo) */
.fases { display: flex; align-items: flex-start; gap: 0; width: calc(100% + 24px); margin: -10px -12px -6px; padding: 10px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.fase { flex: 1 1 0; min-width: 74px; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; text-align: center; font-size: 11.5px; color: var(--tinta-3); }
.fase::before { content: ""; position: absolute; top: 13px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 2px; background: var(--linea-2); border-radius: 2px; }
.fase:first-child::before { display: none; }
.fase__punto { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--linea-2); background: var(--fondo-2); position: relative; z-index: 1; }
.fase__punto .icono { width: 14px; height: 14px; stroke-width: 2.2; }
.fase.hecha { color: var(--tinta-2); }
.fase.hecha::before { background: var(--bien); }
.fase.hecha .fase__punto { background: var(--bien); border-color: var(--bien); color: var(--fondo); }
.fase.actual { color: var(--tinta); font-weight: 600; }
.fase.actual::before { background: linear-gradient(90deg, var(--bien), var(--oro)); }
.fase.actual .fase__punto { border-color: var(--oro); box-shadow: 0 0 0 5px var(--oro-suave), 0 0 6px color-mix(in srgb, var(--oro-borde) 40%, transparent); color: var(--oro); }
.fase.actual .fase__punto::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--oro); animation: latido 1.6s ease-in-out infinite; }

/* ───────── Tablero (preparación) ───────── */
.tablero { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.columna { background: var(--panel-b); border: 1px solid var(--linea); border-radius: var(--r-l); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 280px; scroll-snap-align: start; }
.columna__cabeza { display: flex; align-items: center; gap: 8px; font-size: var(--t-s); font-weight: 600; padding: 2px 4px 6px; }
.columna__cabeza .punto { width: 8px; height: 8px; border-radius: 50%; }
.tarjeta-mini { background: var(--panel-solido); border: 1px solid var(--linea); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 9px; cursor: pointer; transition: border-color var(--rapida) linear, transform var(--media) var(--suave); animation: aparece .5s var(--suave) both; }
.tarjeta-mini:hover { border-color: var(--linea-2); transform: translateY(-1px); }
@media (max-width: 900px) { .tablero { grid-template-columns: repeat(4, 84vw); } }

/* ───────── Barras de progreso y anillos ───────── */
.progreso { height: 6px; border-radius: 6px; background: var(--fondo-4); overflow: hidden; }
.progreso > i { display: block; height: 100%; border-radius: inherit; background: var(--oro); transform-origin: left; animation: crece-x 1.2s var(--suave) both; }
.progreso--bien > i { background: var(--bien); } .progreso--ojo > i { background: var(--ojo); } .progreso--mal > i { background: var(--mal); }

/* ───────── Avisos dentro de una vista ───────── */
.nota { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: 14px; font-size: var(--t-s); background: var(--info-suave); color: var(--tinta-2); border: 1px solid transparent; }
.nota .icono { width: 18px; height: 18px; color: var(--info); margin-top: 1px; }
.nota--ojo { background: var(--ojo-suave); } .nota--ojo .icono { color: var(--ojo); }
.nota--mal { background: var(--mal-suave); } .nota--mal .icono { color: var(--mal); }
.nota--bien { background: var(--bien-suave); } .nota--bien .icono { color: var(--bien); }
.nota--oro { background: var(--oro-suave); border-color: var(--oro-borde); } .nota--oro .icono { color: var(--oro); }
.nota strong { color: var(--tinta); font-weight: 600; }
/* Un enlace dentro de una nota parte la línea como el texto: en el móvil, uno largo no se sale */
.nota .enlace { display: inline; white-space: normal; }
.nota .enlace .icono { display: inline-block; width: 15px; height: 15px; vertical-align: -3px; margin-top: 0; color: inherit; }

/* ───────── Vacío ───────── */
.vacio { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 16px; color: var(--tinta-3); }
.vacio .icono { width: 34px; height: 34px; color: var(--oro); }
.vacio strong { color: var(--tinta); font-size: var(--t-m); }

/* ───────── Cronología ───────── */
.crono { display: flex; flex-direction: column; }
.crono__item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; position: relative; padding-bottom: 16px; }
.crono__item:not(:last-child)::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 2px; width: 1px; background: var(--linea-2); }
.crono__punto { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--fondo-3); border: 1px solid var(--linea); color: var(--oro); }
.crono__punto .icono { width: 16px; height: 16px; }
.crono__texto { font-size: var(--t-s); padding-top: 6px; min-width: 0; }
.crono__texto small { display: block; color: var(--tinta-3); font-size: var(--t-xs); }
.crono__hora { font-size: var(--t-xs); color: var(--tinta-4); padding-top: 8px; font-variant-numeric: tabular-nums; }

/* ───────── Ventanas, hojas laterales y avisos flotantes ───────── */
.velo { position: fixed; inset: 0; background: var(--velo); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 80; display: grid; place-items: center; padding: 18px; animation: aparece-suave .25s linear both; }
.ventana {
  --ventana-pad: clamp(20px, 2.4vw, 28px); --ventana-pad-abajo: var(--ventana-pad);
  width: min(560px, 100%); max-height: min(86vh, 860px); overflow: auto; border-radius: var(--r-xl); padding: var(--ventana-pad);
  background: var(--fondo-2); border: 1px solid var(--linea-2); box-shadow: var(--sombra-flota);
  animation: sube-ventana .45s var(--suave) both; overscroll-behavior: contain;
}
.ventana--ancha { width: min(860px, 100%); }
.ventana__cabeza { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ventana__cabeza h3 { font-size: var(--t-xl); }
/* El pie (el total y el botón principal) se queda fijo abajo en las ventanas largas (mejora 33) */
.ventana__pie {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  position: sticky; bottom: calc(-1 * var(--ventana-pad-abajo)); z-index: 3;
  margin: 22px calc(-1 * var(--ventana-pad)) calc(-1 * var(--ventana-pad-abajo)); padding: 12px var(--ventana-pad) var(--ventana-pad-abajo);
  background: var(--fondo-2); border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.ventana--larga .ventana__pie { border-top: 1px solid var(--linea); box-shadow: var(--sombra-arriba); border-radius: 0; }
@keyframes sube-ventana { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .velo { place-items: end stretch; padding: 0; }
  .ventana { --ventana-pad-abajo: calc(22px + env(safe-area-inset-bottom)); width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 26px 26px 0 0; padding-bottom: var(--ventana-pad-abajo); animation: sube-hoja .5s var(--suave) both; }
  .ventana__pie { border-radius: 0; }
  .ventana__pie .boton { flex: 1 1 auto; }
}
@keyframes sube-hoja { from { transform: translateY(100%); } to { transform: none; } }

.hoja { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 70; background: var(--fondo-2); border-left: 1px solid var(--linea-2); box-shadow: var(--sombra-lado-der); display: flex; flex-direction: column; animation: entra-hoja .45s var(--suave) both; }
.hoja__cabeza { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--linea); }
.hoja__cuerpo { flex: 1 1 auto; overflow-y: auto; padding: 8px 20px 20px; }
@keyframes entra-hoja { from { transform: translateX(100%); } to { transform: none; } }

#capa-toast { position: fixed; z-index: 120; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: min(380px, calc(100vw - 36px)); }
.toast {
  pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 16px; font-size: var(--t-s);
  background: var(--fondo-2); border: 1px solid var(--linea-2); box-shadow: var(--sombra-flota);
  animation: entra-toast .5s var(--suave) both;
}
.toast.sale { animation: sale-toast .35s ease-in both; }
.toast__icono { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--oro-suave); color: var(--oro); flex: none; }
.toast__icono .icono { width: 16px; height: 16px; }
.toast--bien .toast__icono { background: var(--bien-suave); color: var(--bien); }
.toast--ojo .toast__icono { background: var(--ojo-suave); color: var(--ojo); }
.toast--mal .toast__icono { background: var(--mal-suave); color: var(--mal); }
.toast strong { display: block; font-weight: 600; }
.toast span { color: var(--tinta-3); }
@keyframes entra-toast { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sale-toast { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 1080px) { #capa-toast { bottom: calc(var(--alto-pie-movil) + env(safe-area-inset-bottom) + 12px); right: 12px; width: calc(100vw - 24px); } }

/* ───────── Menú flotante ───────── */
.menu-flotante {
  position: fixed; z-index: 90; min-width: 240px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; padding: 6px; border-radius: 16px;
  background: var(--fondo-2); border: 1px solid var(--linea-2); box-shadow: var(--sombra-flota);
  animation: aparece .3s var(--suave) both;
}
.menu-flotante__titulo { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--tinta-4); font-weight: 600; padding: 10px 10px 6px; }
.menu-flotante button, .menu-flotante a { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 10px; font-size: var(--t-s); color: var(--tinta-2); }
.menu-flotante button:hover, .menu-flotante a:hover { background: var(--panel-a); color: var(--tinta); }
.menu-flotante .icono { width: 17px; height: 17px; color: var(--oro); }
.menu-flotante small { display: block; font-size: 11.5px; color: var(--tinta-3); }
.menu-flotante .activo { color: var(--tinta); background: var(--oro-suave); }
.menu-flotante hr { border: 0; border-top: 1px solid var(--linea); margin: 6px 4px; }

/* ───────── Código de verificación (acciones delicadas y acceso) ───────── */
.codigo { display: flex; gap: 8px; justify-content: center; }
.codigo input {
  width: 46px; height: 56px; text-align: center; font-size: 22px; font-weight: 600; border-radius: 14px; border: 1px solid var(--linea-2);
  background: var(--fondo-2); font-variant-numeric: tabular-nums;
}
:root[data-theme="light"] .codigo input { background: #fff; }
.codigo input:focus { border-color: var(--oro); box-shadow: 0 0 0 4px var(--oro-suave); }
@media (max-width: 380px) { .codigo input { width: 40px; height: 50px; } }

/* ───────── Leyendas ───────── */
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--t-xs); color: var(--tinta-2); }
.leyenda span { display: inline-flex; align-items: center; gap: 7px; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.leyenda i.linea { height: 2px; width: 16px; border-radius: 2px; }

/* Semáforo pequeño */
.punto-estado { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.punto-estado--bien { background: var(--bien); box-shadow: 0 0 6px color-mix(in srgb, var(--bien) 40%, transparent); }
.punto-estado--ojo { background: var(--ojo); box-shadow: 0 0 6px color-mix(in srgb, var(--ojo) 40%, transparent); }
.punto-estado--mal { background: var(--mal); box-shadow: 0 0 6px color-mix(in srgb, var(--mal) 40%, transparent); animation: latido 1.6s ease-in-out infinite; }
.punto-estado--apagado { background: var(--apagado); }

/* ───────── Añadidos de las piezas: barra de tiempo compacta, confirmaciones, código y hojas ───────── */
.tiempo__meta { position: absolute; top: -3px; width: 10px; height: 14px; border-radius: 3px; border: 2px solid var(--tinta-3); background: var(--fondo-2); }
.tiempo--compacta { gap: 0; min-width: 90px; }
.tiempo--compacta .tiempo__pista { height: 6px; }
.tiempo--compacta .tiempo__hoy { top: -4px; height: 14px; }
.tiempo--compacta .tiempo__meta { top: -4px; height: 14px; width: 8px; }

.ventana__cuerpo { display: flex; flex-direction: column; gap: 14px; }
.confirmar__icono { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--oro-suave); color: var(--oro); border: 1px solid var(--oro-borde); }
.confirmar__icono .icono { width: 24px; height: 24px; }
.confirmar__icono--mal { background: var(--mal-suave); color: var(--mal); border-color: transparent; }
.confirmar__detalle { padding: 14px 16px; border-radius: 14px; background: var(--fondo-3); border: 1px solid var(--linea); font-size: var(--t-s); display: flex; flex-direction: column; gap: 6px; }
.confirmar__detalle .fila { justify-content: space-between; }
.confirmar__codigo { display: flex; flex-direction: column; gap: 12px; padding: 6px 0; }
.confirmar__registro { display: flex; align-items: center; gap: 8px; }
.confirmar__registro .icono { width: 15px; height: 15px; }
.codigo--error input { border-color: var(--mal); animation: tiembla .4s linear; }
@keyframes tiembla { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.toast__cerrar { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--tinta-4); flex: none; margin: -4px -4px 0 0; }
/* «Deshacer» dentro del aviso flotante (mejora 32) */
.toast__deshacer { display: inline-flex; align-items: center; gap: 5px; align-self: center; flex: none; min-height: 32px; padding: 0 10px; border-radius: 9px; font-size: var(--t-xs); font-weight: 600; color: var(--oro-texto); border: 1px solid var(--oro-borde); background: var(--oro-suave); }
.toast__deshacer .icono { width: 13px; height: 13px; }
.toast__deshacer:hover { border-color: var(--oro); }
.toast__cerrar:hover { color: var(--tinta); background: var(--panel-a); }
.toast__cerrar .icono { width: 14px; height: 14px; }

.velo--hoja { z-index: 69; display: block; padding: 0; }
.velo.sale { animation: aparece-suave .28s linear reverse both; }
.hoja.sale { animation: entra-hoja .28s ease-in reverse both; }
.hoja__cabeza h3 { font-size: var(--t-l); gap: 10px; }
.hoja__cabeza h3 .icono { width: 18px; height: 18px; color: var(--oro); }
@media (max-width: 640px) { .hoja { width: 100vw !important; } }

.ficha-cabeza h2 .pastilla { letter-spacing: normal; }

/* En pantallas táctiles y en el móvil, las zonas de pulsación nunca bajan de 40 px (mejora 33) */
@media (pointer: coarse), (max-width: 640px) {
  .boton--peq, .chip { height: 40px; }
  .segmentado button { height: 40px; }
  .pestanas button { min-height: 40px; }
  .menu-flotante button, .menu-flotante a { min-height: 44px; }
  .toast__cerrar { width: 40px; height: 40px; margin: -8px -8px -6px 0; }
  .toast__deshacer { min-height: 40px; }
  .interruptor { min-height: 40px; }
  .volver { min-height: 40px; }
  .enlace { min-height: 32px; }
}

/* ───────── Aire entre piezas que van juntas ───────── */
/* Dos pastillas seguidas («Justa» «Temporada»), separadas lo justo para leerse como dos */
.pastilla + .pastilla { margin-left: 3px; }
/* En una columna de la rejilla, lo que va apilado (un panel y su nota, dos paneles) lleva el mismo aire que la rejilla */
.rejilla > :is(.c-12, .c-8, .c-7, .c-6, .c-5, .c-4, .c-3):not(.pila) > * + * { margin-top: clamp(12px, 1.4vw, 18px); }
/* Una celda que no se parte en varias líneas (la fecha y la hora de salida), en la tabla de escritorio */
@media (min-width: 901px) { .tabla td.sin-salto { white-space: nowrap; } }
/* Pastillas seguidas en una celda: si bajan de línea, con aire entre las dos */
.tabla td > .pastilla + .pastilla { margin-top: 3px; }
/* En una tarjeta de tabla, una fila con su foto y su nombre baja de línea antes que salirse */
@media (max-width: 900px) { .tabla--tarjetas td span.fila, .tabla--tarjetas td .fila { flex-wrap: wrap; } }
/* Bajo una cifra de una tabla, su explicación («con 27,18 m que ya faltaban») puede ir en dos líneas: la cifra no se parte, la tabla cabe */
.tabla td.num .mpeq, .tabla td.num small { white-space: normal; }
/* En una tabla en tarjetas (móvil y tableta), la fila marcada con un fondo (pierde dinero, por revisar, programada…) es
   una tarjeta entera: con sus esquinas y con aire arriba y abajo, nunca pegada a otra marcada */
@media (max-width: 900px) {
  .tabla--tarjetas tr:is(.mk-fila-pierde, .mk-fila-nueva, .mk-fila-prog, .adm-fila-ojo, .adm-fila-info, .adm-fila-mal) { border-radius: 14px; padding-left: 12px; padding-right: 12px; margin: 8px 0; border-bottom-color: transparent; }
}
/* Una nota dentro de un panel nunca va pegada a lo de arriba ni a lo de abajo (una barra, una lista, unas tarjetas).
   En el panel los márgenes se juntan: donde ya había aire, no se suma */
.panel > * + .nota, .panel > .nota + * { margin-top: 12px; }
