/* ================= GymApp · estilos ================= */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --border: #e3e6ee;
  --text: #171a26;
  --text-2: #4a5068;
  --muted: #7a8099;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #3730a3;
  --success: #0f8a5f;
  --success-soft: #e5f6ee;
  --danger: #d0334b;
  --danger-soft: #fdecef;
  --cat-fuerza: #4f46e5;
  --cat-cardio: #0e7c86;
  --cat-descanso: #8a6a12;
  --grid: #e6e8ef;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 4px 16px rgba(20, 24, 40, 0.05);
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b24;
    --surface-2: #20242f;
    --border: #2b303d;
    --text: #eceef5;
    --text-2: #b9bed0;
    --muted: #8a90a6;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #23264a;
    --accent-text: #c7cbff;
    --success: #34c48b;
    --success-soft: #133326;
    --danger: #f2667b;
    --danger-soft: #3a1820;
    --cat-fuerza: #818cf8;
    --cat-cardio: #3cc3cc;
    --cat-descanso: #d9b44a;
    --grid: #262a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
img, svg, video { max-width: 100%; }
.chart svg { max-width: none; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#view { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 42px; padding: 0.55rem 1.1rem;
  border: 1px solid transparent; border-radius: 12px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0f1117; } }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { filter: brightness(0.97); }
.btn-link { background: none; border: none; color: var(--accent); padding: 0.25rem 0; min-height: auto; font-weight: 600; }
.btn-link.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.btn-link.small { padding: 0; }
.align-start { align-self: flex-start; }
.btn-lg { min-height: 50px; padding: 0.75rem 1.5rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
/* Botón de instalar: visible salvo si ya se usa como app instalada */
body.standalone .install-btn { display: none; }
.install-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.kbd { display: inline-block; padding: 0 0.35rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-size: 0.85em; }

/* ---------- Formularios ---------- */
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem; min-height: 42px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
::placeholder { color: var(--muted); opacity: 0.7; font-weight: 400; }
input:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; }
.form-error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 0; }
.notice { margin-top: 1rem; padding: 0.75rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font-size: 0.85rem; }
.divider { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------- Tarjetas y página ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: 0.75rem; }
.page { max-width: 880px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 0.85rem; margin: 0 0 0.15rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.loader { width: 36px; height: 36px; margin: 4rem auto; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { max-width: 480px; margin: 3rem auto; }

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); font-size: 1.1rem; }
.brand-lg { font-size: 1.4rem; margin-bottom: 1.5rem; }
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 1.4rem; }

