/* =============================================================
   pulso.css — Piezas propias de Pulso sobre el sistema de Pay.
   Sin estilos en línea en el HTML: la CSP solo admite hojas del propio origen.
   ============================================================= */

/* ===================== ACCESO ===================== */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: calc(var(--safe-top) + var(--space-8)) var(--space-6) calc(var(--safe-bottom) + var(--space-8));
}
.auth-inner { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--space-8); }
.auth-theme-toggle { position: fixed; top: calc(var(--safe-top) + var(--space-3)); right: var(--space-4); z-index: 2; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.auth-logo {
  width: 64px; height: 64px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; color: var(--on-primary); background: var(--primary-solid);
}
.auth-logo svg { width: 44px; height: 44px; }
.auth-title { font-size: var(--fs-xl); font-weight: var(--fw-extra); letter-spacing: -0.02em; margin: 0; }
.auth-subtitle { font-size: var(--fs-base); color: var(--text-muted); }
.auth-card { padding: var(--space-5); }
.auth-error { color: var(--danger); font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin-top: var(--space-3); }
.auth-error:empty { display: none; }
.field-password { position: relative; }
.field-password .form-control { padding-right: 52px; }
.toggle-password {
  position: absolute; top: 50%; right: 3px; transform: translateY(-50%);
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 1.1rem; border-radius: var(--radius-sm);
}
.toggle-password:hover { color: var(--primary); }
.bio-panel { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); text-align: center; }
.bio-panel p { color: var(--text-secondary); font-weight: var(--fw-semibold); }
.auth-actions { display: flex; flex-direction: column; gap: var(--space-3); width: 100%; }
.auth-foot { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.auth-foot button { color: var(--primary); font-weight: var(--fw-bold); font-size: inherit; min-height: 44px; }

/* ===================== INICIO ===================== */
.hero-value small { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text-muted); margin-left: 6px; letter-spacing: 0; }
.hero-sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* Fichas de métricas: icono con su color, valor y cobertura */
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.metric-tile {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); text-align: left; color: inherit; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.metric-head { display: flex; align-items: center; gap: var(--space-2); min-width: 0; min-height: 33px; }
.metric-head > span:not(.metric-icon) { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary); line-height: 1.25;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.metric-value { font-size: var(--fs-lg); font-weight: var(--fw-extra); letter-spacing: -0.01em; line-height: 1.15; }
.metric-value small { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); margin-left: 2px; }
.metric-note { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-semibold); }
.metric-note.is-gap { color: var(--warning-text); }

/* Icono en su contenedor, con la pareja tinta + fondo suave de cada métrica */
.metric-icon {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
  background: var(--metric-none-bg); color: var(--metric-none);
}
.entry-icon.metric-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem; }
[data-metric="body"] { --m: var(--metric-body); --m-bg: var(--metric-body-bg); }
[data-metric="sleep"] { --m: var(--metric-sleep); --m-bg: var(--metric-sleep-bg); }
[data-metric="activity"] { --m: var(--metric-activity); --m-bg: var(--metric-activity-bg); }
[data-metric="energy"] { --m: var(--metric-energy); --m-bg: var(--metric-energy-bg); }
[data-metric="heart"] { --m: var(--metric-heart); --m-bg: var(--metric-heart-bg); }
[data-metric="food"] { --m: var(--metric-food); --m-bg: var(--metric-food-bg); }
[data-metric="water"] { --m: var(--metric-water); --m-bg: var(--metric-water-bg); }
[data-metric="fiber"] { --m: var(--metric-fiber); --m-bg: var(--metric-fiber-bg); }
[data-metric] .metric-icon, .metric-icon[data-metric] { background: var(--m-bg); color: var(--m); }

/* Pendientes */
.task-check {
  width: 28px; height: 28px; border-radius: var(--radius-full); flex-shrink: 0;
  border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center;
  color: var(--on-primary); font-size: 0.95rem;
}
.settings-row.is-done .task-check { background: var(--primary-solid); border-color: var(--primary-solid); }
.settings-row.is-done strong { color: var(--text-muted); text-decoration: line-through; }

.insight-list { display: flex; flex-direction: column; gap: var(--space-3); }
.insight-list p { font-size: var(--fs-sm); color: var(--text-secondary); }
.page-foot { margin-top: var(--space-8); text-align: center; font-size: var(--fs-xs); color: var(--text-muted); }

