/* Predix · Propuesta B «Señal de campo».
   Tokens tomados del archivo de Figma «Predix · MVP 3 Pedido sugerido por ruta» (columna B). */
:root {
  /* Paleta */
  --blanco: #FFFFFF;
  --negro-senal: #0E0F11;
  --amarillo-vial: #FFD21F;
  --agotado: #D7261E;
  --a-favor: #1F7A3D;
  --gris-texto: #4A4E54;
  /* Apoyo */
  --linea: #C9CDD1;
  --fondo-escritorio: #E9EBE7;
  --aviso: #FFF4C2;
  --aviso-texto: #2B2A1F;
  --pista: #3A3D42;
  /* Tipografía */
  --condensada: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --texto: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Forma y movimiento */
  --radio: 4px;
  --radio-boton: 6px;
  --salida: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--blanco); color: var(--negro-senal); font: 400 16px/1.45 var(--texto); font-variant-numeric: tabular-nums; }
@media (min-width: 960px) { body { background: var(--fondo-escritorio); } }
h1, h2, h3 { font-family: var(--condensada); font-weight: 700; line-height: 1.05; margin: 0; }
h1 { font-size: 40px; }
h2 { font-size: 28px; line-height: 1.1; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--negro-senal); outline-offset: 2px; box-shadow: 0 0 0 5px var(--amarillo-vial); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amarillo-vial); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.noscript { padding: 24px; }
.section-title { font: 600 15px/1.3 var(--texto); }
.muted { color: var(--gris-texto); }

/* Pie de página con el aviso de derechos */
.pie { width: calc(100% - 32px); max-width: 1088px; margin: 40px auto 0; padding: 16px 0 24px; border-top: 1px solid var(--linea); color: var(--gris-texto); font: 400 13px/1.5 var(--texto); }
.pie a { color: var(--negro-senal); font-weight: 600; }

/* Barra superior de la aplicación */
.band { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; min-height: 56px;
        padding: env(safe-area-inset-top) 16px 0; background: var(--negro-senal); color: var(--blanco); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 26px/1 var(--condensada); letter-spacing: .02em; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.band-route { font: 600 14px/1.2 var(--texto); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.tabs { display: flex; gap: 4px; }
.tabs a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px; font: 600 18px/1 var(--condensada);
          text-decoration: none; color: var(--blanco); opacity: .75; border-bottom: 4px solid transparent; }
.tabs a[aria-current="page"] { opacity: 1; border-bottom-color: var(--amarillo-vial); }
@media (max-width: 959px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--blanco); border-top: 1px solid var(--linea); padding-bottom: env(safe-area-inset-bottom); gap: 0; }
  .tabs a { flex: 1; justify-content: center; color: var(--gris-texto); opacity: 1; border-bottom: 0; border-top: 4px solid transparent; min-height: 56px; }
  .tabs a[aria-current="page"] { color: var(--negro-senal); border-top-color: var(--amarillo-vial); }
  main { padding-bottom: 8px; }
  .pie { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.in-store .band, body.in-store .tabs { display: none; }
  body.in-store main { padding-bottom: 0; }
  body.in-store .pie { display: none; }
}

main { outline: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 32px; }
@media (min-width: 960px) { .page { padding: 40px 32px 56px; } }
.lede { font-size: 16px; line-height: 1.45; max-width: 62ch; margin-top: 10px; }
.stack > * + * { margin-top: 16px; }

/* Paneles: misma superficie que la fila de producto de Figma */
.grid { display: grid; gap: 20px; margin-top: 24px; }
@media (min-width: 960px) { .grid { grid-template-columns: 380px 1fr; align-items: start; } }
.panel { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); padding: 20px; }
.panel h2 { margin-bottom: 10px; }
.hint { font-size: 14px; line-height: 1.45; color: var(--gris-texto); }
.field { display: grid; gap: 6px; }
.field label { font: 600 15px/1.3 var(--texto); }
.field input[type="date"], .field select { min-height: 44px; padding: 0 12px; border: 1.5px solid var(--gris-texto); border-radius: var(--radio); background: var(--blanco); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--negro-senal); min-height: 44px; }
.range-row output { font: 600 34px/1 var(--condensada); min-width: 3.2ch; text-align: right; }
.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--negro-senal); flex: none; }