/* ---------- Shell de la app ---------- */
/* display: contents para que la barra superior "sticky" funcione respecto a toda la página */
#shell:not([hidden]) { display: contents; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem 1rem; padding-top: max(0.6rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav { display: none; gap: 0.25rem; margin: 0 auto; }
.topnav a, .tabbar a { text-decoration: none; color: var(--muted); font-weight: 600; }
.topnav a { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.85rem; border-radius: 10px; }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent-text); }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text); font-weight: 600; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; }
.user-name { display: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.72rem; }
.tabbar a .nav-icon { font-size: 1.25rem; filter: grayscale(1); opacity: 0.7; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .nav-icon { filter: none; opacity: 1; }
body[data-layout='app'] #view { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

@media (min-width: 768px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .user-chip { margin-left: 0; }
  .user-name { display: inline; }
  body[data-layout='app'] #view { padding-bottom: 0; }
  .page { padding-top: 2rem; }
}

/* ---------- Bienvenida ---------- */
.hero {
  padding: 3.5rem 1.25rem 3rem;
  background:
    radial-gradient(900px 400px at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(700px 360px at -10% 110%, color-mix(in srgb, var(--cat-cardio) 16%, transparent), transparent 70%);
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.08; letter-spacing: -0.03em; margin-bottom: 1rem; }
.accent { color: var(--accent); }
.lead { font-size: 1.1rem; color: var(--text-2); max-width: 560px; margin-bottom: 1.75rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
@media (max-width: 480px) { .hero-cta .btn { flex: 1 1 100%; } }
.features { max-width: 960px; margin: 0 auto; padding: 1rem 1.25rem 2rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.feature-icon { font-size: 1.6rem; margin-bottom: 0.5rem; }
.feature h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.feature p { color: var(--text-2); font-size: 0.92rem; margin: 0; }
.public-foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1rem 1rem 2.5rem; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-brand { margin-bottom: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: 0.25rem; }
.auth-card > .muted { margin-bottom: 1.25rem; }
.auth-foot { margin-top: 1.25rem; color: var(--muted); }

/* ---------- Semana ---------- */
.week-nav { display: flex; align-items: center; gap: 0.4rem; }
.week-progress { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.week-progress-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.week-progress-bar span { display: block; height: 100%; background: var(--success); border-radius: 99px; transition: width 0.3s; }
.week-progress-text { font-weight: 700; font-size: 0.9rem; color: var(--text-2); }
.days { display: flex; flex-direction: column; gap: 0.75rem; }

.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.day-card.today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.day-card.done { border-left: 4px solid var(--success); }
.day-card summary { display: flex; align-items: center; gap: 0.9rem; padding: 0.85rem 1rem; cursor: pointer; list-style: none; }
.day-card summary::-webkit-details-marker { display: none; }
.day-date { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 50px; border-radius: 12px; background: var(--surface-2); flex-shrink: 0; }
.day-card.today .day-date { background: var(--accent); color: #fff; }
.day-name { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.8; }
.day-num { font-size: 1.15rem; font-weight: 800; line-height: 1.1; }
.day-head { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.day-title { font-weight: 700; }
.day-sub { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 0.75rem; font-weight: 700; padding: 0.25rem 0.6rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-done { background: var(--success-soft); color: var(--success); }
.day-body { padding: 0 1rem 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.block { margin-bottom: 1rem; }
.block-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.chips li { font-size: 0.82rem; padding: 0.3rem 0.65rem; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.exercise { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 0.5rem; }
.exercise-info { display: flex; flex-direction: column; min-width: 0; }
.exercise-name { font-weight: 600; }
.exercise-meta { font-size: 0.8rem; color: var(--muted); }
.exercise-meta .last { color: var(--accent-text); }
.weight-input { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; color: var(--muted); font-size: 0.85rem; }
.weight-input input { width: 76px; text-align: right; font-weight: 700; font-size: 1rem; }
.options { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 0.75rem; }
.option { position: relative; display: flex; flex-direction: column; gap: 0.15rem; padding: 0.8rem 0.9rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option-name { font-weight: 700; }
.option-desc { font-size: 0.83rem; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem; padding: 0.75rem; border-radius: 12px; background: var(--surface-2); }
.field-sm > span { font-size: 0.78rem; }
.repeat-banner { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.88rem; margin-bottom: 1rem; }
.log-notes { margin: 0.75rem 0 0; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--surface-2); font-size: 0.88rem; color: var(--text-2); }
.day-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.plan-link { display: flex; justify-content: center; margin-top: 1.25rem; }

/* ---------- Entrenamiento distinto ---------- */
.day-actions .swap-btn { margin-right: auto; font-size: 0.85rem; }
.swap-mark { color: var(--accent); font-weight: 800; }
.override-banner { background: color-mix(in srgb, var(--cat-descanso) 14%, var(--surface)); color: var(--text); align-items: flex-start; }
.override-banner em { color: var(--text-2); }
.swap-list { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
@media (min-width: 600px) { .swap-list { grid-template-columns: 1fr 1fr; } }
.swap-option .tag { font-size: 0.65rem; vertical-align: middle; margin-left: 0.25rem; }
.swapped-note { display: block; font-size: 0.8rem; color: var(--muted); }
@media (max-width: 420px) {
  .day-actions { flex-wrap: wrap; }
  .day-actions .swap-btn { width: 100%; text-align: left; justify-content: flex-start; }
}

/* ---------- Editor de plan ---------- */
.page-editor { padding-bottom: 6rem; }
.page-editor .page-head .btn-link { margin-bottom: 0.25rem; }
.ed-day .day-body { display: flex; flex-direction: column; gap: 1rem; }
.ed-day .day-date { height: 40px; }
.chevron { color: var(--muted); transition: transform 0.2s; }
.ed-day[open] .chevron { transform: rotate(180deg); }
.ed-grid { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .ed-grid { grid-template-columns: 1fr 1fr; } }
.ed-block { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.ed-block > .ed-row, .ed-block > .ed-option { width: 100%; }
.ed-row {
  display: grid; gap: 0.5rem; align-items: end; width: 100%;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas: 'name name name' 'sets reps tools';
}
.ed-row .grow { grid-area: name; }
.ed-row .num:nth-of-type(2) { grid-area: sets; }
.ed-row .num:nth-of-type(3) { grid-area: reps; }
.ed-row .row-tools { grid-area: tools; }
.ed-option .ed-row { grid-template-columns: 1fr auto; grid-template-areas: 'name tools'; }
@media (min-width: 600px) {
  .ed-row { grid-template-columns: 1fr 84px 84px auto; grid-template-areas: 'name sets reps tools'; }
}
.ed-block > .ed-row { padding-bottom: 0.6rem; border-bottom: 1px dashed var(--border); }
.ed-option { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.row-tools { display: flex; gap: 0.3rem; }
.icon-btn.sm { width: 42px; height: 42px; font-size: 1rem; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.danger { color: var(--danger); }
a.icon-btn { display: inline-grid; place-items: center; text-decoration: none; font-size: 1.1rem; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.check-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.75rem; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); cursor: pointer; font-size: 0.88rem; min-height: 40px; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.error-list { margin: 0; padding-left: 1.2rem; color: var(--danger); }
.editor-bar {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.6rem max(1rem, calc((100vw - 880px) / 2 + 1rem));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
@media (min-width: 768px) { .editor-bar { bottom: 0; } }
@media (max-width: 600px) {
  .editor-hint { display: none; }
  .editor-bar .btn-row { width: 100%; flex-wrap: nowrap; }
  .editor-bar .btn-row .btn { flex: 1; }
}

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(10, 12, 20, 0.5); opacity: 0; transition: opacity 0.2s; }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 1.25rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); transform: translateY(20px); transition: transform 0.2s; }
.modal-backdrop.show .modal { transform: none; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.modal-head h3 { font-size: 1.1rem; }
.modal-head .icon-btn { border: none; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
.feelings { border: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
.feelings legend { font-weight: 600; font-size: 0.9rem; color: var(--text-2); margin-bottom: 0.5rem; padding: 0; }
.feeling { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 0.6rem 0.2rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.feeling input { position: absolute; opacity: 0; pointer-events: none; }
.feeling:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.feeling:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.feeling-emoji { font-size: 1.5rem; }
.feeling-label { font-size: 0.7rem; font-weight: 600; color: var(--text-2); text-align: center; }

/* ---------- Toast ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; width: max-content; max-width: calc(100vw - 2rem); }
@media (min-width: 768px) { #toasts { bottom: 24px; } }
.toast { padding: 0.7rem 1rem; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.9rem; box-shadow: 0 8px 24px rgba(0,0,0,0.2); opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); color: #fff; }

/* ---------- Historial ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { border: none; background: none; font: inherit; font-weight: 600; font-size: 0.88rem; color: var(--muted); padding: 0.4rem 0.8rem; border-radius: 9px; cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search { flex: 1; min-width: 200px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table td[data-label='Notas'] { min-width: 160px; }
.table td[data-label='Detalle'] { min-width: 150px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); padding: 0.7rem 0.8rem; }
.table td { padding: 0.75rem 0.8rem; border-top: 1px solid var(--border); vertical-align: top; }
.row-actions { text-align: right; }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 99px; margin-right: 0.25rem; border: 1px solid currentColor; }
.tag-fuerza { color: var(--cat-fuerza); }
.tag-cardio { color: var(--cat-cardio); }
.tag-descanso { color: var(--cat-descanso); }
@media (max-width: 900px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 0.75rem 0.9rem; border-top: 1px solid var(--border); }
  .table tr:first-child { border-top: none; }
  .table td { border: none; padding: 0.15rem 0; }
  .table td[data-label]:not([data-label='Fecha']):not([data-label='Actividad'])::before { content: attr(data-label) ': '; color: var(--muted); font-weight: 600; }
  .table td[data-label='Fecha'] br { display: none; }
  .table td[data-label='Fecha'] .muted::before { content: ' · '; }
  .row-actions { text-align: left; padding-top: 0.35rem !important; }
  .table td.empty-cell { display: none; }
  .table td[data-label] { min-width: 0; }
}

/* ---------- Progreso ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.stat-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.stat-value { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.75rem; color: var(--muted); }
.chart-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.chart-grid .card { margin: 0; min-width: 0; }
.page-wide { max-width: 1180px; }
@media (min-width: 1000px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
.chart-card h2 { margin-bottom: 0.1rem; }
.chart-card > .muted, .chart-head .muted { margin-bottom: 0.75rem; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; }
.chart-head select { width: auto; max-width: 100%; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.baseline { stroke: var(--border); }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .mark { fill: var(--accent); transition: opacity 0.15s; }
.chart svg:has(.mark.hover) .mark:not(.hover) { opacity: 0.45; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .marker.hover { r: 6; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart-tip { position: absolute; pointer-events: none; z-index: 2; padding: 0.4rem 0.6rem; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 0.8rem; line-height: 1.35; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,0.18); }

/* ---------- Modo local: aviso discreto ---------- */
body.mode-local[data-layout='app'] .topbar::after {
  content: 'Local'; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted);
}