/* ===================== REGISTROS ===================== */
.date-badge {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  background: var(--surface-2); color: var(--text);
}
.date-badge strong { font-size: var(--fs-md); font-weight: var(--fw-extra); }
.date-badge small { font-size: 0.625rem; font-weight: var(--fw-bold); text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }
.entry.is-today .date-badge { background: var(--primary-soft); color: var(--primary-ink); }
/* Rows are buttons here (Pay used divs): undo the button's centred text. */
button.entry { width: 100%; text-align: left; background: none; color: inherit; }
.entry-tags { display: flex; gap: 4px; flex-shrink: 0; }

/* Detalle de un día */
.detail-group + .detail-group { margin-top: var(--space-5); }
.detail-group .kv-row, .reading-list .kv-row, [data-platform] .kv-row { align-items: center; }
.kv-source { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-semibold); margin-left: var(--space-2); }
.note-text { font-size: var(--fs-sm); color: var(--text-secondary); white-space: pre-line; overflow-wrap: anywhere; }

/* ===================== ALTA DEL DÍA ===================== */
.field-row > span:first-child { width: 132px; }
.field-row .unit { width: auto; flex-shrink: 0; color: var(--text-muted); font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.field-row input[type="number"] { text-align: right; -moz-appearance: textfield; }
.field-row input::-webkit-outer-spin-button, .field-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field-row.stacked { flex-direction: column; align-items: stretch; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.field-row.stacked > span:first-child { width: auto; }
.field-row .segmented { flex: 1; }
.field-row .segmented button { min-height: 40px; padding: 6px 4px; }
.field-row textarea { width: 100%; min-height: 88px; border: 0; outline: 0; background: transparent; resize: vertical; font: inherit; color: var(--text); }
.form-group-title { margin: var(--space-5) var(--space-1) var(--space-2); }

/* ===================== TENDENCIAS ===================== */
.chart-card { padding: var(--space-4); }
.chart-box { position: relative; height: 220px; margin-top: var(--space-3); }
.chart-box.tall { height: 260px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--dot, var(--primary)); }
.chart-legend i.is-line { width: 16px; height: 3px; border-radius: 2px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.chart-note { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-muted); white-space: nowrap; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
.stat-grid .stat-value small { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); }
.stat-hint { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-semibold); }
.period-row { display: flex; gap: var(--space-3); align-items: center; margin-bottom: var(--space-4); }
.period-row .segmented { flex: 1; }

/* ===================== RELOJ ===================== */
.indicator-list .settings-row { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
.status-dot {
  width: 12px; height: 12px; border-radius: var(--radius-full); flex-shrink: 0; margin: 5px 10px 0;
  background: var(--border-strong);
}
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warning); }
.status-dot.bad { background: var(--danger); }
.indicator-list .settings-text small { white-space: normal; }
.reading-list .kv-value small { color: var(--text-muted); font-weight: var(--fw-semibold); }
.action-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.probe-text { font-size: var(--fs-sm); white-space: pre-line; color: var(--text-secondary); }

/* ===================== PERFIL ===================== */
.secret-box {
  white-space: pre-wrap; word-break: break-all;
  font-size: var(--fs-xs); line-height: 1.5;
  background: var(--surface-2); color: var(--text);
  border-radius: var(--radius-sm); padding: var(--space-3);
}
.sheet-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.sheet-hint { font-size: var(--fs-sm); color: var(--text-secondary); }

/* ===================== ESTADOS DE CARGA ===================== */
.skeleton.sk-icon { width: 40px; height: 40px; flex-shrink: 0; }
.skeleton.sk-line { flex: 1; height: 14px; }
.skeleton.sk-tile { height: 112px; border-radius: var(--radius-lg); }
.skeleton.sk-hero { width: 60%; height: 52px; }
/* El spinner toma el color del texto del botón: en oscuro el índigo es claro y el blanco no se vería. */
.btn .spinner { border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }

/* Etiqueta solo para lectores de pantalla */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.choice-hint { display: block; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); }

