/* M-UPLINK · azul del ecosistema (Azul Halo), M naranja. Mobile-first, botones grandes. */
:root {
  color-scheme: dark;
  --fondo: #08121D;
  --panel: #0F1E2F;
  --panel-2: #142940;
  --linea: #1F3B5A;
  --texto: #DCE9F7;
  --suave: #8CA6C2;
  --senal: #3FA9F5;
  --senal-suave: rgba(63, 169, 245, .14);
  --m: #FF8A00;
  --ok: #3DD68C;
  --ok-suave: rgba(61, 214, 140, .12);
  --espera: #F2C14E;
  --espera-suave: rgba(242, 193, 78, .12);
  --cierre: #F2706B;
  --cierre-suave: rgba(242, 112, 107, .12);
  --display: "Rajdhani", "Barlow", system-ui, sans-serif;
  --cuerpo: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radio: 12px;
}
* { box-sizing: border-box; }
html, body { background: var(--fondo); color: var(--texto); }
body {
  margin: 0;
  font-family: var(--cuerpo);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) 16px calc(24px + env(safe-area-inset-bottom, 0));
}
body.con-barra { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0)); }
body.con-modal { overflow: hidden; }
main, .top, .fijados, .pie { width: 100%; max-width: 560px; margin-inline: auto; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--senal); outline-offset: 2px; }

