/* Trail Dashboard: mobile first, barra lateral a escriptori.
   Paleta de sèries validada per a daltonisme (ordre fix d'slots). */

:root {
  color-scheme: light;
  --plane: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;   /* blau     - Trail / mètrica principal */
  --series-2: #eb6834;   /* taronja  - Córrer / segona mètrica   */
  --series-3: #1baf7a;   /* aqua     - Excursió                  */
  --series-4: #eda100;   /* groc     - Força                     */
  --series-5: #e87ba4;   /* magenta  - Bici                      */
  --series-6: #8a63d2;   /* lila     - Pilates i ioga            */
  --series-other: #b5b3ab;
  --band: rgba(42, 120, 214, 0.12);
  /* rampa ordinal blava: zones de FC i calendari (categories ordenades) */
  --seq-0: #ecebe6;
  --seq-1: #b7d3f6;
  --seq-2: #86b6ef;
  --seq-3: #5598e7;
  --seq-4: #2a78d6;
  --seq-5: #1c5cab;
  --seq-6: #104281;
  --div-pos: #2a78d6;
  --div-neg: #e34948;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up: #006300;
  --down: #b42318;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.04);
  --radius: 16px;
  --hero-a: #e8f0fb;
  --hero-b: #fcfcfb;
  --ridge: rgba(42, 120, 214, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
  --series-6: #9a78e0;
    --series-6: #9a78e0;
    --series-other: #5f5e59;
    --band: rgba(57, 135, 229, 0.18);
    --seq-0: #262624;
    --seq-1: #184f95;
    --seq-2: #1c5cab;
    --seq-3: #256abf;
    --seq-4: #3987e5;
    --seq-5: #6da7ec;
    --seq-6: #9ec5f4;
    --div-pos: #3987e5;
    --div-neg: #e66767;
    --up: #0ca30c;
    --down: #e66767;
    --shadow: none;
    --hero-a: #13233a;
    --hero-b: #1a1a19;
    --ridge: rgba(57, 135, 229, 0.14);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #9a78e0;
  --series-other: #5f5e59;
  --band: rgba(57, 135, 229, 0.18);
  --seq-0: #262624;
  --seq-1: #184f95;
  --seq-2: #1c5cab;
  --seq-3: #256abf;
  --seq-4: #3987e5;
  --seq-5: #6da7ec;
  --seq-6: #9ec5f4;
  --div-pos: #3987e5;
  --div-neg: #e66767;
  --up: #0ca30c;
  --down: #e66767;
  --shadow: none;
  --hero-a: #13233a;
  --hero-b: #1a1a19;
  --ridge: rgba(57, 135, 229, 0.14);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.shell { min-height: 100vh; }
.main {
  padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- navegació: barra inferior al mòbil ---------- */
.sidebar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.brand, .sidebar-foot { display: none; }
.nav { display: grid; grid-template-columns: repeat(6, 1fr); }
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 2px 8px; border: 0; background: none;
  color: var(--text-muted); font-size: 11px; font-weight: 500;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.is-active { color: var(--accent); }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .sidebar {
    position: sticky; top: 0; inset: auto; height: 100vh;
    border-top: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 22px 14px;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 26px; }
  .brand strong { display: block; font-size: 15px; }
  .brand span { color: var(--text-muted); font-size: 12px; }
  .brand-mark { width: 34px; height: 34px; fill: var(--accent); stroke: none; }
  .nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item {
    flex-direction: row; gap: 12px; padding: 10px 12px; border-radius: 10px;
    font-size: 14px; color: var(--text-secondary);
  }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item:hover { background: var(--surface-2); }
  .nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sidebar-foot { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding: 0 8px; }
  .main { padding: 28px 32px 48px; width: 100%; }
  .only-mobile { display: none !important; }
}

/* ---------- mode app (instal·lada al mòbil) ---------- */
html { -webkit-tap-highlight-color: transparent; }
.head-actions { display: flex; gap: 8px; }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .main { padding-top: calc(16px + env(safe-area-inset-top)); }
  .page-head { position: sticky; top: 0; z-index: 30; margin: calc(-16px - env(safe-area-inset-top)) -16px 18px;
    padding: calc(12px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--plane) 88%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .page-head h1 { font-size: 24px; }
}

/* ---------- capçalera de pàgina ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.page-head h1 { font-size: 28px; letter-spacing: -0.02em; line-height: 1.1; }
.eyebrow { color: var(--text-muted); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

.sync-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.sync-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.sync-pill.ok i { background: var(--good); }
.sync-pill.warn i { background: var(--warning); }
.sync-pill.err i { background: var(--critical); }

.banner {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warning);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; color: var(--text-secondary);
}

/* ---------- graella ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.grid > * { min-width: 0; }
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(12, 1fr); gap: 16px; }
  .span-4 { grid-column: span 6; } .span-5 { grid-column: span 6; } .span-6 { grid-column: span 6; }
  .span-7 { grid-column: span 12; } .span-8 { grid-column: span 12; } .span-12 { grid-column: span 12; }
}
@media (min-width: 1180px) {
  .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
  .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
}

/* ---------- targetes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; min-width: 0;
}
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.card-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sub-head { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 16px 0 6px; }
.note { color: var(--text-muted); font-size: 12px; margin-top: 10px; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: transparent; border-radius: 9px;
  padding: 6px 10px; font-size: 13px; color: var(--text-secondary); white-space: nowrap;
}
.ghost-btn svg { width: 16px; height: 16px; }
.ghost-btn:hover { background: var(--surface-2); }
.ghost-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.icon-btn svg { width: 20px; height: 20px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 8px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.seg button.is-on { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.chart-box { position: relative; height: 240px; }
.chart-box--xs { height: 120px; }
.chart-box--sm { height: 170px; }
.chart-box--lg { height: 300px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -2px 0 10px; font-size: 12.5px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 2px; }
.legend i.band { height: 10px; width: 14px; border-radius: 2px; background: var(--band) !important; }

.table-view { margin-top: 12px; max-height: 280px; overflow: auto; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } .tiles.tiles--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tiles--dense { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
@media (min-width: 560px) { .tiles--dense { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.tiles--dense .tile { box-shadow: none; padding: 11px 12px; background: var(--surface-2); border-color: transparent; }
.tile-label { color: var(--text-muted); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.tile-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.tiles--dense .tile-value { font-size: 19px; }
.tile-value small { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; letter-spacing: 0; }
.tile-foot { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { font-weight: 600; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.spark { width: 100%; height: 30px; margin-top: 4px; }
.spark path { stroke: var(--series-1); stroke-width: 2; }
.spark circle { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--up); }
.status.warning { color: #a86f00; }
.status.serious { color: #c0532a; }
.status.critical { color: var(--critical); }
:root[data-theme="dark"] .status.warning { color: var(--warning); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status.warning { color: var(--warning); } }

/* ---------- hero ---------- */
.hero {
  display: flex; gap: 22px; align-items: center; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b) 70%);
}
.hero::after { /* serralada decorativa */
  content: ""; position: absolute; inset: auto 0 0 0; height: 70px; pointer-events: none;
  background: var(--ridge);
  clip-path: polygon(0 100%, 0 70%, 9% 45%, 16% 62%, 27% 22%, 36% 52%, 44% 38%, 55% 68%, 66% 18%, 75% 48%, 83% 34%, 92% 58%, 100% 40%, 100% 100%);
}
.hero > * { position: relative; z-index: 1; }
.hero-ring { flex: none; width: 128px; height: 128px; }
.hero-ring svg { width: 100%; height: 100%; }
.hero-body { min-width: 0; }
.hero-body h2 { font-size: 22px; letter-spacing: -0.02em; margin: 4px 0 6px; line-height: 1.2; }
.hero-text { color: var(--text-secondary); font-size: 14.5px; max-width: 60ch; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; color: var(--text-secondary);
}
.chip b { color: var(--text-primary); font-weight: 650; }
@media (max-width: 520px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 12px; }
  .hero-ring { width: 104px; height: 104px; }
}