/* ===================== ACTUALIZACIÓN DE LA APP ===================== */
.update-banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
  padding: var(--space-4); margin-bottom: var(--space-5);
  border-radius: var(--radius-lg); background: var(--primary-solid); color: var(--on-primary);
  box-shadow: 0 12px 28px -10px var(--glow), var(--shadow-primary);
}
.update-icon { font-size: 1.75rem; line-height: 1; animation: update-nudge 2.4s ease-in-out 0.6s 2; }
.update-text strong { display: block; font-size: var(--fs-md); font-weight: var(--fw-extra); }
.update-text small { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.update-close { width: 44px; height: 44px; border-radius: var(--radius-full); color: inherit; display: flex; align-items: center; justify-content: center; }
.update-action { grid-column: 1 / -1; width: 100%; background: var(--on-primary); color: var(--primary-solid); }
@keyframes update-nudge { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(3px); } 60% { transform: translateY(-1px); } }

/* Dot on Perfil in the bottom bar while an update waits */
.nav-item { position: relative; }
.nav-dot {
  position: absolute; top: 4px; left: calc(50% + 12px);
  width: 10px; height: 10px; border-radius: var(--radius-full);
  background: var(--danger); border: 2px solid var(--surface);
}
.settings-row.is-update .settings-icon { background: var(--primary-solid); color: var(--on-primary); }
.settings-row.is-update strong { color: var(--primary); }

/* Sync button turns while it works */
.round-button.is-spinning i { animation: spin 0.9s linear infinite; display: inline-block; }

