:root {
  --bg: oklch(0.97 0.006 258);
  --surface: #ffffff;
  --border: oklch(0.90 0.008 258);
  --text: oklch(0.22 0.02 258);
  --text-secondary: oklch(0.48 0.02 258);
  --text-tertiary: oklch(0.62 0.015 258);
  --accent: oklch(0.56 0.19 258);
  --accent-soft: oklch(0.93 0.03 258);
  --success: oklch(0.62 0.14 152);
  --success-soft: oklch(0.93 0.05 152);
  --warning: oklch(0.55 0.14 75);
  --warning-soft: oklch(0.95 0.04 75);
  --dark: oklch(0.20 0.015 258);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Work Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
}
.screen[hidden] { display: none; }

/* Header */
.topbar { display: flex; align-items: center; padding: 20px 12px 0; }
.topbar .back-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.topbar .titulo { flex: 1; text-align: center; font-size: 16px; font-weight: 600; margin-right: 44px; }

.paso-label { padding: 14px 20px 0; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.progreso { margin: 10px 20px 0; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.progreso > div { height: 100%; background: var(--accent); border-radius: 2px; transition: width .2s; }

.titulo-pantalla { padding: 24px 20px 0; font-size: 22px; font-weight: 700; }
.subtitulo { padding: 8px 20px 0; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }

/* Formularios */
.campo { padding: 0 20px; margin-top: 18px; }
.campo label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
.campo input, .campo textarea {
  width: 100%; height: 52px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); padding: 0 16px; font-size: 15px; color: var(--text);
  font-family: inherit;
}
.campo input:focus, .campo textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.campo input.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 17px; letter-spacing: 0.02em; }
.campo .hint { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; line-height: 1.4; }

/* Botones */
.acciones { margin-top: auto; padding: 22px 20px 36px; display: flex; flex-direction: column; gap: 12px; }
.btn {
  width: 100%; height: 52px; border-radius: 12px; border: none; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); }