/* ---------- setmana ---------- */
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; margin-bottom: 16px; }
.week-day span { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.week-dot { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); position: relative; }
.week-dot b { display: block; border-radius: 50%; }
.week-day.is-today span { color: var(--accent); }
.week-day.is-today .week-dot { box-shadow: 0 0 0 2px var(--accent-soft); }
.week-bars { display: flex; flex-direction: column; gap: 12px; }
.wbar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.wbar-top b { font-weight: 650; }
.wbar-top span { color: var(--text-muted); }
.wbar { position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; }
.wbar i { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 4px; max-width: 100%; }
.wbar em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-secondary); border-radius: 1px; }

/* ---------- última activitat i feed ---------- */
.last-body { display: grid; grid-template-columns: 1fr; gap: 14px; }
.last-body > .route-svg, .last-body > .route-ph { max-width: 220px; }
@media (min-width: 560px) { .last-body { grid-template-columns: 180px 1fr; align-items: center; } }
@media (max-width: 560px) {
  .card-head { flex-wrap: wrap; }
  .head-tools { width: 100%; justify-content: space-between; }
}
.route-svg { width: 100%; aspect-ratio: 1; background: var(--surface-2); border-radius: 12px; display: block; }
.route-svg path { stroke: var(--series-2); stroke-width: 2.4; fill: none; }
.route-svg circle.start { fill: var(--good); stroke: var(--surface); stroke-width: 1.5; }
.route-svg circle.end { fill: var(--critical); stroke: var(--surface); stroke-width: 1.5; }
.route-ph { width: 100%; aspect-ratio: 1; background: var(--surface-2); border-radius: 12px; display: grid; place-items: center; color: var(--text-muted); font-size: 32px; }
.last-name { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 10px; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
.stat-row div { min-width: 0; }
.stat-row dt { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.stat-row dd { margin: 1px 0 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.stat-row dd small { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }

.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.grid > .filter-row { margin-bottom: 0; }
.search, .select {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-primary);
  border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 14px;
}
.search { flex: 1 1 220px; min-width: 0; }
.chips--filter { margin: 0; }
.chips--filter .chip { cursor: pointer; }
.chips--filter .chip i { width: 8px; height: 8px; border-radius: 50%; }
.chips--filter .chip.is-on { background: var(--text-primary); color: var(--surface); border-color: transparent; }
.totals-strip { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 14px; font-size: 13px; color: var(--text-secondary); }
.totals-strip b { color: var(--text-primary); font-size: 16px; font-weight: 650; margin-right: 3px; }

.feed { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .feed { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.act {
  display: grid; grid-template-columns: 84px 1fr; gap: 14px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.act:hover { border-color: var(--axis); }
.act .route-svg, .act .route-ph { border-radius: 10px; }
.act .route-ph { font-size: 26px; }
.act-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }
.badge i { width: 8px; height: 8px; border-radius: 50%; }
.act-name { font-size: 15px; font-weight: 650; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.act .stat-row dd { font-size: 14.5px; }
.more-btn { display: block; margin: 16px auto 0; }
.empty { color: var(--text-muted); padding: 28px 0; text-align: center; }

/* ---------- focus de càrrega ---------- */
.focus-row { margin-bottom: 14px; }
.focus-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; margin-bottom: 6px; }
.focus-top b { font-weight: 650; }
.focus-top span { color: var(--text-muted); font-size: 12.5px; }
.focus-bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.focus-bar i { display: block; height: 100%; border-radius: 5px; }
.focus-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- calendari ---------- */
.calendar-wrap { overflow-x: auto; padding-bottom: 4px; }
.calendar { --cell: 13px; display: grid; grid-auto-flow: column; grid-template-rows: 16px repeat(7, var(--cell)); gap: 3px; width: max-content; }
.cal-month { font-size: 11px; color: var(--text-muted); grid-row: 1; white-space: nowrap; width: 0; overflow: visible; }
.cal-day { width: var(--cell, 13px); height: var(--cell, 13px); border-radius: 3px; background: var(--seq-0); }
.cal-legend .cal-day { width: 12px; height: 12px; }
.cal-day.lv1 { background: var(--seq-1); } .cal-day.lv2 { background: var(--seq-2); }
.cal-day.lv3 { background: var(--seq-3); } .cal-day.lv4 { background: var(--seq-4); }
.cal-day.lv5 { background: var(--seq-5); } .cal-day.lv6 { background: var(--seq-6); }
.cal-day.future { background: transparent; }
.cal-day:hover { outline: 2px solid var(--text-primary); outline-offset: 0; }
.cal-legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); margin-top: 10px; justify-content: flex-end; }
.cal-legend .cal-day:hover { outline: none; }

/* ---------- mapes ---------- */
.map { height: 280px; border-radius: 12px; overflow: hidden; background: var(--surface-2); z-index: 0; }
.map--tall { height: 440px; }
@media (max-width: 719px) { .map--tall { height: 340px; } }
.leaflet-container { font: inherit; }
/* el sprite d'icones de Leaflet no es distribueix: el selector de capes porta text */
.leaflet-control-layers-toggle { background-image: none !important; width: auto !important; height: 30px !important; padding: 0 10px; line-height: 30px; font-size: 12px; font-weight: 600; color: #222; text-decoration: none; }
.leaflet-control-layers-toggle::after { content: "Capes"; }

/* ---------- rècords ---------- */
.records { display: flex; flex-direction: column; }
.rec { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 0; border-bottom: 1px solid var(--grid); align-items: center; }
.rec:last-child { border-bottom: 0; }
.rec-label { font-size: 14px; font-weight: 600; }
.rec-meta { grid-column: 1; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-value { grid-row: 1 / span 2; grid-column: 2; font-size: 18px; font-weight: 650; text-align: right; white-space: nowrap; }
.rec-value small { font-size: 12px; color: var(--text-secondary); font-weight: 500; margin-left: 2px; }
button.rec { background: none; border: 0; border-bottom: 1px solid var(--grid); text-align: left; width: 100%; }
button.rec:hover .rec-label { color: var(--accent); }

/* ---------- detall ---------- */
.detail { position: fixed; inset: 0; z-index: 60; }
.detail-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.42); }
.detail-panel {
  position: absolute; inset: 0; background: var(--plane); overflow-y: auto;
  display: flex; flex-direction: column;
}
@media (min-width: 960px) {
  .detail-panel { inset: 0 0 0 auto; width: min(760px, 92vw); border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(0,0,0,.18); }
}
.detail-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 18px 18px 12px; position: sticky; top: 0; background: var(--plane); z-index: 5;
}
.detail-head h2 { font-size: 21px; letter-spacing: -0.02em; margin-top: 2px; }
.detail-body { padding: 0 18px 28px; display: flex; flex-direction: column; gap: 14px; }

.zone-row { display: grid; grid-template-columns: 74px 1fr 62px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 7px; }
.zone-row span { color: var(--text-secondary); }
.zone-row b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.zone-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.zone-track i { display: block; height: 100%; border-radius: 4px; }

.cmp-row { display: grid; grid-template-columns: 110px 1fr 86px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 12px; }
.cmp-row span { color: var(--text-secondary); }
.cmp-row b { text-align: right; font-weight: 600; }
.cmp-track { position: relative; height: 6px; background: var(--surface-2); border-radius: 3px; }
.cmp-track i { position: absolute; top: -4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--series-1); border: 2px solid var(--surface); }
.cmp-track em { position: absolute; top: -3px; bottom: -3px; left: 50%; width: 1px; background: var(--axis); }