/* ---- encabezado ---- */
.top { display: flex; flex-direction: column; gap: 6px; padding: 18px 0 14px; border-bottom: 1px solid var(--linea); }
.marca { font-family: var(--display); font-weight: 700; font-size: 2rem; letter-spacing: .05em; margin: 0; line-height: 1; }
.m { color: var(--m); }
.quien { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.quien-nombre { font-weight: 600; }
.quien-grupo { color: var(--suave); font-size: .95rem; }
.enlace { background: none; border: 0; color: var(--senal); padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---- vistas ---- */
.vista { padding: 20px 0 8px; }
.titulo { font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1.15; margin: 0 0 8px; }
.ayuda { color: var(--suave); margin: 0 0 18px; }
.pequena { font-size: .9rem; margin: 10px 0 0; }
.error { background: var(--cierre-suave); border: 1px solid var(--cierre); color: #FFD6D3; border-radius: 10px; padding: 12px 14px; margin: 14px 0 0; }
.vacio { color: var(--suave); border: 1px dashed var(--linea); border-radius: var(--radio); padding: 22px 16px; text-align: center; }
.volver { margin-bottom: 8px; }

/* ---- formulario de entrada ---- */
label { display: block; font-weight: 600; margin: 18px 0 6px; }
input[type="text"] {
  width: 100%; font: inherit; font-size: 1.35rem; letter-spacing: .04em;
  padding: 14px 16px; min-height: 58px;
  background: var(--panel); color: var(--texto);
  border: 2px solid var(--linea); border-radius: var(--radio);
}
input[type="text"]:focus { border-color: var(--senal); outline: none; }
#inCodigo { text-transform: uppercase; }
.pin { -webkit-text-security: disc; letter-spacing: .4em; }
.aviso { border-radius: var(--radio); padding: 14px 16px; margin-bottom: 8px; background: var(--cierre-suave); border: 1px solid var(--cierre); }

/* ---- botones ---- */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 58px; padding: 14px 18px; border-radius: var(--radio); font-weight: 700; font-size: 1.1rem; border: 2px solid transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--senal); color: #04101C; margin-top: 24px; }
.btn-sec { background: transparent; color: var(--texto); border-color: var(--linea); }
.btn-sec:not(:disabled):active { background: var(--senal-suave); border-color: var(--senal); }
.botones-archivo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.botones-archivo .btn { min-height: 76px; flex-direction: column; gap: 4px; font-size: 1.05rem; }
.botones-archivo .btn::before { content: ""; width: 26px; height: 26px; background: currentColor; -webkit-mask: var(--icono) center / contain no-repeat; mask: var(--icono) center / contain no-repeat; }
#btnFoto { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M3 8h4l2-3h6l2 3h4v11H3z'/%3E%3Ccircle cx='12' cy='13' r='3.5'/%3E%3C/svg%3E"); }
#btnArchivos { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M6 3h8l4 4v14H6z'/%3E%3Cpath d='M14 3v4h4'/%3E%3C/svg%3E"); }
@media (max-width: 340px) { .botones-archivo { grid-template-columns: 1fr; } }

/* ---- lista de actividades ---- */
.actividades { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.act {
  width: 100%; text-align: left; color: var(--texto);
  background: var(--panel); border: 1px solid var(--linea); border-left: 5px solid var(--linea);
  border-radius: var(--radio); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.act[data-estado="abierta"] { border-left-color: var(--ok); }
.act[data-estado="por-abrir"] { border-left-color: var(--espera); }
.act[data-estado="cerrada"] { border-left-color: var(--cierre); }
.act-nombre { font-family: var(--display); font-weight: 700; font-size: 1.35rem; line-height: 1.15; }
.act-ventana { color: var(--suave); font-size: .95rem; }
.act-mia { font-weight: 600; font-size: .95rem; }
.act-mia.entregado { color: var(--ok); }
.act-mia.falta { color: var(--espera); }
.cuenta { font-variant-numeric: tabular-nums; }

/* ---- estado de una actividad ---- */
.instrucciones { white-space: pre-line; margin: 0 0 14px; }
.estado { border-radius: var(--radio); padding: 14px 16px; border: 1px solid; display: flex; flex-direction: column; gap: 2px; }
.estado strong { font-size: 1.05rem; }
.estado.abierta { background: var(--ok-suave); border-color: var(--ok); }
.estado.por-abrir { background: var(--espera-suave); border-color: var(--espera); }
.estado.cerrada { background: var(--cierre-suave); border-color: var(--cierre); }

/* ---- archivos listos (aún no enviados) ---- */
.pendientes { list-style: none; margin: 14px 0 0; padding: 0; }
.pendiente-resumen { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radio); background: var(--espera-suave); border: 2px solid var(--espera); }
.pendiente-resumen .texto { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pendiente-resumen strong { color: #FFE7A8; }
.pendiente-resumen small { color: var(--suave); }
.pendiente-resumen .quitar { background: none; border: 1px solid var(--linea); color: var(--texto); border-radius: 8px; padding: 8px 12px; }

/* ---- botón fijo de envío ---- */
.barra-enviar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0)); background: linear-gradient(transparent, var(--fondo) 30%); z-index: 50; }
.btn-enviar { max-width: 560px; margin: 0 auto; background: var(--ok); color: #03140B; min-height: 64px; font-size: 1.2rem; }

/* ---- entregas anteriores ---- */
.mis-entregas { margin-top: 28px; }
.mis-entregas h3, .historial h3 { font-family: var(--display); font-size: 1.2rem; margin: 0 0 8px; }
.mis-entregas ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entrega { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 12px 14px; }
.entrega.vigente { border-color: var(--ok); }
.entrega-cabeza { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.entrega-meta { color: var(--suave); font-size: .9rem; }
.entrega-archivos { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.entrega-archivos button { background: var(--panel-2); color: var(--texto); border: 1px solid var(--linea); border-radius: 8px; padding: 8px 10px; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calificacion { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--linea); }
.calificacion strong { color: var(--ok); font-size: 1.1rem; }

/* ---- avisos ---- */
.fijados { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.fijados:empty { display: none; }
.fijado { background: var(--senal-suave); border: 1px solid var(--senal); border-radius: 10px; padding: 10px 14px; }
.fijado strong { display: block; }
.historial { margin-top: 28px; }
.historial ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.historial li { background: var(--panel); border-radius: 10px; padding: 10px 14px; border-left: 4px solid var(--linea); }
.historial li.nuevo { border-left-color: var(--senal); }

/* ---- modal / transmisión ---- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(4, 10, 18, .82); }
.modal-caja { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--linea); border-radius: 16px; padding: 24px 20px 20px; }
.modal-caja h3 { font-family: var(--display); font-size: 1.6rem; margin: 0 0 14px; }
.modal.exito .modal-caja { border-color: var(--ok); }
.modal.exito h3 { color: var(--ok); }
.modal.falla .modal-caja { border-color: var(--cierre); }
.modal.falla h3 { color: var(--cierre); }
.modal.enviando #modalOk { display: none; }

/* La barra de transmisión: un tramo por archivo + el registro final */
.segmentos { display: flex; gap: 4px; height: 22px; }
.segmento { flex: 1; background: var(--panel-2); border-radius: 4px; overflow: hidden; position: relative; }
.segmento i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--senal); transition: width .2s linear; }
.segmento.listo i { background: var(--ok); }
.segmento.registro { flex: 0 0 22px; }
.transmision-texto { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 12px 0 0; }
.transmision-texto strong { font-family: var(--display); font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.recibo { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; background: var(--fondo); border: 1px solid var(--linea); border-radius: 10px; padding: 14px; }
.recibo dt { color: var(--suave); }
.recibo dd { margin: 0; font-weight: 600; word-break: break-word; }
.folio { font-family: var(--display); font-size: 1.3rem; letter-spacing: .08em; color: var(--senal); }
.tarde { color: var(--espera); }

/* Aviso modal: mantener presionado 2 s */
.aviso-texto { white-space: pre-line; margin: 0 0 20px; }
.btn-mantener { position: relative; overflow: hidden; background: var(--panel-2); color: var(--texto); border-color: var(--senal); user-select: none; -webkit-user-select: none; touch-action: none; }
.mantener-relleno { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--senal-suave); border-right: 2px solid var(--senal); }
.btn-mantener.llenando .mantener-relleno { width: 100%; transition: width 2s linear; }
.mantener-texto { position: relative; }

.pie { margin-top: auto; padding-top: 28px; text-align: center; color: var(--suave); font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .btn-mantener.llenando .mantener-relleno { transition: width 2s steps(4) !important; }
}
