/* ============ Base ============ */
:root {
  --pri: #d9485f;
  --pri-osc: #b8364c;
  --pri-claro: #fbe3e7;
  --acc: #f4a261;
  --acc-claro: #fdeedd;
  --ok: #2e9e6a;
  --ok-claro: #dff3e9;
  --bg: #fbf7f4;
  --card: #ffffff;
  --txt: #2a2730;
  --muted: #8a8390;
  --linea: #eee7e3;
  --sombra: 0 2px 10px rgba(60, 30, 40, 0.06);
  --r: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--txt); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.45;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
.oculto { display: none !important; }

/* ============ Estructura ============ */
.cabecera {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-top) + 10px) 18px 10px;
  background: rgba(251, 247, 244, 0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid transparent;
}
.cabecera h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.cab-acciones { display: flex; align-items: center; gap: 6px; }
.btn-icono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.btn-icono:active { background: var(--linea); }
.btn-icono svg { width: 22px; height: 22px; }
.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 6px 8px; border-radius: 10px; }
.sync .punto { width: 9px; height: 9px; border-radius: 50%; background: #c9c2c6; }
.sync.ok .punto { background: var(--ok); }
.sync.pend .punto, .sync.subiendo .punto { background: var(--acc); }
.sync.subiendo .punto { animation: latido 1s infinite; }
.sync.err .punto { background: var(--pri); }
@keyframes latido { 50% { opacity: 0.3; } }

main { max-width: 560px; margin: 0 auto; padding: 6px 16px calc(96px + var(--safe-bot)); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--linea);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-bot));
}
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.nav button svg { width: 24px; height: 24px; }
.nav button.activo { color: var(--pri); }