/* Botones: primario = «Botón principal» de Figma; secundario = mismo trazo que el chip */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 10px 14px;
       border: 1.5px solid var(--gris-texto); border-radius: var(--radio); background: var(--blanco); font: 600 14px/1.2 var(--texto);
       text-decoration: none; cursor: pointer; transition: transform 100ms var(--salida), background-color 150ms var(--salida); }
.btn::after { content: ""; position: absolute; inset: -3px; }
.btn:active { transform: scale(.97); }
.btn-primary { border: 0; border-radius: var(--radio-boton); background: var(--amarillo-vial); color: var(--negro-senal); padding: 18px 20px; font: 600 18px/1.2 var(--texto); }
.btn-block { width: 100%; }
.btn-file { overflow: hidden; }
.btn-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: 600 14px/1.3 var(--texto); min-height: 32px; }

/* Avisos de datos: superficie «Aviso» de Figma */
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.issues li { padding: 10px 12px; border-radius: var(--radio); background: var(--aviso); color: var(--aviso-texto); font-size: 13px; line-height: 1.4; }
.issues li.error { background: var(--agotado); color: var(--blanco); }
.issues .row-ref { font-weight: 600; }
.fatal { padding: 12px 14px; border-radius: var(--radio); background: var(--agotado); color: var(--blanco); font-weight: 600; }

/* Hoja de carga */
.load-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-top: 4px; }
.big { font: 600 72px/1 var(--condensada); }
.big small { font: 400 20px/1 var(--texto); color: var(--gris-texto); margin-left: 8px; }
.versus { font-size: 14px; color: var(--gris-texto); }
.compare { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 15px; }
.compare th, .compare td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--linea); }
.compare th:first-child, .compare td:first-child { text-align: left; }
.compare thead th { font: 600 13px/1.3 var(--texto); color: var(--gris-texto); }
.compare tfoot td { font-weight: 600; border-bottom: 0; }
.compare .good { color: var(--a-favor); font-weight: 600; }
.compare .bad { color: var(--agotado); font-weight: 600; }
.model-note { margin-top: 10px; font-size: 13px; color: var(--gris-texto); max-width: 70ch; }
.table-wrap { overflow-x: auto; }

/* «Barra de ruta» de Figma: negro señal, texto blanco, avance amarillo */
.route-bar { background: var(--negro-senal); color: var(--blanco); padding: calc(22px + env(safe-area-inset-top)) 16px 16px; display: grid; gap: 10px; }
.route-bar .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.route-bar .route-name { font: 600 14px/1.2 var(--texto); }
.route-bar .count { font: 600 14px/1.2 var(--condensada); }
.progress { height: 6px; background: var(--pista); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--amarillo-vial); border-radius: 3px; transition: width 250ms var(--salida); }

/* Lista de tiendas */
.stores { list-style: none; margin: 0; padding: 4px 16px 16px; display: grid; gap: 10px; }
.stores a { display: grid; grid-template-columns: 2.2ch 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; text-decoration: none;
            background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); }