/* ===================== PESO EN INICIO ===================== */
.weight-card { padding: var(--space-5); }
.weight-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.weight-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.weight-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-semibold); }
.weight-card .hero-value { font-size: var(--fs-2xl); font-weight: var(--fw-extra); letter-spacing: -0.03em; line-height: 1.1; }
.weight-delta {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; margin-top: 2px;
  padding: 6px 12px; border-radius: var(--radius-full);
  background: var(--primary-soft); color: var(--primary-ink);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); white-space: nowrap;
}
.weight-sub { margin-top: var(--space-2); font-size: var(--fs-sm); color: var(--text-secondary); }
.weight-chart { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.weight-chart-head { display: flex; justify-content: space-between; align-items: center; }
.weight-chart-head span { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.weight-chart-box { height: 140px; margin-top: var(--space-1); }

/* Sincronizar todo, bajo Conexiones en Perfil */
.sync-all { margin-top: var(--space-3); }
.sync-all-hint { margin-top: var(--space-2); text-align: center; }
.btn.is-spinning i { animation: spin 0.9s linear infinite; display: inline-block; }

/* ===================== ENTRENAMIENTOS ===================== */
.chip-count { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); }
.chip.active .chip-count { color: inherit; opacity: 0.8; }
.workout-hero { display: flex; align-items: center; gap: var(--space-3); }
.workout-hero .workout-hero-icon { width: 52px; height: 52px; border-radius: 16px; font-size: 1.5rem; }
.workout-hero strong { display: block; font-size: var(--fs-xl); font-weight: var(--fw-extra); letter-spacing: -0.02em; line-height: 1.15; }
.workout-hero small { display: block; font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-semibold); }
.workout-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.workout-stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  padding: var(--space-3) var(--space-2); border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
}
.workout-stat-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.workout-stat-label i { font-size: 0.7rem; color: var(--primary); margin-left: 2px; }
.workout-stat-value { font-size: var(--fs-lg); font-weight: var(--fw-extra); letter-spacing: -0.01em; }
.workout-stat-value small { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-muted); margin-left: 3px; }
.workout-stat.is-empty .workout-stat-value { color: var(--text-muted); font-weight: var(--fw-bold); }
.workout-note { white-space: pre-wrap; padding: var(--space-3) var(--space-4); border-radius: 16px; background: var(--surface-2); color: var(--text-secondary); }
.inside { display: flex; flex-direction: column; gap: var(--space-4); }
.inside:empty { display: none; }
.inside-skeleton { height: 220px; border-radius: 16px; }
.inside-section {
  padding: var(--space-3) var(--space-4) var(--space-4); border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
}
.inside-title { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--fs-md); font-weight: var(--fw-bold); }
.inside-title .metric-icon { width: 28px; height: 28px; border-radius: 9px; font-size: 0.9rem; }
.inside-summary { margin: var(--space-1) 0 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.inside-chart { height: 180px; }
.splits { margin-top: var(--space-3); font-variant-numeric: tabular-nums; }
.split-row { display: grid; grid-template-columns: 2.6em minmax(0, 1fr) 3.2em; align-items: center; gap: var(--space-2); min-height: 32px; }
.split-row + .split-row { border-top: 1px solid var(--border); }
.split-head { min-height: 24px; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.split-km { font-weight: var(--fw-bold); }
.split-pace { position: relative; display: flex; align-items: center; min-height: 24px; }
.split-bar {
  position: absolute; inset: 3px auto 3px 0; width: var(--share, 0%); border-radius: 6px;
  background: var(--metric-activity-bg);
}
.split-value { position: relative; padding-left: var(--space-2); font-weight: var(--fw-semibold); }
.split-hr, .split-head > :last-child { text-align: right; }
.duration-inputs { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.field-row .duration-inputs input { width: 2.6em; flex: 0 0 auto; text-align: right; }
.sheet-footer > .action-stack { flex: 1; }

/* ===================== COMPARAR ENTRENAMIENTOS ===================== */
.tab-scroll { overflow-x: auto; scrollbar-width: none; }
.tab-scroll::-webkit-scrollbar { display: none; }
.tab-scroll { gap: 2px; }
.tab-scroll button { flex: 1 0 auto; padding: 8px 6px; }
@media (max-width: 380px) { .tab-scroll button { font-size: var(--fs-xs); } }

.compare-builder { display: flex; flex-direction: column; gap: var(--space-3); }
.compare-builder .chip-row, .sheet-body .chip-row { margin: 0 calc(-1 * var(--space-4)); padding: var(--space-1) var(--space-4); }
@media (min-width: 600px) { .compare-builder .chip-row, .sheet-body .chip-row { margin: 0; padding: var(--space-1) 0; } }
.compare-picked { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.settings-row.is-current { background: var(--primary-soft); }
.settings-row.is-current .settings-chevron { color: var(--primary); }

.stat-value.stat-text { font-size: var(--fs-base); line-height: 1.3; }
.stat-value.is-better { color: var(--success); }
.stat-value.is-worse { color: var(--warning-text); }

.compare-scroll { overflow-x: auto; margin: 0 calc(var(--space-4) * -1); padding: 0 var(--space-4); }
.compare-scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.compare-table { border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); min-width: 100%; }
.compare-table th, .compare-table td { padding: var(--space-2) var(--space-3); text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.compare-table tbody tr:last-child > * { border-bottom: none; }
.compare-table th[scope="row"] { position: sticky; left: 0; z-index: 1; text-align: left; font-weight: var(--fw-semibold); color: var(--text-secondary); background: var(--surface); }
.compare-table thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.compare-table thead button { display: flex; flex-direction: column; align-items: flex-end; margin-left: auto; min-height: 40px; justify-content: center; color: var(--primary); font-weight: var(--fw-bold); }
.compare-table thead button small { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-semibold); }
.compare-table td.is-best { font-weight: var(--fw-extra); color: var(--text); }
.compare-table td.is-best::before { content: "\2605"; color: var(--primary); margin-right: 4px; font-size: 0.7rem; }

.pick-row { width: 100%; text-align: left; }
.pick-check {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border-strong);
  display: grid; place-items: center; color: transparent; font-size: 0.95rem; transition: background var(--transition-fast), border-color var(--transition-fast);
}
.pick-row.is-selected { background: var(--primary-soft); }
.pick-row.is-selected .pick-check { background: var(--primary-solid); border-color: var(--primary-solid); color: var(--on-primary); }

.compare-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-3));
  width: min(calc(100% - var(--space-5) * 2), 560px);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.18));
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary);
}
.compare-bar[hidden] { display: none; }
.is-selecting .app-shell { padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 96px); }

/* Inicio: último entrenamiento */
.workout-card { padding: 0; overflow: hidden; }
.workout-card.is-empty { padding: var(--space-4); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--text-secondary); }
.workout-card-main { display: block; width: 100%; text-align: left; padding: var(--space-4); color: inherit; }
.workout-card-main:active { background: var(--surface-hover); }
.workout-card-head { display: flex; align-items: center; gap: var(--space-3); }
.workout-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.workout-card-title strong { font-size: var(--fs-md); font-weight: var(--fw-extra); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workout-card-title small { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-semibold); }
.workout-card-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--space-2); margin-top: var(--space-4); }
.workout-card-figures > span { display: flex; flex-direction: column; min-width: 0; }
.workout-card-figures small { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-muted); }
.workout-card-figures strong { font-size: var(--fs-base); font-weight: var(--fw-extra); white-space: nowrap; }
.workout-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary);
}