/* ============ Tarjetas y elementos ============ */
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: var(--sombra); margin-bottom: 14px; }
.card h2 { font-size: 19px; font-weight: 750; }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.sub { color: var(--muted); font-size: 14px; }
.mini { font-size: 12.5px; color: var(--muted); }
.sec-titulo { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 4px 8px; }
.fila { display: flex; align-items: center; gap: 10px; }
.entre { justify-content: space-between; }
.gap6 { gap: 6px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 14px; font-weight: 700; font-size: 16px; }
.btn-pri { background: var(--pri); color: #fff; }
.btn-pri:active { background: var(--pri-osc); }
.btn-sec { background: var(--pri-claro); color: var(--pri-osc); }
.btn-gris { background: #f2ece9; color: var(--txt); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ancho { width: 100%; }
.btn-peq { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn-link { color: var(--pri); font-weight: 650; font-size: 15px; padding: 8px 0; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: #f2ece9; color: var(--txt); }
.chip-pri { background: var(--pri-claro); color: var(--pri-osc); }
.chip-acc { background: var(--acc-claro); color: #a65a14; }
.chip-ok { background: var(--ok-claro); color: #1f7a50; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ============ Hoy ============ */
.saludo { padding: 4px 4px 12px; }
.saludo h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.semana-tira { display: flex; gap: 6px; margin-top: 12px; }
.semana-tira .d {
  flex: 1; text-align: center; padding: 8px 0 6px; border-radius: 12px; background: #f2ece9;
  font-weight: 700; font-size: 14px; color: var(--muted);
}
.semana-tira .d small { display: block; font-size: 10.5px; font-weight: 600; }
.semana-tira .d.hecho { background: var(--ok-claro); color: #1f7a50; }
.semana-tira .d.hoy { outline: 2px solid var(--pri); outline-offset: -2px; color: var(--pri-osc); }

.hero { background: linear-gradient(140deg, #d9485f 0%, #e8705e 100%); color: #fff; border-radius: 22px; padding: 20px; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(217, 72, 95, 0.25); }
.hero .eti { font-size: 13px; font-weight: 700; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.06em; }
.hero h2 { font-size: 26px; font-weight: 800; margin: 4px 0 2px; }
.hero .foco { opacity: 0.95; font-size: 15px; }
.hero .meta { display: flex; gap: 14px; margin: 12px 0 16px; font-size: 14px; opacity: 0.95; }
.hero .btn-blanco { background: #fff; color: var(--pri-osc); width: 100%; }
.hero .btn-trans { background: rgba(255, 255, 255, 0.18); color: #fff; width: 100%; margin-top: 8px; }
.hero.descanso { background: linear-gradient(140deg, #4f8a8b 0%, #74a9a0 100%); box-shadow: 0 8px 24px rgba(79, 138, 139, 0.25); }
.hero.hecho { background: linear-gradient(140deg, #2e9e6a 0%, #57b884 100%); box-shadow: 0 8px 24px rgba(46, 158, 106, 0.25); }
.hero-mapa { background: rgba(255, 255, 255, 0.15); border-radius: 14px; padding: 6px; margin-top: 10px; }

.aviso { display: flex; gap: 12px; align-items: flex-start; }
.aviso .ico { font-size: 22px; line-height: 1; }
.consejo-dia { background: var(--acc-claro); }

/* ============ Sesión ============ */
.vista-sesion { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ses-cab {
  position: sticky; top: 0; z-index: 5; background: rgba(251, 247, 244, 0.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: calc(var(--safe-top) + 8px) 12px 10px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--linea);
}
.ses-cab .tit { flex: 1; min-width: 0; }
.ses-cab .tit h2 { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ses-cab .reloj { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--pri); font-size: 15px; }
.ses-cuerpo { max-width: 560px; margin: 0 auto; padding: 12px 14px calc(170px + var(--safe-bot)); }
.progreso-barra { height: 5px; background: var(--linea); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progreso-barra i { display: block; height: 100%; background: var(--pri); transition: width 0.3s; }

.bloque-tit { font-size: 13px; font-weight: 800; color: var(--pri-osc); text-transform: uppercase; letter-spacing: 0.07em; margin: 20px 4px 8px; }
.grupo { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); margin-bottom: 14px; overflow: hidden; }
.grupo-cab { padding: 10px 14px; background: #fcf3f0; border-bottom: 1px solid var(--linea); display: flex; gap: 10px; align-items: center; }
.grupo-cab .eti { background: var(--pri); color: #fff; font-weight: 800; font-size: 13px; border-radius: 8px; padding: 3px 8px; }
.grupo-cab .txt { font-size: 13px; color: var(--muted); line-height: 1.3; }
.ej { padding: 14px; border-bottom: 1px solid var(--linea); }
.ej:last-child { border-bottom: 0; }
.ej-cab { display: flex; gap: 12px; align-items: center; }
.miniatura { width: 62px; height: 62px; border-radius: 12px; object-fit: cover; background: #f2ece9; flex-shrink: 0; display: grid; place-items: center; font-size: 24px; overflow: hidden; }
.miniatura img { width: 100%; height: 100%; object-fit: cover; }
.ej-info { flex: 1; min-width: 0; }
.ej-nombre { font-weight: 750; font-size: 16px; line-height: 1.25; }
.ej-presc { font-size: 14px; color: var(--pri-osc); font-weight: 700; margin-top: 2px; }
.ej-ultima { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ej-acciones { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sugerencia { background: var(--ok-claro); color: #1f7a50; border-radius: 10px; padding: 7px 10px; font-size: 13.5px; font-weight: 700; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sugerencia button { background: #fff; color: #1f7a50; border-radius: 8px; padding: 4px 10px; font-weight: 700; font-size: 13px; }

.series { margin-top: 10px; display: grid; gap: 8px; }
.serie { display: grid; grid-template-columns: 30px 1fr 1fr 52px; gap: 8px; align-items: center; }
.serie.sinpeso { grid-template-columns: 30px 1fr 52px; }
.serie .num { width: 30px; height: 30px; border-radius: 50%; background: #f2ece9; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--muted); }
.campo { position: relative; }
.campo input {
  width: 100%; height: 46px; border: 1.5px solid var(--linea); border-radius: 12px; background: #fff;
  text-align: center; font-size: 18px; font-weight: 700; padding: 0 30px 0 8px; -webkit-appearance: none; appearance: none;
}
.campo input:focus { outline: none; border-color: var(--pri); }
.campo input.error { border-color: var(--pri); background: var(--pri-claro); animation: sacudir 0.3s; }
@keyframes sacudir { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.campo span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; font-weight: 600; }
.check { width: 52px; height: 46px; border-radius: 12px; background: #f2ece9; display: grid; place-items: center; }
.check svg { width: 24px; height: 24px; stroke: #b9b0b4; }
.serie.ok .check { background: var(--ok); }
.serie.ok .check svg { stroke: #fff; }
.serie.ok .num { background: var(--ok-claro); color: #1f7a50; }
.serie.ok input { background: #f6fbf8; border-color: #cfe9db; }

.activo-caja { margin: 0 14px 14px; background: var(--acc-claro); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.activo-caja .t { flex: 1; font-size: 14px; line-height: 1.3; }
.activo-caja .t b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #a65a14; }

.calenta { padding: 4px 14px 12px; }
.calenta label { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--linea); font-size: 15px; }
.calenta label:last-child { border-bottom: 0; }
.calenta input { width: 22px; height: 22px; accent-color: var(--ok); }

/* Temporizador de descanso */
.temporizador {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-bot)); z-index: 60;
  max-width: 540px; margin: 0 auto;
  background: #2a2730; color: #fff; border-radius: 20px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(140%); transition: transform 0.3s ease, visibility 0.3s; visibility: hidden;
}
.temporizador.visible { transform: translateY(0); visibility: visible; }
.temporizador.fin { background: var(--ok); }
.temp-fila { display: flex; align-items: center; gap: 12px; }
.temp-tiempo { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; min-width: 92px; }
.temp-txt { flex: 1; font-size: 14px; line-height: 1.3; }
.temp-txt b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.7; margin-bottom: 2px; }
.temp-botones { display: flex; gap: 8px; margin-top: 10px; }
.temp-botones button { flex: 1; background: rgba(255, 255, 255, 0.14); color: #fff; padding: 9px; border-radius: 11px; font-weight: 700; font-size: 14px; }
.temp-barra { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); margin-top: 10px; overflow: hidden; }
.temp-barra i { display: block; height: 100%; background: var(--acc); }

.ses-pie { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: 10px 14px calc(10px + var(--safe-bot)); background: linear-gradient(to top, var(--bg) 70%, rgba(251, 247, 244, 0)); }
.ses-pie .btn { max-width: 532px; margin: 0 auto; display: flex; }

/* ============ Modales ============ */
.modal-fondo { position: fixed; inset: 0; z-index: 80; background: rgba(30, 20, 25, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: aparecer 0.2s; }
.modal {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 24px 24px 0 0; padding: 8px 16px calc(24px + var(--safe-bot)); animation: subir 0.25s ease;
}
.modal-asa { width: 40px; height: 5px; border-radius: 3px; background: #d8cfcb; margin: 4px auto 10px; }
.modal-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.modal-cab h2 { font-size: 22px; font-weight: 800; }
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(40px); opacity: 0.6; } }

.fotos { position: relative; aspect-ratio: 3 / 2; border-radius: 16px; overflow: hidden; background: #f2ece9; }
.fotos img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fotos img.f1 { animation: alternar 2.4s infinite; }
@keyframes alternar { 0%, 40% { opacity: 0; } 50%, 90% { opacity: 1; } 100% { opacity: 0; } }
.fotos .etiq { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 8px; }
.sin-foto { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; font-size: 14px; }
.lista-pasos { margin: 0; padding-left: 22px; }
.lista-pasos li { margin-bottom: 7px; }
.lista-simple { margin: 0; padding-left: 20px; }
.lista-simple li { margin-bottom: 6px; }
.alt-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--linea); }
.alt-item:last-child { border-bottom: 0; }

/* ============ Formularios ============ */
.form-fila { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.form-campo label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 4px; }
.form-campo input, .form-campo select {
  width: 100%; height: 46px; border: 1.5px solid var(--linea); border-radius: 12px; background: #fff; padding: 0 12px; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.form-campo input:focus, .form-campo select:focus { outline: none; border-color: var(--pri); }

/* ============ Progreso ============ */
.resumen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.dato { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--sombra); }
.dato .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.dato .v small { font-size: 14px; font-weight: 700; color: var(--muted); }
.dato .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.dato .dif { font-size: 13px; font-weight: 700; margin-top: 2px; }
.baja { color: var(--ok); } .sube { color: var(--pri); } .igual { color: var(--muted); }
.grafica { width: 100%; height: auto; display: block; margin-top: 10px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 6px 4px; border-bottom: 1px solid var(--linea); }
.tabla td { padding: 9px 4px; border-bottom: 1px solid var(--linea); }
.tabla tr:last-child td { border-bottom: 0; }
.borrar { color: #c3b9bd; font-size: 18px; padding: 2px 8px; }
.selector { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.selector::-webkit-scrollbar { display: none; }
.selector button { flex-shrink: 0; padding: 7px 12px; border-radius: 999px; background: #f2ece9; font-size: 13.5px; font-weight: 650; }
.selector button.activo { background: var(--pri); color: #fff; }
.hist-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--linea); width: 100%; text-align: left; }
.hist-item:last-child { border-bottom: 0; }
.hist-fecha { width: 46px; text-align: center; flex-shrink: 0; }
.hist-fecha b { display: block; font-size: 20px; line-height: 1; }
.hist-fecha small { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 700; }

/* ============ Plan ============ */
.linea-tiempo { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin: 14px 0 6px; }
.linea-tiempo i { height: 12px; border-radius: 3px; position: relative; }
.linea-tiempo i.b1 { background: #f6c3ca; } .linea-tiempo i.b2 { background: #ef9aa6; } .linea-tiempo i.b3 { background: #e06c7f; } .linea-tiempo i.b4 { background: #c63f56; }
.linea-tiempo i.desc { background: #d8d0cc; }
.linea-tiempo i.actual { outline: 2.5px solid var(--txt); outline-offset: 1px; }
.linea-tiempo i.pasada { opacity: 0.45; }
.leyenda { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-weight: 650; }
.dia-item { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--card); border-radius: 16px; box-shadow: var(--sombra); margin-bottom: 10px; width: 100%; text-align: left; }
.dia-letra { width: 44px; height: 44px; border-radius: 13px; background: var(--pri-claro); color: var(--pri-osc); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.dia-item.hecho .dia-letra { background: var(--ok); color: #fff; }
.presc-tabla td:last-child { text-align: right; font-weight: 700; color: var(--pri-osc); }

/* ============ Consejos / nutrición ============ */
.acordeon { background: var(--card); border-radius: 16px; box-shadow: var(--sombra); margin-bottom: 10px; overflow: hidden; }
.acordeon summary { list-style: none; padding: 15px 16px; display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; cursor: pointer; }
.acordeon summary::-webkit-details-marker { display: none; }
.acordeon summary .ico { font-size: 22px; }
.acordeon summary .flecha { margin-left: auto; transition: transform 0.2s; color: var(--muted); }
.acordeon[open] summary .flecha { transform: rotate(90deg); }
.acordeon .cuerpo { padding: 0 16px 16px; }
.acordeon .cuerpo p { margin-bottom: 10px; color: #4a4550; }
.acordeon .cuerpo p:last-child { margin-bottom: 0; }
.obj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.obj { background: var(--card); border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--sombra); }
.obj b { display: block; font-size: 18px; font-weight: 800; color: var(--pri-osc); letter-spacing: -0.02em; }
.obj span { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.obj p { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.3; }
.plato-fila { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--linea); font-size: 14.5px; }
.plato-fila:last-child { border-bottom: 0; }
.plato-fila b { width: 96px; flex-shrink: 0; color: var(--pri-osc); }

/* ============ Mapa muscular ============ */
.mapa { width: 100%; max-width: 300px; display: block; margin: 0 auto; }
.mapa text { font-size: 12px; font-weight: 700; fill: var(--muted); }
.barra-mus { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.barra-mus .n { width: 150px; flex-shrink: 0; }
.barra-mus .b { flex: 1; height: 8px; border-radius: 4px; background: #f2ece9; overflow: hidden; }
.barra-mus .b i { display: block; height: 100%; background: var(--pri); border-radius: 4px; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 14px); transform: translate(-50%, -150%); z-index: 100;
  background: #2a2730; color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); transition: transform 0.3s ease; max-width: 90vw; text-align: center;
}
.toast.visible { transform: translate(-50%, 0); }

.vacio { text-align: center; color: var(--muted); padding: 18px 8px; font-size: 14.5px; }
