/* ==========================================================================
   Pulso · sistema de diseño
   Capa propia sobre AdminLTE 3 / Bootstrap 4. No se edita ninguna dependencia:
   todo ajuste se hace aquí, a partir de los tokens de :root.
   ========================================================================== */

:root {
    /* Color de acción (violeta) */
    --p-primary: #6a4be3;
    --p-primary-strong: #5436c9;
    --p-primary-text: #5a3bd1;
    --p-primary-soft: #efeaff;
    --p-primary-softer: #f7f4ff;

    /* Cardio y potencia (naranja) */
    --p-cardio: #f0772b;
    --p-cardio-text: #a94c0c;
    --p-cardio-soft: #fff0e5;

    /* Objetivo cumplido (verde) y errores (rojo, sólo para fallos) */
    --p-success: #2c9a5a;
    --p-success-text: #1d7442;
    --p-success-soft: #e5f5eb;
    --p-danger: #c8323f;
    --p-danger-text: #a8202d;
    --p-danger-soft: #fdecee;
    --p-warning-soft: #fff7df;
    --p-warning-text: #7a5600;

    /* Neutros */
    --p-bg: #f5f5f9;
    --p-surface: #ffffff;
    --p-surface-2: #fafafc;
    --p-ink: #1d1e29;
    --p-ink-2: #464858;
    --p-muted: #636575;
    --p-border: #e4e5ed;
    --p-border-strong: #cfd1dc;
    --p-sidebar: #15161f;
    --p-sidebar-ink: #b8b9c6;

    /* Tipografía */
    --p-font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --p-text-xs: .8125rem;   /* 13px: mínimo para metadatos */
    --p-text-sm: .875rem;    /* 14px */
    --p-text-md: 1rem;       /* 16px: cuerpo */
    --p-text-lg: 1.125rem;
    --p-text-xl: 1.375rem;
    --p-text-display: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem);

    /* Forma, profundidad y espacio */
    --p-radius-sm: 8px;
    --p-radius: 12px;
    --p-radius-lg: 18px;
    --p-radius-pill: 999px;
    --p-shadow-sm: 0 1px 2px rgba(22, 20, 40, .05);
    --p-shadow: 0 1px 2px rgba(22, 20, 40, .04), 0 6px 20px rgba(22, 20, 40, .06);
    --p-shadow-lg: 0 20px 60px rgba(22, 20, 40, .18);
    --p-space-1: 4px;
    --p-space-2: 8px;
    --p-space-3: 12px;
    --p-space-4: 16px;
    --p-space-5: 24px;
    --p-space-6: 32px;
    --p-touch: 44px;
    --p-focus: 0 0 0 3px #fff, 0 0 0 6px var(--p-primary);
    --p-tabbar-h: 64px;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body.pulso { background: var(--p-bg); color: var(--p-ink); font-family: var(--p-font); font-size: var(--p-text-md); line-height: 1.5; }
.pulso h1, .pulso h2, .pulso h3, .pulso h4, .pulso h5 { font-family: var(--p-font); color: var(--p-ink); letter-spacing: -.01em; }
/* Color de enlace sólo para enlaces de texto: los botones-enlace usan el color de su variante. */
/* :where() deja la prioridad mínima: cualquier componente (menús, pestañas, segmentos) la sobrescribe. */
:where(.pulso) :where(a:not(.btn)) { color: var(--p-primary-text); }
:where(.pulso) :where(a:not(.btn)):hover { color: var(--p-primary-strong); }
.text-muted { color: var(--p-muted) !important; }
.small, small { font-size: var(--p-text-sm); }
.tabular { font-variant-numeric: tabular-nums; }