/* ---------- tooltip propi (calendari, punts) ---------- */
.tip {
  position: fixed; z-index: 80; pointer-events: none; max-width: 240px;
  background: var(--text-primary); color: var(--surface); border-radius: 8px; padding: 7px 10px;
  font-size: 12.5px; line-height: 1.35; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.tip b { font-weight: 650; }

/* ---------- entrenador ---------- */
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.co-hero { min-height: 190px; }
.co-count {
  flex: none; width: 128px; height: 128px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: var(--surface); border: 10px solid var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent);
}
.co-count b { font-size: 40px; line-height: 1; letter-spacing: -0.03em; }
.co-count span { font-size: 12px; color: var(--text-muted); }
@media (max-width: 520px) { .co-count { width: 96px; height: 96px; border-width: 7px; } .co-count b { font-size: 32px; } }
.co-chip-btn { cursor: pointer; color: var(--accent); }
.co-today-title { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.co-today-plus { font-size: 13px; font-weight: 600; color: var(--text-primary); background: color-mix(in srgb, var(--series-4) 22%, transparent); border-radius: 6px; padding: 1px 6px; vertical-align: middle; }
.co-today-meta { color: var(--text-secondary); font-size: 13.5px; margin: 2px 0 10px; }
.co-target { font-size: 13.5px; color: var(--text-primary); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.co-verdict { font-size: 14px; border-left: 3px solid var(--good); padding: 2px 0 2px 10px; margin: 6px 0; color: var(--text-secondary); }
.co-verdict.warning { border-color: var(--warning); }
.co-verdict.critical, .co-verdict.serious { border-color: var(--critical); }

.co-weeks { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 2px 0 12px; scrollbar-width: thin; }
.co-week {
  flex: 1 0 84px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 10px 8px;
}
.co-week i { display: block; width: 100%; height: 5px; border-radius: 3px; background: var(--seq-1); margin-bottom: 4px; }
.co-week.lv0 i { background: var(--seq-0); } .co-week.lv2 i { background: var(--seq-3); }
.co-week.lv3 i { background: var(--seq-2); } .co-week.lv4 i { background: var(--seq-5); }
.co-week.lv5 i { background: var(--series-2); }
.co-week span { font-size: 13px; font-weight: 600; }
.co-week small { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.co-week.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.co-option-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; max-width: 90ch; }

.co-days { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 1180px) { .co-days { grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: start; } }
.co-day { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); border-top: 4px solid var(--seq-1); }
.co-day.k-rest { border-top-color: var(--grid); background: var(--surface-2); }
.co-day.k-quality { border-top-color: var(--series-2); }
.co-day.k-long { border-top-color: var(--seq-5); }
.co-day.k-race { border-top-color: var(--series-2); background: color-mix(in srgb, var(--series-2) 8%, var(--surface)); }
.co-day.is-today { box-shadow: 0 0 0 2px var(--accent); }
.co-day.is-past { opacity: .78; }
.co-day summary { list-style: none; cursor: pointer; padding: 10px 12px; display: grid; gap: 3px; }
.co-day summary::-webkit-details-marker { display: none; }
.co-day-head { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--text-muted); }
.co-day-head b { color: var(--text-secondary); font-size: 12.5px; }
.co-day-head em { font-style: normal; color: var(--accent); font-weight: 650; margin-left: auto; }
.co-day-title { font-weight: 650; font-size: 14.5px; line-height: 1.25; }
.co-day-meta { font-size: 12.5px; color: var(--text-secondary); }
.co-day-strength { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.co-str { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 3px 7px; border-radius: 7px; font-size: 12px; text-align: left;
  background: color-mix(in srgb, var(--series-4) 16%, transparent); color: var(--text-primary); }
.co-str i { width: 7px; height: 7px; border-radius: 50%; background: var(--series-4); flex: none; }
.co-day-body { padding: 0 12px 12px; font-size: 13px; }
.co-steps { margin: 0 0 8px; padding-left: 18px; color: var(--text-secondary); font-size: 13px; }
.co-steps li { margin-bottom: 4px; }
.co-steps b { color: var(--text-primary); }
.co-why { color: var(--text-muted); font-size: 12.5px; }
.co-why b { color: var(--text-secondary); }
.co-done { border-top: 1px dashed var(--grid); padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.co-done-item { border: 0; background: none; padding: 0; text-align: left; font-size: 12.5px; color: var(--up); font-weight: 600; }
.co-miss { font-size: 12px; color: var(--text-muted); }

.co-pred-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.co-pred-big b { font-size: 36px; letter-spacing: -0.03em; line-height: 1; }
.co-pred-big span { color: var(--text-secondary); font-size: 13px; }
.co-gap { display: grid; gap: 6px; margin-bottom: 12px; }
.co-gap-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.co-table td small, .co-table th small { color: var(--text-muted); font-size: 11.5px; font-weight: 400; }
.co-table td { vertical-align: top; white-space: normal; }
.co-table tr.co-ref td { background: var(--accent-soft); }
.co-z { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.co-z.z1 { background: var(--seq-2); } .co-z.z2 { background: var(--seq-3); } .co-z.z3 { background: var(--seq-4); }
.co-z.z4 { background: var(--seq-5); } .co-z.z5 { background: var(--seq-6); }

.co-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.co-notes li { display: grid; gap: 2px; padding-left: 12px; border-left: 3px solid var(--axis); font-size: 13.5px; }
.co-notes li.good { border-color: var(--good); }
.co-notes li.warning { border-color: var(--warning); }
.co-notes li.critical { border-color: var(--critical); }
.co-notes span { color: var(--text-secondary); }

.co-plan-tabs { margin: 0 0 14px; }
.co-splan { display: grid; gap: 4px 24px; }
@media (min-width: 960px) { .co-splan { grid-template-columns: repeat(2, minmax(0, 1fr)); } .co-splan-info { grid-column: 1 / -1; } }
.co-splan-info { font-size: 14px; color: var(--text-secondary); max-width: 90ch; }
.co-splan-meta { color: var(--text-primary); margin-bottom: 4px; }
.co-block .sub-head { margin-top: 12px; }
.co-ex-list { display: grid; gap: 6px; }
.co-ex { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.co-ex summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; font-size: 13.5px; }
.co-ex summary::-webkit-details-marker { display: none; }
.co-ex summary::after { content: "+"; color: var(--text-muted); font-weight: 600; }
.co-ex[open] summary::after { content: "–"; }
.co-ex-name { font-weight: 600; }
.co-ex-dose { color: var(--text-secondary); margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.co-ex-body { padding: 0 12px 12px; font-size: 13px; color: var(--text-secondary); }
.co-ex-body ul { margin: 6px 0; padding-left: 18px; }
.co-ex-body a { color: var(--accent); }
.co-ex-musc { color: var(--text-muted); font-size: 12.5px; }
.co-media { display: grid; gap: 10px; margin: 10px 0 6px; }
@media (min-width: 720px) { .co-media { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.co-anim-fig { margin: 0; background: var(--surface-2); border-radius: 10px; padding: 6px 6px 4px; }
.co-anim-fig figcaption { font-size: 11.5px; color: var(--text-muted); text-align: center; }
.co-anim { aspect-ratio: 240 / 150; }
.an-svg { width: 100%; height: 100%; display: block; }
.an-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.an-n, .an-f, .an-foot { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.an-n { stroke: var(--text-primary); stroke-width: 4.5; }
.an-f { stroke: var(--text-muted); stroke-width: 4.5; opacity: .75; }
.an-head { fill: var(--text-primary); stroke: none; }
.an-ground { stroke: var(--axis); stroke-width: 1.5; }
.an-bench { fill: var(--surface); stroke: var(--axis); stroke-width: 1.5; }
.an-db { fill: var(--series-1); stroke: none; }
.an-ball { fill: var(--series-2); stroke: none; }
.an-band { stroke: var(--critical); stroke-width: 2; stroke-dasharray: 4 3; fill: none; }
.an-wall { stroke: var(--axis); stroke-width: 3; }
.an-foot { stroke: var(--text-primary); stroke-width: 3; }
.an-label { font-size: 10px; fill: var(--text-muted); stroke: none; }
.co-video { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0b0b0b; }
.co-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.co-video-btn { position: absolute; inset: 0; width: 100%; border: 0; background: linear-gradient(135deg, #1a1a19, #2c2c2a); color: #f0efec; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.co-video-btn span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--critical); color: #fff; font-size: 15px; padding-left: 3px; }
.co-ex-links { font-size: 12.5px; }
.co-lib { display: grid; gap: 8px; }
@media (min-width: 720px) { .co-lib { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
@media (min-width: 1180px) { .co-lib { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.co-lib-item { display: grid; gap: 4px; }
.co-cat { font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }

.co-goal-list { display: grid; gap: 8px; margin-bottom: 14px; }
.co-goal { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.co-goal > div { flex: 1; min-width: 0; display: grid; }
.co-goal small { color: var(--text-muted); font-size: 12.5px; }
.co-goal.is-past { opacity: .6; }
.co-prio { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--accent); color: #fff; flex: none; }
.co-prio.p-B { background: var(--seq-3); } .co-prio.p-C { background: var(--series-other); }
.co-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin: 0 0 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; }
@media (min-width: 960px) { .co-form { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.co-form label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); min-width: 0; }
.co-form .search, .co-form .select { width: 100%; min-width: 0; }
.co-form .w2 { grid-column: span 2; }
.co-form .w-all { grid-column: 1 / -1; }
.co-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.co-primary { background: var(--accent); color: #fff; border-color: transparent; }
.co-primary:hover { background: var(--accent); filter: brightness(1.08); }
.co-danger { color: var(--critical); margin-left: auto; }
.co-prefs { grid-template-columns: repeat(3, minmax(0, 1fr)); border-style: dashed; }
@media (max-width: 560px) { .co-prefs { grid-template-columns: 1fr; } .co-form .w2 { grid-column: 1 / -1; } }

.foot { color: var(--text-muted); font-size: 12px; text-align: center; margin-top: 28px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- entrenador en mode salut ---- */
.co-day.k-pilates { border-top-color: var(--series-6); }
.sa-progress { height: 10px; border-radius: 999px; background: var(--grid); overflow: hidden; margin-top: 14px; }
.sa-progress i { display: block; height: 100%; border-radius: inherit; background: var(--series-1); }
.sa-progress-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin: 4px 0 10px; }
.sa-checks { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sa-checks li { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px; }
.sa-checks li small { color: var(--text-muted); }
.sa-checks li.is-done { border-color: var(--good); }
.sa-checks li.is-done span { color: var(--good); font-weight: 700; }
.sa-dots { letter-spacing: 2px; }
.sa-dots.run { color: var(--series-2); }
.sa-dots.pil { color: var(--series-6); }
.sa-dots.str { color: var(--series-4); }
.sa-dots.none { color: var(--text-muted); }