.stores a[aria-current="true"] { border-color: var(--negro-senal); box-shadow: inset 4px 0 0 var(--amarillo-vial); }
.stores .num { font: 600 14px/1 var(--condensada); color: var(--gris-texto); }
.stores .name { font: 700 22px/1.1 var(--condensada); }
.stores .meta { display: block; font: 400 13px/1.35 var(--texto); color: var(--gris-texto); margin-top: 2px; }
.stores .qty-cell { font: 600 34px/1 var(--condensada); text-align: right; white-space: nowrap; }
.stores .qty-cell small { font: 400 15px/1 var(--texto); color: var(--gris-texto); margin-left: 4px; }
.stores .done a { background: #F6F7F5; }
.stores .done .name, .stores .done .qty-cell { color: var(--gris-texto); }
.stores .done .num { color: var(--a-favor); }
.route-layout { display: grid; }
@media (min-width: 960px) {
  .route-layout { grid-template-columns: 380px 1fr; gap: 20px; max-width: 1120px; margin: 24px auto; padding: 0 32px; align-items: start; }
  .route-list, .store-pane { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
  .route-list { position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow: auto; }
  .store-empty { display: grid; place-items: center; color: var(--gris-texto); padding: 64px 24px; }
}
@media (max-width: 959px) { .route-layout.has-store .route-list { display: none; } .route-layout:not(.has-store) .store-pane { display: none; } }
.store-pane { min-width: 0; }

/* Pantalla «Tienda» de Figma */
.store { display: flex; flex-direction: column; min-height: 100vh; background: var(--blanco); }
@media (min-width: 960px) { .store { min-height: 0; } .store .route-bar { padding-top: 22px; } }
.store-head { padding: 18px 16px 12px; display: grid; gap: 6px; }
.store-head .back { justify-self: start; display: inline-flex; align-items: center; min-height: 32px; font: 600 14px/1 var(--texto); text-decoration: none; color: var(--gris-texto); }
@media (min-width: 960px) { .store-head .back { display: none; } }
.store-title { font: 700 28px/1.1 var(--condensada); }
.store-sub { font-size: 14px; line-height: 1.3; color: var(--gris-texto); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border: 1.5px solid var(--gris-texto); border-radius: var(--radio); font: 600 13px/1 var(--texto); color: var(--negro-senal); }
.badge.control { border-style: dashed; }
.note { padding: 10px 12px; border-radius: var(--radio); background: var(--aviso); color: var(--aviso-texto); font-size: 13px; line-height: 1.4; }
.items { list-style: none; margin: 0; padding: 4px 16px 16px; display: grid; gap: 10px; }
.more { font-size: 13px; color: var(--gris-texto); }

/* «Fila de producto · B» */
.item { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); padding: 16px; display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.item-name { font: 600 18px/1.25 var(--texto); }
.item-detail { font: 400 13px/1.35 var(--texto); color: var(--gris-texto); margin-top: 4px; }
.item-detail .alerta { color: var(--agotado); font-weight: 600; }
.qty { display: flex; align-items: baseline; gap: 4px; justify-content: flex-end; }
.qty-num { font: 600 34px/1 var(--condensada); display: inline-block; min-width: 1.2ch; text-align: right; }
.qty-unit { font: 400 15px/1 var(--texto); color: var(--gris-texto); }
.qty-was { font-size: 12px; color: var(--gris-texto); text-align: right; min-height: 0; }
.qty-was:empty { display: none; }
.item-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* «Chip agotado · B»: Normal = trazo gris 1.5; Agotado = relleno rojo */
.chip { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1.5px solid var(--gris-texto); border-radius: var(--radio);
        background: transparent; color: var(--negro-senal); font: 600 14px/1.2 var(--texto); cursor: pointer;
        transition: background-color 150ms var(--salida), border-color 150ms var(--salida), color 150ms var(--salida), transform 100ms var(--salida); }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--gris-texto); transition: background-color 150ms var(--salida), box-shadow 150ms var(--salida); }
.chip::after { content: ""; position: absolute; inset: -3px; }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--agotado); border-color: var(--agotado); color: var(--blanco); }
.chip[aria-pressed="true"]::before { background: var(--blanco); box-shadow: none; }

/* Ajustes de la fila (fuera del componente base, plegados por defecto) */
.adjust-toggle { position: relative; background: none; border: 0; padding: 10px 4px; font: 600 14px/1.2 var(--texto); color: var(--gris-texto);
                 text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.adjust-toggle::after { content: ""; position: absolute; inset: -2px; }
.adjust-panel { display: none; }
.item.open .adjust-panel { display: block; animation: reveal 200ms var(--salida); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.adjust-inner { display: flex; flex-wrap: wrap; gap: 12px 20px; padding-top: 10px; border-top: 1px solid var(--linea); }
.stepper-field { display: grid; gap: 6px; }
.stepper-label { font: 400 13px/1.3 var(--texto); color: var(--gris-texto); }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--gris-texto); border-radius: var(--radio); }
.stepper button { width: 44px; height: 40px; border: 0; background: transparent; font: 600 22px/1 var(--condensada); cursor: pointer; }
.stepper button:active { background: var(--amarillo-vial); }
.stepper output { min-width: 3ch; text-align: center; font: 600 22px/1 var(--condensada); }