:focus { outline: none; }
:focus-visible, .btn:focus-visible, .form-control:focus-visible, .custom-select:focus-visible { outline: none !important; box-shadow: var(--p-focus) !important; border-radius: var(--p-radius-sm); }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 2000; padding: 10px 16px; border-radius: var(--p-radius-sm); background: var(--p-ink); color: #fff !important; font-weight: 700; }
.skip-link:focus { top: 12px; }
main:focus { box-shadow: none !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Botones ---------- */
.btn { min-height: var(--p-touch); padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--p-radius-sm); font-weight: 700; font-size: var(--p-text-sm); line-height: 1.2; }
.btn-sm { min-height: 36px; padding: 6px 12px; }
.btn-lg { min-height: 56px; padding: 14px 24px; font-size: var(--p-text-md); border-radius: var(--p-radius); }
.btn-primary, .btn-purple { border-color: var(--p-primary); background: var(--p-primary); color: #fff; }
.btn-primary:hover, .btn-purple:hover, .btn-primary:focus, .btn-purple:focus, .btn-primary:not(:disabled):active { border-color: var(--p-primary-strong) !important; background: var(--p-primary-strong) !important; color: #fff; }
.btn-cardio { border-color: var(--p-cardio); background: var(--p-cardio); color: #1d1206; }
.btn-cardio:hover, .btn-cardio:focus { background: #dc6517; border-color: #dc6517; color: #120a03; }
.btn-success { border-color: var(--p-success); background: var(--p-success); }
.btn-danger { border-color: var(--p-danger); background: var(--p-danger); }
.btn-outline-secondary { border-color: var(--p-border-strong); background: var(--p-surface); color: var(--p-ink-2); }
.btn-outline-secondary:hover, .btn-outline-secondary:focus { border-color: var(--p-muted); background: var(--p-surface-2); color: var(--p-ink); }
.btn-outline-danger { border-color: #e7b6bc; color: var(--p-danger-text); background: var(--p-surface); }
.btn-outline-danger:hover { background: var(--p-danger-soft); color: var(--p-danger-text); border-color: var(--p-danger); }
.btn-ghost { border: 0; background: transparent; color: var(--p-ink-2); }
.btn-ghost:hover { background: var(--p-primary-softer); color: var(--p-primary-text); }
.btn-icon { width: var(--p-touch); padding: 0; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: p-spin .7s linear infinite; }
@keyframes p-spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--p-space-2); }

/* ---------- Estructura AdminLTE ---------- */
.main-header { min-height: 60px; background: var(--p-surface); border-bottom: 1px solid var(--p-border) !important; }
.main-header .nav-link { min-height: var(--p-touch); display: flex; align-items: center; gap: 8px; color: var(--p-ink-2); }
.header-date { font-size: var(--p-text-sm); color: var(--p-muted) !important; }
.header-logout { min-height: var(--p-touch); }
.mobile-brand { font-weight: 800; font-size: 1.2rem; color: var(--p-ink) !important; letter-spacing: -.02em; }
.brand-mark { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: linear-gradient(140deg, var(--p-primary), #9a6cf5 60%, var(--p-cardio)); color: #fff; font-size: 15px; flex: 0 0 32px; }
.main-sidebar { background: var(--p-sidebar); }
.main-sidebar .brand-link { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid #262735 !important; color: #fff !important; }
.main-sidebar .brand-text { font-weight: 800; font-size: 1.35rem; letter-spacing: -.03em; }
.sidebar { padding: 0 10px; }
.user-panel { margin: 16px 6px 12px; padding: 0 0 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #262735 !important; overflow: hidden; }
.user-panel .info { padding: 0; }
.user-panel .user-name { color: #fff; font-weight: 700; font-size: var(--p-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.user-panel small { color: var(--p-sidebar-ink); font-size: var(--p-text-xs); }
.profile-avatar { width: 36px; height: 36px; flex: 0 0 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #2c2645; color: #d8ccff; font-weight: 800; }
.nav-sidebar .nav-item { margin-bottom: 4px; }
.nav-sidebar .nav-link { min-height: var(--p-touch); display: flex; align-items: center; border-radius: var(--p-radius-sm) !important; color: var(--p-sidebar-ink) !important; font-weight: 600; }
.nav-sidebar .nav-link p { font-size: var(--p-text-sm); }
.nav-sidebar .nav-link:hover { background: #20212d !important; color: #fff !important; }
.nav-sidebar .nav-link.active { background: #2a2547 !important; color: #fff !important; box-shadow: inset 3px 0 0 #a58bff !important; }
.sidebar-note { margin: 24px 6px 0; padding: 14px; display: flex; flex-direction: column; gap: 4px; border-radius: var(--p-radius); background: #1d1e2a; color: #e8e6f2; font-size: var(--p-text-sm); }
.sidebar-note span { color: var(--p-sidebar-ink); font-size: var(--p-text-xs); }
.sidebar-collapse .sidebar-note, .sidebar-collapse .user-panel .info { display: none; }
.content-wrapper { background: var(--p-bg); }
.page-container { max-width: 1440px; padding: var(--p-space-5) var(--p-space-5) var(--p-space-6); }

/* ---------- Tipografía de página ---------- */
.page-head { margin-bottom: var(--p-space-5); display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--p-space-4); }
.page-title { margin: 0; font-size: var(--p-text-display); font-weight: 800; line-height: 1.15; letter-spacing: -.025em; }
.page-title .accent { color: var(--p-primary-text); }
.page-lead { margin: 6px 0 0; color: var(--p-ink-2); max-width: 60ch; }
.eyebrow, .card-kicker { margin: 0 0 4px; color: var(--p-primary-text); font-size: var(--p-text-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.breadcrumb-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--p-touch); margin-bottom: 4px; font-weight: 700; font-size: var(--p-text-sm); }

/* ---------- Tarjetas ---------- */
.p-card { margin-bottom: var(--p-space-4); border: 1px solid var(--p-border); border-radius: var(--p-radius-lg); background: var(--p-surface); box-shadow: var(--p-shadow); }
.p-card-header { padding: 18px 20px 6px; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--p-space-3); }
.p-card-title { margin: 0; font-size: var(--p-text-lg); font-weight: 800; }
.p-card-body { padding: 12px 20px 20px; }
.p-card-footer { padding: 14px 20px; border-top: 1px solid var(--p-border); }
.card { border-radius: var(--p-radius-lg); }

/* ---------- Métricas del resumen ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--p-space-4); margin-bottom: var(--p-space-4); }
.stat { position: relative; padding: 18px 20px; border: 1px solid var(--p-border); border-radius: var(--p-radius-lg); background: var(--p-surface); box-shadow: var(--p-shadow); }
.stat-label { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; color: var(--p-ink-2); font-size: var(--p-text-sm); font-weight: 700; }
.stat-icon { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--p-primary-soft); color: var(--p-primary-text); font-size: 14px; }
.stat-icon.cardio { background: var(--p-cardio-soft); color: var(--p-cardio-text); }
.stat-icon.success { background: var(--p-success-soft); color: var(--p-success-text); }
.stat-value { margin: 0; font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-value small { font-size: var(--p-text-sm); font-weight: 700; color: var(--p-muted); letter-spacing: 0; }
.stat-note { margin: 8px 0 0; color: var(--p-muted); font-size: var(--p-text-xs); }
.stat-note strong { color: var(--p-ink-2); }
.goal-meter { margin-top: 10px; height: 8px; border-radius: var(--p-radius-pill); background: var(--p-primary-soft); overflow: hidden; }
.goal-meter span { display: block; height: 100%; border-radius: inherit; background: var(--p-primary); }
.goal-meter.done span { background: var(--p-success); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--p-radius-pill); font-size: var(--p-text-xs); font-weight: 700; background: var(--p-surface-2); color: var(--p-ink-2); border: 1px solid var(--p-border); white-space: nowrap; }
.pill-primary { background: var(--p-primary-soft); color: var(--p-primary-text); border-color: transparent; }
.pill-cardio { background: var(--p-cardio-soft); color: var(--p-cardio-text); border-color: transparent; }
.pill-success { background: var(--p-success-soft); color: var(--p-success-text); border-color: transparent; }
.pill-danger { background: var(--p-danger-soft); color: var(--p-danger-text); border-color: transparent; }
.pill-warning { background: var(--p-warning-soft); color: var(--p-warning-text); border-color: transparent; }

/* ---------- Acciones rápidas ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--p-space-3); margin-bottom: var(--p-space-4); }
.quick-action { min-height: 72px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--p-border); border-radius: var(--p-radius); background: var(--p-surface); color: var(--p-ink) !important; text-align: left; font-weight: 700; box-shadow: var(--p-shadow-sm); cursor: pointer; width: 100%; }
.quick-action:hover { border-color: #c9bdf7; background: var(--p-primary-softer); text-decoration: none; }
.quick-action small { display: block; color: var(--p-muted); font-weight: 500; font-size: var(--p-text-xs); }
.quick-action .qa-icon { width: 42px; height: 42px; flex: 0 0 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--p-primary-soft); color: var(--p-primary-text); font-size: 17px; }
.quick-action.cardio .qa-icon { background: var(--p-cardio-soft); color: var(--p-cardio-text); }

/* ---------- Gráfico semanal ---------- */
.week-chart { height: 210px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(6px, 2vw, 18px); align-items: end; padding-top: 8px; border-bottom: 1px solid var(--p-border); background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), #eef0f5 calc(25% - 1px), #eef0f5 25%); }
.chart-day { height: 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.chart-value { min-height: 18px; color: var(--p-ink-2); font-size: var(--p-text-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-track { width: min(100%, 36px); flex: 1; display: flex; align-items: flex-end; }
.chart-bar { width: 100%; min-height: 0; border-radius: 6px 6px 2px 2px; background: #c8bbfa; }
.chart-bar.today { background: var(--p-primary); }
.chart-bar.future { background: transparent; border: 1px dashed var(--p-border-strong); border-bottom: 0; height: 8px !important; }
.chart-labels { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(6px, 2vw, 18px); margin-top: 8px; }
.chart-label { color: var(--p-muted); font-size: var(--p-text-xs); font-weight: 700; text-align: center; }
.chart-label.today { color: var(--p-primary-text); }
.chart-legend { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 14px; color: var(--p-muted); font-size: var(--p-text-xs); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }

/* ---------- Listas (historial, próximos) ---------- */
.list-row { min-height: 64px; padding: 10px 0; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--p-border); color: inherit !important; }
a.list-row:hover { text-decoration: none; background: var(--p-primary-softer); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--p-radius-sm); }
.list-row:last-child { border-bottom: 0; }
.type-icon { width: 40px; height: 40px; flex: 0 0 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--p-primary-soft); color: var(--p-primary-text); }
.type-icon.cardio { background: var(--p-cardio-soft); color: var(--p-cardio-text); }
.list-main { min-width: 0; flex: 1; }
.list-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--p-text-md); }
.list-main small { display: block; margin-top: 2px; color: var(--p-muted); font-size: var(--p-text-xs); }
.list-metric { flex: 0 0 auto; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.list-metric small { display: block; color: var(--p-muted); font-weight: 600; font-size: var(--p-text-xs); }
.date-tile { width: 48px; height: 52px; flex: 0 0 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12px; background: var(--p-primary-soft); color: var(--p-primary-text); line-height: 1.1; }
.date-tile strong { font-size: 1.2rem; font-weight: 800; }
.date-tile span { font-size: 11px; font-weight: 800; text-transform: uppercase; }

/* ---------- Estados vacíos y avisos ---------- */
.empty-state { padding: 28px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; color: var(--p-ink-2); }
.empty-state .empty-icon { width: 56px; height: 56px; display: inline-flex; align-items: center; justify-content: center; border-radius: 18px; background: var(--p-primary-soft); color: var(--p-primary-text); font-size: 22px; margin-bottom: 4px; }
.empty-state strong { color: var(--p-ink); font-size: var(--p-text-lg); }
.empty-state p { margin: 0; max-width: 42ch; font-size: var(--p-text-sm); }
.alert-pulso { margin-bottom: var(--p-space-4); padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px; border: 1px solid transparent; border-radius: var(--p-radius); font-size: var(--p-text-sm); }
.alert-pulso > i { margin-top: 3px; }
.alert-pulso > span, .alert-pulso > div { flex: 1; }
.alert-pulso-success { background: var(--p-success-soft); border-color: #bfe5cd; color: #14532f; }
.alert-pulso-danger { background: var(--p-danger-soft); border-color: #f3c2c8; color: #7c1520; }
.alert-pulso-info { background: var(--p-primary-softer); border-color: #ddd3fb; color: #33236f; }
.alert-pulso-warning { background: var(--p-warning-soft); border-color: #f0dc9e; color: #5d4200; }
.alert-close { width: 36px; height: 36px; margin: -8px -8px -8px 0; border: 0; border-radius: var(--p-radius-sm); background: transparent; color: inherit; opacity: .7; }
.alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.offline-banner { position: sticky; top: 0; z-index: 1030; padding: 12px 20px; display: flex; gap: 10px; align-items: center; background: #2a2b38; color: #fff; font-size: var(--p-text-sm); }
.offline-banner[hidden] { display: none; }

/* ---------- Formularios ---------- */
.pulso label, .pulso .col-form-label { margin-bottom: 6px; color: var(--p-ink); font-size: var(--p-text-sm); font-weight: 700; }
.pulso .form-control, .pulso .custom-select { min-height: var(--p-touch); height: auto; padding: 10px 12px; border: 1px solid var(--p-border-strong); border-radius: var(--p-radius-sm); color: var(--p-ink); font-size: var(--p-text-md); background-color: var(--p-surface); }
.pulso textarea.form-control { min-height: 88px; }
.pulso .form-control:focus, .pulso .custom-select:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(106, 75, 227, .2); }
.pulso .form-control.is-invalid { border-color: var(--p-danger); }
.invalid-feedback { color: var(--p-danger-text); font-size: var(--p-text-xs); font-weight: 600; }
.form-hint { margin-top: 6px; display: block; color: var(--p-muted); font-size: var(--p-text-xs); }
.optional { color: var(--p-muted); font-weight: 500; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--p-space-4); }
.field-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fieldset-pulso { margin: 4px 0 16px; padding: 14px 16px 2px; border: 1px solid var(--p-border); border-radius: var(--p-radius); background: var(--p-surface-2); }
.fieldset-pulso legend { width: auto; margin: 0; padding: 0 6px; font-size: var(--p-text-sm); font-weight: 800; color: var(--p-cardio-text); }
.segmented { display: inline-flex; padding: 4px; border-radius: var(--p-radius); background: #ecedf3; gap: 4px; }
.segmented a { min-height: 40px; padding: 8px 16px; display: inline-flex; align-items: center; border-radius: 9px; color: var(--p-ink-2); font-weight: 700; font-size: var(--p-text-sm); }
.segmented a:hover { text-decoration: none; color: var(--p-ink); }
.segmented a[aria-current="true"] { background: var(--p-surface); color: var(--p-primary-text); box-shadow: var(--p-shadow-sm); }
.filters { display: flex; flex-wrap: wrap; gap: var(--p-space-3); align-items: flex-end; }
.filters .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------- Modales ---------- */
.modal-content { border: 0; border-radius: var(--p-radius-lg); box-shadow: var(--p-shadow-lg); }
.modal-header { padding: 18px 20px 10px; align-items: flex-start; border-bottom: 0; }
.modal-title { font-size: var(--p-text-xl); font-weight: 800; }
.modal-header .close { width: var(--p-touch); height: var(--p-touch); margin: -10px -10px -10px auto; padding: 0; opacity: .7; font-size: 18px; }
.modal-body { padding: 8px 20px 12px; }
.modal-footer { padding: 12px 20px 18px; border-top: 0; gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-sm-pulso { max-width: 420px; }

/* ---------- Detalles (actividad, plan, entrenamiento) ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--p-space-3); margin: 0; }
.detail-grid > div { padding: 14px; border: 1px solid var(--p-border); border-radius: var(--p-radius); background: var(--p-surface-2); }
.detail-grid dt { margin-bottom: 4px; color: var(--p-muted); font-size: var(--p-text-xs); font-weight: 700; }
.detail-grid dd { margin: 0; font-size: var(--p-text-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.detail-grid dd small { font-size: var(--p-text-xs); color: var(--p-muted); font-weight: 600; display: block; }
.power-trace { width: 100%; height: 140px; display: block; }

/* ---------- Planificador ---------- */
.planner-toolbar { padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--p-space-3); border-bottom: 1px solid var(--p-border); }
.period-nav { display: flex; align-items: center; gap: 4px; }
.period-nav h2 { min-width: 180px; margin: 0; font-size: var(--p-text-lg); font-weight: 800; text-align: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday { padding: 10px 8px; border-bottom: 1px solid var(--p-border); color: var(--p-muted); font-size: var(--p-text-xs); font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.calendar-day { min-width: 0; padding: 8px; border-right: 1px solid var(--p-border); border-bottom: 1px solid var(--p-border); background: var(--p-surface); display: flex; flex-direction: column; gap: 6px; }
.calendar-day:nth-child(7n) { border-right: 0; }
.week-view .calendar-day { min-height: 220px; }
.month-view .calendar-day { min-height: 132px; }
.calendar-day.outside-month { background: var(--p-surface-2); }
.calendar-day.outside-month .day-number { color: #9a9cab; }
.calendar-day.is-today { background: var(--p-primary-softer); box-shadow: inset 0 3px 0 var(--p-primary); }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.day-number { font-weight: 800; color: var(--p-ink-2); font-variant-numeric: tabular-nums; }
.day-name-mobile { display: none; }
.today-tag { padding: 1px 8px; border-radius: var(--p-radius-pill); background: var(--p-primary); color: #fff; font-size: 11px; font-weight: 800; }
.day-add { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px dashed var(--p-border-strong); border-radius: var(--p-radius-sm); background: transparent; color: var(--p-muted); }
.day-add:hover, .day-add:focus-visible { border-style: solid; border-color: var(--p-primary); color: var(--p-primary-text); }
.plan-chip { position: relative; min-width: 0; display: flex; align-items: stretch; border: 1px solid #ddd3fb; border-left: 4px solid var(--p-primary); border-radius: var(--p-radius-sm); background: var(--p-primary-softer); }
.plan-chip.cardio { border-color: #f6d1b8; border-left-color: var(--p-cardio); background: #fff8f2; }
.plan-chip.completed { border-color: #c5e7d2; border-left-color: var(--p-success); background: var(--p-success-soft); }
.plan-chip-link { min-width: 0; flex: 1; padding: 6px 8px; color: var(--p-ink) !important; line-height: 1.25; }
.plan-chip-link:hover { text-decoration: none; }
.plan-chip-link strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--p-text-sm); }
.plan-chip-link small { display: block; color: var(--p-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-chip.completed .plan-chip-link strong { text-decoration: line-through; text-decoration-color: rgba(29, 116, 66, .5); }
.plan-status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; }
.plan-chip .plan-toggle { width: 40px; flex: 0 0 40px; border: 0; border-left: 1px solid rgba(0, 0, 0, .06); background: transparent; color: var(--p-primary-text); border-radius: 0 var(--p-radius-sm) var(--p-radius-sm) 0; }
.plan-chip.completed .plan-toggle { color: var(--p-success-text); }
.plan-chip .plan-toggle:hover { background: rgba(0, 0, 0, .04); }
.month-view .plan-chip-link small { display: none; }
.calendar-legend { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 18px; border-top: 1px solid var(--p-border); color: var(--p-muted); font-size: var(--p-text-xs); }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; border-left: 4px solid; background: var(--p-primary-softer); border-color: var(--p-primary); }
.legend-swatch.cardio { background: #fff8f2; border-color: var(--p-cardio); }
.legend-swatch.done { background: var(--p-success-soft); border-color: var(--p-success); }
.agenda { display: none; }
.agenda-day { padding: 12px 16px; border-bottom: 1px solid var(--p-border); }
.agenda-day h3 { margin: 0 0 8px; font-size: var(--p-text-sm); font-weight: 800; color: var(--p-ink-2); }
.agenda-day .plan-chip { margin-bottom: 8px; }

/* ---------- Creador de entrenamientos ---------- */
.builder-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: var(--p-space-4); align-items: start; }
.builder-preview { position: sticky; top: 16px; }
.block-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.block-item { padding: 12px 12px 4px; border: 1px solid var(--p-border); border-left: 5px solid var(--block-color, var(--p-primary)); border-radius: var(--p-radius); background: var(--p-surface); }
.block-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.block-index { width: 28px; height: 28px; flex: 0 0 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--p-surface-2); border: 1px solid var(--p-border); font-weight: 800; font-size: var(--p-text-xs); }
.block-item-head .block-title { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-tools { display: flex; gap: 2px; }
.block-tools .btn { min-height: 40px; width: 40px; padding: 0; }
.block-fields { display: grid; grid-template-columns: 1.2fr 1.2fr .6fr .6fr 1fr; gap: 0 10px; }
.block-fields .form-group { margin-bottom: 8px; }
.block-fields label { font-size: var(--p-text-xs); }
.add-block-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.repeat-box { margin-top: 14px; padding: 14px; border: 1px dashed var(--p-border-strong); border-radius: var(--p-radius); background: var(--p-surface-2); }
.profile { height: 120px; display: flex; align-items: flex-end; gap: 2px; padding: 8px 0 0; border-bottom: 2px solid var(--p-border); }
.profile-bar { min-width: 3px; border-radius: 4px 4px 0 0; background: var(--block-color, var(--p-primary)); }
.profile-empty { flex: 1; align-self: center; text-align: center; color: var(--p-muted); font-size: var(--p-text-sm); }
.block-type-warmup { --block-color: #9d8cf0; }
.block-type-steady { --block-color: #6a4be3; }
.block-type-interval { --block-color: #f0772b; }
.block-type-recovery { --block-color: #47b67a; }
.block-type-cooldown { --block-color: #8aa0c8; }
.preview-total { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 12px 0; }
.preview-total strong { font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.preview-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.preview-list li { padding: 8px 0; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--p-border); font-size: var(--p-text-sm); }
.preview-list li:last-child { border-bottom: 0; }
.preview-swatch { width: 10px; height: 26px; flex: 0 0 10px; border-radius: 4px; background: var(--block-color); }
.preview-list .pl-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-list .pl-meta { color: var(--p-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.workout-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--p-space-4); }
.workout-card .profile { height: 64px; }

/* ---------- Sesión de ciclismo ---------- */
.ride-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: var(--p-space-4); align-items: start; }
.ride-stage { padding: 22px; border-radius: var(--p-radius-lg); background: linear-gradient(160deg, #1c1a2e, #262241 70%, #33264a); color: #fff; box-shadow: var(--p-shadow); }
.ride-stage .eyebrow { color: #c9b9ff; }
.ride-state { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: var(--p-radius-pill); background: rgba(255, 255, 255, .1); font-size: var(--p-text-xs); font-weight: 800; }
.ride-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9a9cab; }
.ride-state[data-state="running"]::before { background: #5be39a; }
.ride-state[data-state="paused"]::before { background: #ffcc4d; }
.ride-state[data-state="finished"]::before, .ride-state[data-state="saved"]::before { background: #b9a6ff; }
.ride-block-now { margin: 18px 0 6px; }
.ride-block-now .now-label { margin: 0; color: #c9c6dc; font-size: var(--p-text-sm); font-weight: 700; }
.ride-block-now h2 { margin: 2px 0 0; color: #fff; font-size: clamp(1.6rem, 1rem + 2.6vw, 2.6rem); font-weight: 800; line-height: 1.1; }
.ride-clock-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.ride-clock { padding: 12px 14px; border-radius: var(--p-radius); background: rgba(255, 255, 255, .07); }
.ride-clock span { display: block; color: #c9c6dc; font-size: var(--p-text-xs); font-weight: 700; }
.ride-clock strong { display: block; color: #fff; font-size: clamp(1.5rem, 1rem + 2vw, 2.4rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.ride-clock.big strong { color: #ffb27a; }
.ride-target strong { color: #ffb27a; }
.block-progress { height: 10px; border-radius: var(--p-radius-pill); background: rgba(255, 255, 255, .12); overflow: hidden; }
.block-progress span { display: block; height: 100%; width: 0; background: var(--p-cardio); border-radius: inherit; transition: width .9s linear; }
.ride-next { margin-top: 14px; color: #d6d3e8; font-size: var(--p-text-sm); }
.ride-next strong { color: #fff; }
.ride-profile { position: relative; margin-top: 18px; height: 70px; display: flex; align-items: flex-end; gap: 2px; }
.ride-profile .profile-bar { opacity: .5; }
.ride-profile .profile-bar.done { opacity: .25; }
.ride-profile .profile-bar.current { opacity: 1; outline: 2px solid #fff; outline-offset: 1px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.metric { padding: 12px; border-radius: var(--p-radius); background: rgba(255, 255, 255, .07); }
.metric span { display: block; color: #c9c6dc; font-size: var(--p-text-xs); font-weight: 700; }
.metric strong { display: block; color: #fff; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric small { color: #c9c6dc; font-weight: 600; }
.metric.unavailable strong { color: #8e8ba5; font-size: 1.2rem; }
.metric.power strong { color: #ffb27a; }
.ride-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.ride-controls .btn { flex: 1 1 140px; min-height: 60px; font-size: var(--p-text-md); }
.ride-controls .btn-light-outline { border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff; }
.ride-controls .btn-light-outline:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.trainer-panel .status-line { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--p-radius); background: var(--p-surface-2); border: 1px solid var(--p-border); font-weight: 700; }
.status-dot { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; background: #9a9cab; }
.status-dot[data-status="connecting"], .status-dot[data-status="reconnecting"] { background: #f0b429; animation: p-pulse 1s ease-in-out infinite; }
.status-dot[data-status="connected"] { background: var(--p-success); }
.status-dot[data-status="error"] { background: var(--p-danger); }
@keyframes p-pulse { 50% { opacity: .35; } }
.diag-list { margin: 0; padding: 0; list-style: none; font-size: var(--p-text-sm); }
.diag-list li { padding: 6px 0; display: flex; gap: 8px; justify-content: space-between; border-bottom: 1px solid var(--p-border); }
.diag-list li:last-child { border-bottom: 0; }
.ride-summary { margin-top: 18px; padding: 18px; border-radius: var(--p-radius); background: var(--p-surface); color: var(--p-ink); }
.ride-summary label { color: var(--p-ink); }
.sticky-ride-bar { display: none; }

/* ---------- Autenticación ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--p-bg); }
.auth-visual { padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(155deg, #17152a, #2c2450 65%, #4a2f4f); color: #fff; }
.auth-visual h1 { color: #fff; font-size: clamp(2rem, 1.4rem + 2vw, 3rem); font-weight: 800; line-height: 1.1; letter-spacing: -.03em; }
.auth-visual p { color: #d7d3ea; max-width: 40ch; }
.auth-wave { width: 100%; max-width: 420px; height: auto; }
.auth-form-wrap { padding: 32px 20px; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.4rem; color: #fff; letter-spacing: -.02em; }

/* ---------- Barra inferior (móvil y tablet) ---------- */
.pulso-tabbar { display: none; }

/* ==========================================================================
   Adaptación por tamaño
   ========================================================================== */
@media (max-width: 1199.98px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .builder-layout, .ride-layout { grid-template-columns: minmax(0, 1fr); }
    .builder-preview { position: static; }
}

/* Tablet y móvil: AdminLTE oculta la barra lateral; se usa la barra inferior. */
@media (max-width: 991.98px) {
    .pulso-tabbar { position: fixed; right: 0; bottom: 0; left: 0; z-index: 1035; height: calc(var(--p-tabbar-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(6, 1fr); background: var(--p-surface); border-top: 1px solid var(--p-border); box-shadow: 0 -4px 20px rgba(22, 20, 40, .06); }
    .pulso-tabbar a { min-width: 0; min-height: var(--p-touch); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--p-muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
    .pulso-tabbar a i { font-size: 18px; }
    .pulso-tabbar a.active { color: var(--p-primary-text); }
    .pulso-tabbar a.active i { transform: translateY(-1px); }
    .pulso-tabbar a:hover { text-decoration: none; }
    .content-wrapper { padding-bottom: calc(var(--p-tabbar-h) + env(safe-area-inset-bottom)); }
    .main-footer { display: none; }
    .page-container { padding: var(--p-space-4); }
    .calendar-weekday { font-size: 11px; padding: 8px 2px; }
    .week-view .calendar-day { min-height: 180px; }
    .plan-chip .plan-toggle { width: 36px; flex-basis: 36px; }
}

@media (max-width: 767.98px) {
    .page-head { align-items: stretch; }
    .page-head > .btn, .page-head > .btn-row { width: 100%; }
    .page-head > .btn-row .btn { flex: 1; }
    .quick-actions { grid-template-columns: minmax(0, 1fr); }
    .field-grid, .field-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .block-fields { grid-template-columns: 1fr 1fr; }
    .block-fields .bf-type, .block-fields .bf-label { grid-column: span 1; }
    .block-fields .bf-target { grid-column: 1 / -1; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ride-stage { padding: 18px 16px; border-radius: var(--p-radius); }
    .p-card-header { padding: 16px 16px 4px; }
    .p-card-body { padding: 10px 16px 16px; }

    /* Semana en móvil: agenda vertical en lugar de 7 columnas estrechas. */
    .week-view.calendar-grid { grid-template-columns: minmax(0, 1fr); }
    .week-view .calendar-weekday { display: none; }
    .week-view .calendar-day { min-height: 0; padding: 12px 16px; border-right: 0; }
    .week-view .day-name-mobile { display: inline; font-weight: 700; color: var(--p-muted); margin-left: 6px; text-transform: capitalize; }
    .week-view .day-empty-hint { display: block; }

    /* Mes en móvil: cuadrícula compacta con indicadores + agenda del mes. */
    .month-view .calendar-day { min-height: 64px; padding: 6px 4px; align-items: center; }
    .month-view .plan-chip { display: none; }
    .month-view .day-add { display: none; }
    .month-view .day-dots { display: flex; }
    .agenda { display: block; border-top: 1px solid var(--p-border); }
    .period-nav h2 { min-width: 0; flex: 1; font-size: var(--p-text-md); }
    .planner-toolbar > * { width: 100%; }
    .period-nav { justify-content: space-between; }
}

@media (max-width: 575.98px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--p-space-3); }
    .stat { padding: 14px; }
    .stat-value { font-size: 1.6rem; }
    .stat-label { font-size: var(--p-text-xs); }
    .stat-icon { display: none; }
    .ride-clock-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ride-clock-row .ride-target { grid-column: 1 / -1; }
    .modal-dialog { margin: 8px; }
    .modal-dialog-centered { min-height: calc(100% - 16px); }
    .auth-page { grid-template-columns: minmax(0, 1fr); }
    .auth-visual { padding: 28px 20px; }
    .auth-visual .auth-wave, .auth-visual .auth-foot { display: none; }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .auth-page { grid-template-columns: minmax(0, 1fr); }
    .auth-visual .auth-wave { display: none; }
}

.day-dots { display: none; gap: 3px; flex-wrap: wrap; justify-content: center; }
.day-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--p-primary); }
.day-dots i.cardio { background: var(--p-cardio); }
.day-dots i.done { background: var(--p-success); }
.day-empty-hint { display: none; color: var(--p-muted); font-size: var(--p-text-xs); }

/* Pantalla de sesión: se oculta la barra de secciones para dejar sitio a los controles. */
@media (max-width: 991.98px) {
    body.page-ride .pulso-tabbar { display: none; }
    body.page-ride .content-wrapper { padding-bottom: 0; }
}

/* ---------- Objetivos táctiles: en pantallas táctiles todo control mide ≥ 44 px ---------- */
@media (pointer: coarse) {
    .btn-sm { min-height: var(--p-touch); padding: 8px 14px; }
    .day-add { width: var(--p-touch); height: var(--p-touch); }
    .plan-chip-link { min-height: var(--p-touch); display: flex; flex-direction: column; justify-content: center; }
    .block-tools .btn { min-height: var(--p-touch); width: var(--p-touch); }
}
.month-view .plan-chip-link { min-height: 40px; display: flex; flex-direction: column; justify-content: center; }
.session-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.session-picker .custom-select { min-width: 180px; flex: 1 1 180px; }
@media (max-width: 767.98px) {
    .session-picker { width: 100%; }
    .session-picker label { width: 100%; }
}
.hr-zone { display: inline-block; margin-top: 2px; font-size: var(--p-text-xs); font-weight: 700; color: #ffb3c1; }
.metric.heart strong { color: #ff8fa6; }
.sensor-block + .sensor-block { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--p-border); }
.exercise-table { width: 100%; }
.exercise-row { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, .8fr)) var(--p-touch); gap: 8px; align-items: end; margin-bottom: 8px; }
.exercise-row .form-group { margin-bottom: 0; }
.exercise-row label { font-size: var(--p-text-xs); }
@media (max-width: 575.98px) {
    .exercise-row { grid-template-columns: repeat(3, minmax(0, 1fr)) var(--p-touch); padding-bottom: 10px; border-bottom: 1px solid var(--p-border); }
    .exercise-row .ex-name { grid-column: 1 / -1; }
}
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 8px; height: 8px; margin-right: 10px; flex: 0 0 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details[open] > summary::before { transform: rotate(45deg); }
.ride-sync { margin: 14px 0 0; min-height: 20px; color: #c9c6dc; font-size: var(--p-text-xs); font-weight: 600; }
.ride-sync:empty { display: none; }
.ride-sync::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #9a9cab; }
.ride-sync[data-sync="ok"]::before { background: #5be39a; }
.ride-sync[data-sync="offline"]::before { background: #ffcc4d; }
.ride-sync[data-sync="error"]::before { background: #ff6b7a; }

/* ---------- Gráficas ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--p-space-4); margin-bottom: var(--p-space-3); }
.chart-grid .p-card { margin-bottom: 0; }
.chart-box { position: relative; height: 200px; }
.chart-box.tall { height: 240px; }
.chart-headline { margin: 0; text-align: right; color: var(--p-muted); font-size: var(--p-text-xs); }
.chart-headline strong { display: block; color: var(--p-ink); font-size: 1.35rem; font-weight: 800; }
.series-swatch { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 3px; vertical-align: 0; }
.series-power { background: #d9661c; } .series-cadence { background: #6a4be3; } .series-heart { background: #d6336c; } .series-speed { background: #0e8fa0; } .series-primary { background: #6a4be3; }
@media (max-width: 991.98px) { .chart-grid { grid-template-columns: minmax(0, 1fr); } }
.scale-reading { padding: 14px; border-radius: var(--p-radius); background: var(--p-primary-softer); border: 1px solid #ddd3fb; }
.scale-weight { font-size: var(--p-text-lg); color: var(--p-ink-2); }
.scale-weight strong { font-size: 2.4rem; font-weight: 800; color: var(--p-ink); }
.capture-panel { padding: 14px; border: 1px dashed var(--p-border-strong); border-radius: var(--p-radius); background: var(--p-surface-2); }
.packet-log { max-height: 200px; overflow: auto; margin: 4px 0 8px; padding: 10px; border-radius: var(--p-radius-sm); background: #1d1e29; color: #e7e5f2; font-size: 12px; line-height: 1.5; white-space: pre; }
.packet-log:empty::before { content: "Sin paquetes todavía."; color: #9a9cab; }
.scale-live { font-size: var(--p-text-lg); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--p-ink); }
.composition-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 16px; margin: 6px 0 4px; font-size: var(--p-text-xs); }
.composition-list div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--p-border); padding: 3px 0; }
.composition-list dt { font-weight: 600; color: var(--p-muted); }
.composition-list dd { margin: 0; font-weight: 800; color: var(--p-ink); }
.library-card .p-card-body { display: flex; flex-direction: column; align-items: flex-start; }
.library-card .p-card-body > :last-child { margin-top: auto; }
.weekday-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.weekday-option { position: relative; margin: 0; }
.weekday-option input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.weekday-option span:first-of-type { min-height: var(--p-touch); display: flex; align-items: center; justify-content: center; border: 1px solid var(--p-border-strong); border-radius: var(--p-radius-sm); font-size: var(--p-text-xs); font-weight: 800; background: var(--p-surface); }
.weekday-option input:checked + span { background: var(--p-primary); border-color: var(--p-primary); color: #fff; }
.weekday-option input:focus-visible + span { box-shadow: var(--p-focus); }
.item-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 2fr); gap: 0 10px; }
.item-fields .form-group { margin-bottom: 8px; }
.item-fields label { font-size: var(--p-text-xs); }
@media (max-width: 767.98px) { .item-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } .item-fields .item-notes { grid-column: 1 / -1; } }

/* ---------- Sesión de gimnasio ---------- */
.gym-stage { position: sticky; top: 0; z-index: 20; padding: 16px 18px; }
.gym-progress { color: #d6d3e8; font-weight: 700; }
.gym-progress span { color: #fff; font-variant-numeric: tabular-nums; }
.set-table { display: flex; flex-direction: column; gap: 8px; }
.set-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 56px; gap: 8px; align-items: center; }
.set-row:has(input[name$="[duration_seconds]"]) { grid-template-columns: 44px minmax(0, 2fr) 56px; }
.set-head { font-size: var(--p-text-xs); font-weight: 700; color: var(--p-muted); }
.set-head:has(span:nth-child(3):last-child) { grid-template-columns: 44px minmax(0, 2fr) 56px; }
.set-number { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--p-surface-2); border: 1px solid var(--p-border); font-weight: 800; }
.set-row.is-done .set-number { background: var(--p-success); border-color: var(--p-success); color: #fff; }
.set-row.is-done .form-control { background: var(--p-success-soft); }
.set-done { position: relative; margin: 0; }
.set-done input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.set-done > span { width: 56px; height: 48px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--p-border-strong); border-radius: var(--p-radius-sm); color: transparent; font-size: 18px; background: var(--p-surface); }
.set-done input:checked + span { background: var(--p-success); border-color: var(--p-success); color: #fff; }
.set-done input:focus-visible + span { box-shadow: var(--p-focus); }
.rest-bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1040; width: min(520px, calc(100% - 24px)); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: var(--p-radius-lg); background: #1d1e29; color: #fff; box-shadow: var(--p-shadow-lg); }
.rest-bar[hidden] { display: none; }
.rest-bar strong { display: block; font-size: 2rem; font-weight: 800; line-height: 1; }
.rest-bar .small { color: #c9c6dc; }
.program-group > summary { list-style: none; display: flex; align-items: center; }
.program-group > summary::-webkit-details-marker { display: none; }
/* La cabecera fija de la sesión no debe tapar la serie enfocada (WCAG 2.4.11). */
html:has(.gym-stage) { scroll-padding-top: 170px; }
.set-row, .gym-exercise { scroll-margin-top: 170px; }
/* La barra de descanso no debe tapar las últimas series: espacio y margen de desplazamiento. */
#gym-form { padding-bottom: 110px; }
html:has(.gym-stage) { scroll-padding-bottom: 120px; }
.set-row, .gym-exercise { scroll-margin-bottom: 120px; }

/* ---------- Guía de ejercicios ---------- */
.exercise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.exercise-tile { min-height: 64px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--p-border); border-radius: var(--p-radius); background: var(--p-surface); color: var(--p-ink) !important; }
.exercise-tile:hover { text-decoration: none; border-color: #c9bdf7; background: var(--p-primary-softer); }
.exercise-tile[hidden], [data-group][hidden] { display: none; }
.exercise-guide { font-size: var(--p-text-sm); }
.guide-title { margin: 12px 0 6px; font-size: var(--p-text-sm); font-weight: 800; }
.guide-steps { padding-left: 20px; margin-bottom: 8px; }
.guide-steps li { margin-bottom: 4px; }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; margin-bottom: 8px; }
.guide-grid ul { padding-left: 18px; margin-bottom: 0; }
@media (max-width: 767.98px) { .guide-grid { grid-template-columns: minmax(0, 1fr); } }
/* Móvil: accesos rápidos compactos (2 columnas, sin subtítulo) para que las métricas se vean antes. */
@media (max-width: 767.98px) {
    .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .quick-action { min-height: 56px; padding: 8px 10px; gap: 8px; font-size: var(--p-text-sm); }
    .quick-action small { display: none; }
    .quick-action .qa-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; }
}
.erg-panel { padding: 12px; border-radius: var(--p-radius); background: var(--p-cardio-soft); border: 1px solid #f6d1b8; }
.erg-panel .custom-control-label { min-height: 28px; display: flex; align-items: center; }

/* ---------- Pictogramas de ejercicios ---------- */
.pictogram-figure { margin: 0 0 12px; padding: 12px; border-radius: var(--p-radius); background: var(--p-surface-2); border: 1px solid var(--p-border); text-align: center; }
.pictogram { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto 8px; }
.pictogram line, .pictogram path { stroke-linecap: round; stroke-linejoin: round; fill: none; }
.pg-body { stroke: #3d3660; stroke-width: 8; }
.pg-torso { stroke-width: 11; }
.pg-back { stroke: #bdb4ec; stroke-width: 7; }
.pg-head { fill: #3d3660; }
.pg-prop { fill: #f0772b; }
.pg-prop-hole { fill: #fff; }
.pg-equip { fill: #dfe0e8; }
.pg-equip-line { stroke: #b2b4c2; stroke-width: 3; }
.pg-thick { stroke-width: 5; }
.pg-cable { stroke: #8f91a2; stroke-width: 1.5; stroke-dasharray: 3 3; }
.pg-ground { stroke: #cfd1dc; stroke-width: 2; }
.pictogram-thumb { width: 64px; height: 58px; flex: 0 0 64px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--p-surface-2); }
.pictogram-thumb .pictogram { margin: 0; max-width: 64px; }
.run-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.run-field { margin: 0; font-size: var(--p-text-xs); font-weight: 700; }
.run-field span { display: block; color: var(--p-muted); }
.run-pace { grid-column: 1 / -1; font-weight: 700; color: var(--p-cardio-text); }
.set-row:has([data-run]) { grid-template-columns: 44px minmax(0, 1fr) 56px; }
.energy-table th, .energy-table td { vertical-align: top; font-size: var(--p-text-sm); }
.energy-table tr.is-today { background: var(--p-primary-softer); }
.energy-table tfoot th, .energy-table tfoot td { background: var(--p-surface-2); }

/* ---------- Comidas ---------- */
.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-nav-form .form-control { min-height: 40px; width: auto; }
.meal-card .p-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.meal-card .p-card-title { display: flex; align-items: center; gap: 10px; }
.meal-actions { display: flex; align-items: center; gap: 12px; }
.food-list { list-style: none; margin: 0; padding: 0; }
.food-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--p-border); }
.food-list li:first-child { border-top: 0; }
.food-list-main { flex: 1; min-width: 0; }
.food-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: var(--p-radius-pill); border: 1px solid var(--p-border-strong); background: var(--p-surface); color: var(--p-ink); font-size: var(--p-text-sm); font-weight: 600; cursor: pointer; }
.chip:hover, .chip:focus-visible { border-color: var(--p-primary); color: var(--p-primary-text); }
.chip .fa-star { color: #b7791f; }
.form-label-sm { font-size: var(--p-text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--p-muted); }
legend.form-label-sm { width: auto; margin-bottom: 6px; }
.segmented-tabs { display: flex; width: 100%; }
.segmented-tabs button, .segmented-sm label { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 9px; color: var(--p-ink-2); font-weight: 700; font-size: var(--p-text-sm); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; cursor: pointer; margin: 0; }
.segmented-tabs button[aria-selected="true"], .segmented-sm label:has(input:checked) { background: var(--p-surface); color: var(--p-primary-text); box-shadow: var(--p-shadow-sm); }
.segmented-sm label { white-space: nowrap; padding: 6px 14px; }
.segmented-sm input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-sm label:has(input:focus-visible) { outline: 2px solid var(--p-primary); }
.gap-2 { gap: 8px; }
.field-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 575.98px) { .field-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .segmented-tabs button i { display: none; } }
.food-results-group { margin-top: 12px; }
.food-result { display: flex; width: 100%; text-align: left; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--p-border); border-radius: var(--p-radius-sm); background: var(--p-surface); color: var(--p-ink); margin-top: 6px; cursor: pointer; }
.food-result:hover, .food-result:focus-visible { border-color: var(--p-primary); }
.food-result small { color: var(--p-muted); }
.selected-food { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; margin-bottom: 12px; border-radius: var(--p-radius-sm); background: var(--p-primary-softer); border: 1px solid var(--p-primary-soft); }
.food-preview { font-weight: 700; color: var(--p-primary-text); }
.scanner { position: relative; border-radius: var(--p-radius); overflow: hidden; background: #000; margin-bottom: 12px; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff4d5e; box-shadow: 0 0 8px #ff4d5e; }
.label-preview { max-width: 100%; max-height: 220px; border-radius: var(--p-radius-sm); margin-top: 8px; }
.label-raw { white-space: pre-wrap; font-size: var(--p-text-xs); max-height: 200px; overflow: auto; background: var(--p-surface-2); padding: 8px; border-radius: var(--p-radius-sm); }
@media (min-width: 1200px) { .food-panel { position: sticky; top: 76px; } }

/* Gráfica de todas las medidas: botones-leyenda */
.metric-toggle[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.metric-toggle[aria-pressed="false"] .series-swatch { background: transparent !important; box-shadow: inset 0 0 0 2px var(--p-border-strong); }

/* Catálogo de bici: filtros */
.filter-row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 12px; }
.filter-row > .form-label-sm { min-width: 72px; }
.chip[aria-current="true"] { background: var(--p-primary-soft); border-color: var(--p-primary); color: var(--p-primary-text); }
a.chip:hover { text-decoration: none; }

/* Tus próximas subidas */
.next-step-badge { display: inline-block; font-size: var(--p-text-xs); font-weight: 800; padding: 2px 8px; border-radius: var(--p-radius-pill); margin-right: 6px; vertical-align: 1px; }
.next-step-up .next-step-badge { background: var(--p-success-soft); color: var(--p-success-text); }
.next-step-down .next-step-badge { background: var(--p-warning-soft); color: var(--p-warning-text); }
.next-step-keep .next-step-badge { background: #ecedf3; color: var(--p-ink-2); }
.library-card .profile { width: 100%; align-self: stretch; }
.filter-row > nav { flex: 1 1 0; min-width: 0; }

/* Importar desde la app Salud */
.apple-list { max-height: 420px; overflow: auto; border: 1px solid var(--p-border); border-radius: var(--p-radius-sm); }
.apple-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--p-border); margin: 0; cursor: pointer; font-weight: 400; }
.apple-row:first-child { border-top: 0; }
.apple-row input { margin-top: 4px; width: 18px; height: 18px; flex: 0 0 18px; }
.apple-row-main { display: flex; flex-direction: column; min-width: 0; }
.apple-row-main small { color: var(--p-muted); }
.progress-bar { background: var(--p-primary); }

.series-pace { background: #0e8fa0; }

.shortcut-steps code { word-break: break-all; }

/* Bandeja del iPhone */
.inbox-month { font-size: var(--p-text-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--p-muted); margin: 16px 0 4px; }
.inbox-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--p-border); margin: 0; cursor: pointer; font-weight: 400; }
.inbox-row input { width: 20px; height: 20px; flex: 0 0 20px; }
.inbox-row:has(input:checked) { background: var(--p-primary-softer); }
.inbox-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.p-card-header .custom-checkbox { margin-left: auto; }