.btn-outline-accent { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
.btn-link { background: none; border: none; color: var(--accent); font-weight: 600; font-size: 13.5px; }

/* Tipo de entrega */
.opciones-tipo { display: flex; gap: 12px; padding: 0 20px; }
.opcion-tipo {
  flex: 1; height: 68px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  position: relative; cursor: pointer;
}
.opcion-tipo.seleccionada, .opcion-tipo-destino.seleccionada { border-color: var(--accent); background: var(--accent-soft); }
.opcion-tipo span, .opcion-tipo-destino span { font-size: 13.5px; font-weight: 600; color: var(--text); }
.opcion-tipo.seleccionada span, .opcion-tipo-destino.seleccionada span { color: var(--accent); }
.opcion-tipo-destino {
  flex: 1; height: 68px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  position: relative; cursor: pointer;
}

/* Botón ancho de opción (Sí/No) — mismo look que .opcion-tipo pero en fila y sin la lógica de selección global */
.opcion-ancha {
  border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  display: flex; align-items: center; cursor: pointer; color: var(--text);
}
.opcion-ancha span { font-size: 14.5px; font-weight: 600; }
.opcion-ancha:active { background: var(--accent-soft); border-color: var(--accent); }

/* Camara / vista previa de foto */
.visor {
  margin: 20px 20px 0; height: 380px; border-radius: 20px; background: var(--dark);
  position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.visor video, .visor img { width: 100%; height: 100%; object-fit: cover; }
.visor .marco { position: absolute; inset: 40px 40px 76px; border: 2px dashed rgba(255,255,255,0.4); border-radius: 12px; pointer-events: none; }

.controles-camara { margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 32px; padding: 24px 0 36px; }
.btn-shutter {
  width: 72px; height: 72px; border-radius: 50%; background: white; border: 4px solid var(--accent);
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.btn-shutter > span { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); display: block; }
.btn-icono-camara {
  width: 48px; height: 48px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}

/* Lista de lotes/series detectados */
.lista-detectados { margin: 18px 20px 0; display: flex; flex-direction: column; gap: 10px; }
.item-detectado {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
}
.item-detectado.incompleto { background: var(--warning-soft); border-color: var(--warning); border-width: 1.5px; }
.item-detectado .codigo {
  flex: 1; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 16px; font-weight: 600;
  border-bottom: 1.5px dashed var(--border); padding-bottom: 3px; cursor: text; outline: none;
}
.item-detectado.incompleto .codigo { border-bottom-color: var(--warning); }
.item-detectado .codigo:focus { border-bottom-style: solid; border-bottom-color: var(--accent); }
.item-detectado .nota-incompleto { font-size: 11.5px; color: var(--warning); margin-top: 3px; }
.item-detectado .acciones { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.item-detectado button { background: none; border: none; padding: 0; cursor: pointer; display: flex; }
.item-detectado button.btn-editar-codigo { color: var(--accent); }
.item-detectado button.btn-quitar-codigo { color: var(--text-tertiary); }

/* Chips (ya agregados) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 8px 7px 14px; font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px; font-weight: 600;
}
.chip button { width: 18px; height: 18px; border-radius: 50%; background: oklch(0.93 0.008 258); border: none; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }

/* Tarjeta de resumen */
.card { margin: 18px 20px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.card-fila { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.card-fila .icono { margin-top: 2px; flex-shrink: 0; color: var(--text-tertiary); }
.card-fila .etiqueta { font-size: 12px; color: var(--text-tertiary); }
.card-fila .valor { font-size: 14.5px; color: var(--text); font-weight: 500; }
.card-divisor { height: 1px; background: oklch(0.92 0.008 258); }

/* Lista de resultados de búsqueda (traslados: buscar negocio) */
.lista-resultados { margin-top: 10px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.resultado-item { width: 100%; text-align: left; padding: 12px 14px; background: none; border: none; border-bottom: 1px solid var(--border); cursor: pointer; font-family: inherit; }
.resultado-item:last-child { border-bottom: none; }
.resultado-item:active { background: var(--accent-soft); }
.resultado-item .nombre { font-size: 14px; font-weight: 600; color: var(--text); }
.resultado-item .codigo { font-size: 12px; color: var(--text-tertiary); font-family: 'JetBrains Mono', ui-monospace, monospace; margin-top: 2px; }
.resultado-vacio { padding: 14px; font-size: 13px; color: var(--text-tertiary); }

/* Negocio encontrado */
.negocio-encontrado {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px;
}
.negocio-encontrado .icono { width: 40px; height: 40px; border-radius: 10px; background: var(--success-soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--success); }

/* Estado / pill */
.pill { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill-opcional { color: var(--text-tertiary); background: var(--border); }
.pill-nota { color: var(--accent); background: var(--accent-soft); }

/* Éxito */
.exito-centro { display: flex; flex-direction: column; align-items: center; margin-top: 140px; padding: 0 32px; text-align: center; }
.exito-icono { width: 96px; height: 96px; border-radius: 50%; background: var(--success-soft); display: flex; align-items: center; justify-content: center; color: var(--success); }

/* Spinner / carga */
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,0.4); border-top-color: white; animation: girar .7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

.banner-error { margin: 14px 20px 0; background: var(--warning-soft); border: 1px solid var(--warning); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--warning); white-space: pre-wrap; }

/* Motivo de cierre (lista de opciones tipo radio) */
.opciones-motivo { margin: 10px 20px 0; display: flex; flex-direction: column; gap: 9px; }
.opcion-motivo {
  width: 100%; text-align: left; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  padding: 13px 14px; font-size: 14px; font-weight: 600; color: var(--text); font-family: inherit;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.opcion-motivo.seleccionada { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.radio-dot { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.opcion-motivo.seleccionada .radio-dot { border-color: var(--accent); }
.opcion-motivo.seleccionada .radio-dot::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

/* Interruptor (ej. "Este negocio está cerrando" en Retiro) */
.toggle-fila {
  margin: 18px 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 13px 14px;
}
.toggle-fila.activo { border-color: var(--warning); background: var(--warning-soft); }
.toggle-fila .t1 { font-size: 13.5px; font-weight: 600; }
.toggle-fila .t2 { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.switch-toggle { width: 42px; height: 24px; border-radius: 999px; background: var(--border); position: relative; flex-shrink: 0; border: none; padding: 0; cursor: pointer; }
.switch-toggle.on { background: var(--warning); }
.switch-toggle span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; transition: left .15s; }
.switch-toggle.on span { left: 21px; }

/* Foto opcional chica (ej. evidencia del cierre) */
.foto-chica-preview { display: flex; align-items: center; gap: 10px; margin: 10px 20px 0; }
.foto-chica-preview img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }

/* Aviso de existencias antes de cerrar/inactivar un negocio (Cerrar negocio
   standalone y Retiro + cierre combinado) — "No todavía" bloquea seguir. */
.aviso-existencias { margin: 18px 20px 0; border-radius: 14px; border: 1.5px solid var(--warning); background: var(--warning-soft); padding: 15px 15px 17px; }
.aviso-existencias .pregunta { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.4; display: flex; gap: 9px; align-items: flex-start; }
.aviso-existencias .pregunta svg { flex-shrink: 0; margin-top: 1px; color: var(--warning); }
.opciones-si-no { display: flex; gap: 9px; margin-top: 13px; }
.opcion-si-no { flex: 1; height: 44px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.opcion-si-no.seleccionada-si { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.opcion-si-no.seleccionada-no { border-color: var(--warning); background: var(--warning); color: white; }
.nota-no { margin-top: 11px; font-size: 12px; color: var(--warning); line-height: 1.4; display: none; }
.nota-no.visible { display: block; }

/* Mis registros (resumen personal del promotor) */
.teaser-resumen {
  margin: 14px 20px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 15px; display: flex; align-items: center; gap: 12px; cursor: pointer; width: calc(100% - 40px);
  font-family: inherit; text-align: left;
}
.teaser-resumen .num { font-size: 20px; font-weight: 700; color: var(--text); }
.teaser-resumen .txt { flex: 1; }
.teaser-resumen .txt .t1 { font-size: 13px; font-weight: 600; color: var(--text); }
.teaser-resumen .txt .t2 { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.teaser-resumen .flecha { color: var(--text-tertiary); flex-shrink: 0; }

.filtros-rapidos { display: flex; gap: 8px; padding: 14px 20px 0; }
.filtro-pill { border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); padding: 7px 14px; font-size: 12px; font-weight: 600; color: var(--text-secondary); font-family: inherit; cursor: pointer; }
.filtro-pill.activo { background: var(--accent); border-color: var(--accent); color: white; }

.kpis-mini { display: flex; flex-wrap: wrap; gap: 9px; padding: 14px 20px 0; }
.kpi-mini { flex: 1; min-width: 44%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 10px; text-align: center; }
.kpi-mini .num { font-size: 19px; font-weight: 700; }
.kpi-mini .label { font-size: 10px; color: var(--text-secondary); margin-top: 2px; line-height: 1.3; }
.kpi-mini.alerta { border-color: var(--warning); background: var(--warning-soft); }
.kpi-mini.alerta .num, .kpi-mini.alerta .label { color: var(--warning); }

.lista-mis-registros { display: flex; flex-direction: column; gap: 9px; padding: 14px 20px 24px; }
.registro-item { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 12px 13px; display: flex; flex-direction: column; gap: 6px; }
.registro-item .fila-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.registro-item .fecha { font-size: 11px; color: var(--text-tertiary); }
.tipo-pill { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.tipo-nuevo { background: var(--accent-soft); color: var(--accent); }
.tipo-reposicion { background: var(--success-soft); color: var(--success); }
.tipo-reasignacion { background: var(--warning-soft); color: var(--warning); }
.tipo-retiro { background: oklch(0.92 0.008 258); color: var(--text-secondary); }
.tipo-cierre { background: var(--warning-soft); color: var(--warning); }
.registro-item .fila-mid { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.registro-item .negocio { font-size: 14.5px; font-weight: 700; }
.registro-item .detalle { font-size: 11.5px; color: var(--text-secondary); }
.registro-item .subida-tarde { color: var(--warning); }
.estado-pill { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.estado-confirmado { background: var(--success-soft); color: var(--success); }
.estado-por-confirmar { background: var(--warning-soft); color: var(--warning); }

.vacio-lista { text-align: center; color: var(--text-tertiary); font-size: 12.5px; padding: 30px 20px; }