/* «Acción» de Figma */
.store-foot { position: sticky; bottom: 0; margin-top: auto; background: var(--blanco); border-top: 1px solid var(--linea); padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.store-foot .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--gris-texto); }
.store-foot .total { font: 600 22px/1.2 var(--condensada); color: var(--negro-senal); }
.btn-primary.is-done { background: var(--a-favor); color: var(--blanco); }

/* Cierre */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px; }
.kpi b { display: block; font: 600 34px/1 var(--condensada); }
.kpi span { font-size: 13px; color: var(--gris-texto); }
.method ol { padding-left: 20px; margin: 0; }
.method li + li { margin-top: 8px; }

/* Sistema de diseño (página de referencia) */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 16px 12px; margin-top: 12px; }
.swatch { display: grid; gap: 6px; }
.swatch i { display: block; height: 56px; border-radius: var(--radio); border: 1px solid var(--linea); }
.swatch b { font: 600 13px/1.2 var(--texto); }
.swatch code { font: 600 12px/1 var(--condensada); color: var(--gris-texto); }
.specimen { display: grid; gap: 10px; margin-top: 12px; }
.specimen .store-name { font: 700 30px/1.1 var(--condensada); }
.specimen .num-row { display: flex; align-items: baseline; gap: 8px; }
.specimen .num-row b { font: 600 72px/1 var(--condensada); }
.specimen .num-row span { font: 400 20px/1 var(--texto); color: var(--gris-texto); }
.ds-components { display: grid; gap: 16px; margin-top: 12px; max-width: 358px; }

/* Movimiento: solo en respuesta a una acción */
.enter { animation: enter 200ms var(--salida); }
@keyframes enter { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.enter-back { animation: enter-back 200ms var(--salida); }
@keyframes enter-back { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.bump { animation: bump 250ms var(--salida); }
@keyframes bump { 40% { transform: scale(1.08); } }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; z-index: 9; background: var(--negro-senal);
         color: var(--blanco); padding: 12px 16px; border-radius: var(--radio-boton); font: 600 14px/1.3 var(--texto); max-width: calc(100% - 32px);
         transition: opacity 150ms var(--salida), transform 200ms var(--salida); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: center; gap: 14px; }
.toast.has-action.show { pointer-events: auto; }
.toast-action { position: relative; background: none; border: 0; padding: 6px 2px; color: var(--amarillo-vial); font: 600 14px/1 var(--texto); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.toast-action::after { content: ""; position: absolute; inset: -8px; }
body.in-store .toast { bottom: 150px; }

/* Filtros de la lista de tiendas: mismo trazo que el chip */
.filters { display: flex; gap: 8px; padding: 12px 16px 6px; overflow-x: auto; }
.filter { position: relative; flex: none; padding: 8px 12px; border: 1.5px solid var(--gris-texto); border-radius: var(--radio); background: var(--blanco);
          font: 600 14px/1.2 var(--texto); cursor: pointer; transition: background-color 150ms var(--salida), color 150ms var(--salida); }
.filter::after { content: ""; position: absolute; inset: -4px; }
.filter[aria-pressed="true"] { background: var(--negro-senal); border-color: var(--negro-senal); color: var(--blanco); }
.empty-list { padding: 24px 4px; color: var(--gris-texto); }

/* Hoja de carga desplegable por producto */
.row-toggle { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 32px; text-align: left; }
.row-toggle::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 150ms var(--salida); }
.row-toggle[aria-expanded="true"]::before { transform: rotate(45deg); }
.sheet-row.open td { border-bottom-color: transparent; font-weight: 600; }
.sheet-sub td { font-size: 14px; color: var(--gris-texto); background: #F6F7F5; padding-top: 6px; padding-bottom: 6px; }
.sheet-sub td:first-child { padding-left: 24px; color: var(--negro-senal); }
.dot-alert { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--agotado); vertical-align: middle; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Hoja de carga impresa */
@media print {
  .band, .tabs, .no-print, .toast { display: none !important; }
  body { background: var(--blanco); }
  .panel { border: 0; padding: 0; }
  .grid { display: block; }
}
