:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #5f6b64;
  --border: #dcdcd8;
  --accent: #2f6b4f;
  --accent-contrast: #ffffff;
  --accent-soft: #e2efe7;
  --danger: #b3261e;
  --warn: #9a6700;
  --ok: #1e7a46;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06);
  --nav-bg: #eaf1f8;
  --nav-border: #d3dfeb;
  color-scheme: light;
}
/* Tema: data-theme="light" | "dark" no <html>; sem atributo segue o sistema */
:root[data-theme="light"] { color-scheme: only light; }  /* impede o escuro forçado do browser */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816;
    --surface: #1d2320;
    --text: #e7ebe8;
    --muted: #9aa69f;
    --border: #2f3833;
    --accent: #6fbf94;
    --accent-contrast: #0f1a14;
    --accent-soft: #23372c;
    --danger: #f2877e;
    --warn: #e6b450;
    --ok: #6fcf97;
    --shadow: none;
    --nav-bg: #1c2631;
    --nav-border: #2c3a48;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141816;
  --surface: #1d2320;
  --text: #e7ebe8;
  --muted: #9aa69f;
  --border: #2f3833;
  --accent: #6fbf94;
  --accent-contrast: #0f1a14;
  --accent-soft: #23372c;
  --danger: #f2877e;
  --warn: #e6b450;
  --ok: #6fcf97;
  --shadow: none;
  --nav-bg: #1c2631;
  --nav-border: #2c3a48;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 16px; padding-top: max(.6rem, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--accent); }
.topbar nav { display: flex; gap: .25rem; }
.main-nav { margin-left: auto; }
.topbar nav a {
  text-decoration: none; color: var(--muted); padding: .4rem .7rem; border-radius: 8px;
}
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }
.topbar nav a { display: inline-flex; align-items: center; min-height: 40px; }
.nav-icon { display: none; }
@media (max-width: 520px) {
  .topbar { gap: .5rem; padding-left: 12px; padding-right: 12px; }
  /* «Importar» passa a ícone; o texto fica para leitores de ecrã */
  .nav-icon { display: block; }
  .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* navegação principal numa barra fixa em baixo */
  .main-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; margin: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .main-nav a { justify-content: center; min-height: 52px; border-radius: 0; font-size: .95rem; }
  .main-nav a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--accent); }
  .tools-nav { margin-left: auto; }
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}

.container { max-width: 960px; margin: 0 auto; padding: 1rem 16px 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn:disabled { opacity: .6; cursor: progress; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .7rem; min-height: 44px;
  max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
label.block { display: block; margin: .75rem 0; }
label.block textarea { margin-top: .3rem; }

/* Filtros */
.filters { display: grid; gap: .6rem; margin-bottom: 1rem; }
.filters input[type=search] { width: 100%; }
.filters .row { display: flex; flex-wrap: wrap; gap: .6rem; }
.filters .row label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); flex: 1 1 140px; }
.filters .row input, .filters .row select { width: 100%; }
.more-filters { display: grid; gap: .6rem; }
.more-filters[open] { padding-bottom: .25rem; }
.more-filters > summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: .3rem 0; }
.more-filters > * + * { margin-top: .6rem; }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span, .chip {
  display: inline-block; padding: .35rem .75rem; border-radius: 999px; min-height: 36px; line-height: 1.6;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .9rem;
}
.chip-toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Lista */
.totals { margin: 0 0 .75rem; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.activity { position: relative; padding: .8rem 1rem; margin: 0; }
.activity a.stretched { color: inherit; text-decoration: none; display: block; }
.activity-head { display: flex; align-items: center; gap: .5rem; justify-content: space-between; }
.activity .name { font-size: 1.02rem; }
.stats { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .4rem; font-size: .95rem; }
.stats b { font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.tag {
  display: inline-flex; align-items: center; gap: .2rem;
  background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem;
}
.tag-x { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 0 .2rem; min-width: 28px; min-height: 28px; }
.badge { font-size: .75rem; border: 1px solid var(--border); border-radius: 6px; padding: 0 .4rem; color: var(--muted); white-space: nowrap; }
.group { margin-bottom: 1.25rem; }
.group-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; align-items: baseline;
  font-size: 1rem; margin: 0 0 .5rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border);
}
.group-totals { font-weight: 400; color: var(--muted); font-size: .9rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* Importação */
.upload { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.dropzone {
  flex: 1 1 100%; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 120px; border: 2px dashed var(--border); border-radius: var(--radius); padding: 1rem;
  color: var(--muted); cursor: pointer; position: relative;
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.results { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.result { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; align-items: baseline; }
.result > :nth-child(n+3) { grid-column: 2; }
.result .status { font-weight: 600; font-size: .85rem; }
.result.importado .status { color: var(--ok); }
.result.duplicado .status { color: var(--warn); }
.result.erro .status { color: var(--danger); }
.result .file { word-break: break-all; }

/* Detalhe */
.name-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .25rem; }
.title-input { flex: 1 1 260px; font-size: 1.3rem; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin: 1rem 0; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; }
.metric .label { display: block; font-size: .8rem; color: var(--muted); }
.metric .value { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric small { font-size: .8rem; font-weight: 400; color: var(--muted); }
form.inline { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
form.inline input { flex: 1 1 180px; }
.suggestions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.rating { border: 0; padding: 0; margin: 0 0 .75rem; min-width: 0; }
.rating legend { padding: 0; margin-bottom: .3rem; }
.rating .options { display: flex; flex-wrap: wrap; gap: .3rem; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating .options span {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface);
}
.rating .options input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 700; }
.rating .options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.saved { color: var(--ok); margin-left: .75rem; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 2rem; }

/* Mapa e altimetria */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.track-view { margin: 1rem 0; display: grid; gap: .75rem; }
.map {
  width: 100%; height: min(55vh, 460px); min-height: 280px;
  border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; background: var(--surface);
}
.map-tall { height: calc(100vh - 210px); min-height: 360px; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.map-toolbar label { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); }
.legend { display: flex; align-items: center; gap: .5rem; font-size: .85rem; flex-wrap: wrap; }
.legend:empty { display: none; }
.legend-end small { color: var(--muted); }
.legend-ramp { display: inline-flex; gap: 2px; }
.legend-ramp span { width: 18px; height: 10px; border-radius: 2px; }
.profile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .75rem .5rem; }
.profile h2 { margin-bottom: .25rem; }
.profile-canvas { position: relative; height: 200px; }
.map-notice, .map-error {
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface);
}
.map-notice p { margin: .25rem 0; }
.map-error { margin: 1rem; color: var(--muted); }
.info { font: 14px/1.4 system-ui, sans-serif; color: #1f2421; }
.info a { font-weight: 600; color: #2f6b4f; }

/* Definições */
.key-status code { font-size: .9rem; }
.form-error { color: var(--danger); margin: .75rem 0 0; }
.form-warning { color: var(--warn); margin: .75rem 0 0; }
.remove-key { margin-top: .75rem; }
#definicoes-mapas .saved { display: block; margin: .75rem 0 0; }
.map-auth-error { border-color: var(--danger); margin-bottom: .5rem; }
.map-auth-error code { font-size: .85rem; }

/* Perfil desportivo */
.section-nav-unused { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.section-nav a {
  padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem;
}
section[id] { scroll-margin-top: 70px; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem 1rem; margin: .75rem 0; }
.field-grid > label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.with-unit { display: inline-flex; align-items: center; gap: .4rem; }
.with-unit input { width: 7rem; }
.with-unit > span { color: var(--muted); font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; }
.field-error { color: var(--danger); font-size: .85rem; }
[aria-invalid="true"] { border-color: var(--danger); }
.inline-error { margin-left: .75rem; }
.availability { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem .75rem; margin: 1rem 0; min-width: 0; }
.availability legend { padding: 0 .4rem; font-weight: 600; }
.day-row { display: grid; grid-template-columns: 4.75rem auto 1fr; align-items: center; gap: .25rem .75rem; padding: .25rem 0; }
.day-row .field-error { grid-column: 1 / -1; }
.day-hours input { width: 4.75rem; }
.day-rest { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--muted); }
.day-rest input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.zones table { border-collapse: collapse; margin-bottom: 1rem; font-size: .9rem; }
.zones th, .zones td { padding: .3rem .75rem .3rem 0; text-align: left; border-bottom: 1px solid var(--border); }
.zones .num { font-variant-numeric: tabular-nums; text-align: right; }
.injuries { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.injury { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: 10px; }
.injury.active { border-left: 4px solid var(--warn); }
.injury.past { opacity: .75; }
.injury-actions { display: flex; gap: .4rem; align-items: center; }
.injury-form { border-top: 1px solid var(--border); padding-top: .5rem; }
.injury-form .block input { width: 100%; margin-top: .3rem; }

/* Sapatilhas */
.shoes { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.shoe { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; }
.shoe.retired { opacity: .7; }
.shoe-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.shoe-km { margin-top: .2rem; font-variant-numeric: tabular-nums; }
.badge-warn { color: var(--warn); border-color: var(--warn); }
.badge-danger { color: var(--danger); border-color: var(--danger); }
.wear { height: 8px; border-radius: 4px; background: var(--accent-soft); margin: .5rem 0 .25rem; overflow: hidden; }
.wear-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.wear-fill.wear-perto { background: var(--warn); }
.wear-fill.wear-gastas { background: var(--danger); }
.shoe-edit > summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-top: .3rem; }
.shoe-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.shoe-new { border-top: 1px solid var(--border); padding-top: .5rem; }
.shoe-select select { display: block; margin: .3rem 0 .2rem; min-width: 14rem; max-width: 100%; }
.shoe-select .hint { display: block; }

/* Feedback ao gravar */
.toasts {
  position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%);
  bottom: max(1rem, env(safe-area-inset-bottom)); display: grid; gap: .5rem;
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  padding: .75rem 1rem; border-radius: 10px; font-weight: 600; box-shadow: 0 4px 16px rgb(0 0 0 / .25);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: auto;
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { background: var(--accent); color: var(--accent-contrast); }
.toast-erro { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-erro { color: #1a0000; } }
:root[data-theme="dark"] .toast-erro { color: #1a0000; }

/* botão a gravar / gravado / alterações por gravar */
.htmx-request button[type="submit"], button.htmx-request { opacity: .7; cursor: progress; }
.htmx-request button[type="submit"]::after, button.htmx-request::after { content: "…"; }
/* Três estados nos formulários com gravação:
   sem alterações = neutro · alterações por gravar = verde cheio · gravado = contorno verde + ✓ */
form[data-track-changes]:not(.dirty) button[type="submit"]:not(.is-saved) {
  background: var(--surface); border-color: var(--border); color: var(--text);
}
form.dirty button[type="submit"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
  box-shadow: 0 0 0 3px var(--accent-soft); font-weight: 600;
}
form.dirty button[type="submit"]::before { content: "● "; }
button.is-saved, button.is-saved.primary {
  background: transparent; border: 2px solid var(--ok); color: var(--ok); font-weight: 700;
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Pins do mapa geral (estilo do pin do Google Maps) */
.map-pin {
  position: absolute; width: 27px; height: 43px; padding: 0; border: 0; background: none; cursor: pointer;
  transform: translate(-50%, -100%); min-height: 0;
}
.map-pin svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / .4)); }
.map-pin .pin-body { fill: #ea4335; stroke: #b31412; stroke-width: 1; }
.map-pin .pin-dot { fill: #b31412; }
.map-pin:hover .pin-body, .map-pin.selected .pin-body { fill: #c5221f; }
.map-pin.selected { z-index: 2; }
.map-pin:hover, .map-pin:focus-visible { z-index: 1; }
.map-pin:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; border-radius: 4px; }
.map-pin-count {
  position: absolute; left: 0; right: 0; top: 7px; text-align: center;
  font: 700 12px/1 system-ui, sans-serif; color: #ffffff;
}
.info .info-title { font-weight: 700; margin-bottom: .35rem; }
.info ul { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.info li { padding: .3rem 0; border-top: 1px solid #e3e3dc; }
.info li:first-child { border-top: 0; }
.info .info-meta { color: #5f6b64; font-size: 12px; }

/* Provas */
.span-2 { grid-column: span 2; }
@media (max-width: 480px) { .span-2 { grid-column: auto; } }
.goal { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem .75rem; margin: .5rem 0; min-width: 0; }
.goal legend { padding: 0 .4rem; font-weight: 600; }
.goal > label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.goal-options { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-bottom: .6rem; }
.radio { display: inline-flex; align-items: center; gap: .4rem; }
.radio input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.time-input { width: 9rem; }
.result-fields > summary, .race-edit > summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin: .5rem 0; }
.race-new > summary { cursor: pointer; }
.race-new[open] > summary { margin-bottom: .75rem; }
.race-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.race-name { font-size: 1.05rem; margin-right: .25rem; }
.badge-prio { border-color: var(--accent); color: var(--accent); }
.badge-concluida { border-color: var(--ok); color: var(--ok); }
.badge-dnf { border-color: var(--danger); color: var(--danger); }
.countdown { color: var(--text); }
.race-goal, .race-result { margin-top: .35rem; }
.vs-goal { margin-left: .4rem; font-weight: 600; font-size: .9rem; }
.vs-goal.better { color: var(--ok); }
.vs-goal.worse { color: var(--warn); }
.needs-result { color: var(--warn); margin: .5rem 0 0; }
.race-report { white-space: pre-line; margin: .5rem 0 0; }
.race-past { opacity: .92; }
.history { margin-top: 1.5rem; }

/* Plano semanal */
.disclaimer {
  display: flex; gap: .5rem; align-items: flex-start; margin: 0 0 1rem; padding: .5rem .75rem;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border)); border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 7%, var(--surface)); font-size: .82rem; color: var(--muted);
}
.disclaimer .i { color: var(--warn); margin-top: .1rem; }
.disclaimer strong { color: var(--text); }
.plan-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem; }
.plan-totals { display: flex; flex-wrap: wrap; gap: .3rem 1.25rem; font-size: .9rem; margin: .25rem 0 .75rem; }
.plan-days { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.plan-day { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; border-left-width: 4px; }
.plan-day.is-today { box-shadow: 0 0 0 2px var(--accent-soft); }
.plan-day.st-feito { border-left-color: var(--ok); }
.plan-day.st-falhado { border-left-color: var(--danger); }
.plan-day.st-por-fazer { border-left-color: var(--accent); }
.plan-day.st-extra { border-left-color: var(--warn); }
.plan-day-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.day-status { font-size: .85rem; color: var(--muted); }
.st-feito .day-status { color: var(--ok); font-weight: 600; }
.st-falhado .day-status { color: var(--danger); font-weight: 600; }
.planned-session { margin-top: .35rem; }
.ps-main { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.ps-type { font-weight: 600; }
.ps-numbers { font-variant-numeric: tabular-nums; color: var(--muted); }
.ps-objective { font-size: .92rem; margin-top: .15rem; }
.ps-details > summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.done-list { margin-top: .35rem; font-size: .9rem; }
.plan-summary { font-size: 1.02rem; }
.plan-warnings { border: 1px solid var(--warn); border-radius: 10px; padding: .5rem .75rem; margin-bottom: .75rem; }
.plan-warnings ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.plan-error { border: 1px solid var(--danger); border-radius: 10px; padding: .5rem .75rem; margin-top: .75rem; }
.plan-error p { margin: .2rem 0; }
.summary-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; }
@media (max-width: 520px) { .summary-list { grid-template-columns: 1fr; } .summary-list dd { margin-bottom: .4rem; } }
.payload > summary { cursor: pointer; font-weight: 600; margin: .5rem 0; }
.payload pre {
  max-height: 360px; overflow: auto; font-size: .8rem; line-height: 1.35; padding: .75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; white-space: pre-wrap; word-break: break-word;
}
.injury-confirm { border: 1px solid var(--warn); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .75rem; }
.injury-confirm ul { margin: .2rem 0 .5rem; }
.checkbox { display: flex; gap: .5rem; align-items: flex-start; }
.checkbox input { width: 20px; height: 20px; min-height: 0; margin-top: .15rem; flex: none; accent-color: var(--accent); }
.send-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.past-plans { margin: 0; padding-left: 1.2rem; }
.past-plans li { margin: .25rem 0; }

/* toasts acima da barra de navegação do telemóvel */
@media (max-width: 520px) { .toasts { bottom: calc(68px + env(safe-area-inset-bottom)); } }
.warn-text { color: var(--warn); }

/* Aviso de pedido de plano pronto */
.plan-banner {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .75rem;
  padding: .6rem 16px; background: var(--accent); color: var(--accent-contrast); text-decoration: none; font-size: .95rem;
}
.plan-banner-cta { font-weight: 700; white-space: nowrap; }
.ai-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }
#definicoes-ia .saved { display: block; margin: .75rem 0 0; }
.plan-missing { border: 1px solid var(--warn); border-left-width: 4px; border-radius: 10px; padding: .6rem .8rem; }
.plan-missing ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.plan-missing li { margin: .3rem 0; }

/* «Como fazer»: fases da sessão */
.steps { list-style: none; margin: .4rem 0 .2rem; padding: 0; display: grid; gap: .45rem; }
.step { border-left: 3px solid var(--border); padding: .15rem 0 .15rem .65rem; font-size: .92rem; }
.step-aquecimento { border-left-color: #86b6ef; }
.step-parte_principal { border-left-color: var(--accent); }
.step-retorno_calma { border-left-color: #898781; }
.step-dica { border-left-color: var(--warn); }
.step-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .1rem; }
.step-label { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.step-dur { font-size: .8rem; font-variant-numeric: tabular-nums; border: 1px solid var(--border); border-radius: 6px; padding: 0 .35rem; }
.step-text { margin: 0; line-height: 1.45; }
.step-items { margin: .15rem 0 0; padding-left: 1.1rem; line-height: 1.45; }
.step-items li + li { margin-top: .2rem; }

/* Escolha do tema */
.theme-options { display: flex; flex-wrap: wrap; gap: .5rem; border: 0; padding: 0; margin: 0; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option span {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .5rem .9rem;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.theme-option input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); font-weight: 600; }
.theme-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------------------
   Ícones e Definições redesenhadas
   --------------------------------------------------------------------------- */
:root {
  --c-green: #2f6b4f; --c-blue: #2a6fb3; --c-amber: #a05f00; --c-rose: #b8324f;
  --c-violet: #6a4bb5; --c-teal: #137a7a; --c-slate: #4f5b66; --c-orange: #c2410c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-green: #6fbf94; --c-blue: #79b2ee; --c-amber: #e6b450; --c-rose: #f08aa0;
    --c-violet: #b39cf0; --c-teal: #5cc8c8; --c-slate: #a7b3bd; --c-orange: #fb923c;
  }
}
:root[data-theme="dark"] {
  --c-green: #6fbf94; --c-blue: #79b2ee; --c-amber: #e6b450; --c-rose: #f08aa0;
  --c-violet: #b39cf0; --c-teal: #5cc8c8; --c-slate: #a7b3bd; --c-orange: #fb923c;
}

.i {
  width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em;
}
.btn .i { margin-right: .1rem; }

/* atalhos no topo */
.settings-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: 0 0 1.25rem;
}
.settings-tile {
  display: flex; align-items: center; gap: .6rem; padding: .65rem .75rem; min-height: 56px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .92rem; line-height: 1.25;
  transition: border-color .15s, box-shadow .15s;
}
.settings-tile:hover, .settings-tile:focus-visible {
  border-color: var(--sec); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sec) 25%, transparent); outline: none;
}
@media (max-width: 520px) {
  .settings-tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ícone num círculo com a cor da secção */
.sec-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 12px;
  color: var(--sec); background: color-mix(in srgb, var(--sec) 14%, var(--surface));
}
.sec-icon .i { width: 22px; height: 22px; }
.settings-tile .sec-icon { width: 34px; height: 34px; border-radius: 10px; }
.settings-tile .sec-icon .i { width: 19px; height: 19px; }

/* cartões das secções */
.settings-section, .plan-section, .section-card { padding: 0; overflow: hidden; border-top: 4px solid var(--sec); scroll-margin-top: 70px; }
.sec-head {
  display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem;
  background: color-mix(in srgb, var(--sec) 7%, var(--surface));
  border-bottom: 1px solid var(--border);
}
.sec-head h2 { margin: 0; font-size: 1.12rem; color: var(--sec); }
.sec-sub { margin: .1rem 0 0; font-size: .86rem; color: var(--muted); }
.sec-body { padding: 1rem; }
.sec-body > :first-child { margin-top: 0; }
.settings-section h3 { color: var(--sec); font-size: .95rem; margin-top: 1.25rem; }
.settings-section .availability legend, .settings-section .goal legend { color: var(--sec); }
.settings-section .btn.primary:not(.is-saved) { background: var(--accent); }

/* opções do tema com ícone */
.theme-option span { gap: .5rem; }
.theme-option input:checked + span { border-color: var(--sec, var(--accent)); color: var(--sec, var(--accent)); }
.theme-option .i { width: 1.25em; height: 1.25em; }

/* Botão «Topo» (Definições) */
.to-top {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 1500;
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 52px; padding: 0 1.1rem 0 .95rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-contrast); text-decoration: none;
  font-weight: 700; font-size: 1rem; box-shadow: 0 6px 18px rgb(0 0 0 / .3);
  opacity: 0; transform: translate(-50%, 12px) scale(.95); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.to-top.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.to-top .i { width: 22px; height: 22px; stroke-width: 2.5; }
.to-top:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
@media (max-width: 520px) {
  .to-top { bottom: calc(56px + 16px + env(safe-area-inset-bottom)); }  /* acima da barra de navegação */
}
@media (prefers-reduced-motion: reduce) { .to-top { transition: none; } }

/* Menu principal só com ícones */
.topbar .icon-nav { gap: .25rem; }
.topbar .icon-nav a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 12px; color: var(--muted);
}
.topbar .icon-nav a:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.topbar .icon-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.topbar .icon-nav .i { width: 23px; height: 23px; }
.tools-nav { padding-left: .5rem; margin-left: .25rem; border-left: 1px solid var(--border); }
@media (max-width: 520px) {
  .tools-nav { border-left: 0; padding-left: 0; }
  /* barra de baixo: 4 ícones espalhados pela largura toda */
  .topbar .main-nav.icon-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; }
  .topbar .main-nav.icon-nav a { width: auto; height: 56px; border-radius: 0; }
  .topbar .main-nav.icon-nav .i { width: 27px; height: 27px; }
  .topbar .main-nav.icon-nav a[aria-current="page"] { background: var(--accent-soft); box-shadow: inset 0 3px 0 var(--accent); }
}

/* Atalhos das Definições só com ícones */
.settings-tiles { display: flex; flex-wrap: wrap; gap: .6rem; }
.settings-tile {
  width: 56px; height: 56px; min-height: 0; padding: 0; justify-content: center;
  color: var(--sec); background: color-mix(in srgb, var(--sec) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--sec) 35%, var(--border)); border-radius: 16px;
}
.settings-tile .i { width: 26px; height: 26px; }
.settings-tile:hover, .settings-tile:focus-visible { background: color-mix(in srgb, var(--sec) 22%, var(--surface)); }
@media (max-width: 520px) {
  .settings-tiles { display: grid; grid-template-columns: repeat(4, 1fr); }
  .settings-tile { width: auto; }
}


/* ---------------------------------------------------------------------------
   Plano semanal: destaques com cor
   --------------------------------------------------------------------------- */
.sec-action { margin-left: auto; min-height: 38px; padding: .3rem .8rem; font-size: .9rem; }
.plan-section .sec-body, .section-card .sec-body { display: grid; gap: 1rem; }

/* destaques (foco, avisos) */
.callout { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem .9rem; border-radius: 12px;
  border: 1px solid var(--co-border); background: var(--co-bg); }
.callout p, .callout ul { margin: .2rem 0 0; }
.callout ul { padding-left: 1.1rem; }
.callout li + li { margin-top: .25rem; }
.callout-title { display: block; color: var(--co-color); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.callout-icon { display: inline-flex; padding: .4rem; border-radius: 10px; color: var(--co-color);
  background: color-mix(in srgb, var(--co-color) 16%, var(--surface)); }
.callout-icon .i { width: 22px; height: 22px; }
.callout-focus { --co-color: var(--c-violet); --co-bg: color-mix(in srgb, var(--c-violet) 8%, var(--surface));
  --co-border: color-mix(in srgb, var(--c-violet) 35%, var(--border)); font-size: 1.02rem; }
.callout-warn { --co-color: var(--c-amber); --co-bg: color-mix(in srgb, var(--c-amber) 9%, var(--surface));
  --co-border: color-mix(in srgb, var(--c-amber) 40%, var(--border)); font-size: .93rem; }

/* números da semana */
.week-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.stat { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .8rem; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--st) 35%, var(--border)); background: color-mix(in srgb, var(--st) 9%, var(--surface)); }
.stat-planned { --st: var(--c-blue); }
.stat-done { --st: var(--c-green); }
.stat-compliance { --st: var(--c-amber); }
.stat-label { display: flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--st); }
.stat-label .i { width: 16px; height: 16px; }
.stat-value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-value small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.stat-sub { font-size: .82rem; color: var(--muted); }
.stat-bar { display: block; height: 6px; border-radius: 3px; margin-top: .35rem; background: color-mix(in srgb, var(--st) 18%, var(--surface)); overflow: hidden; }
.stat-bar span { display: block; height: 100%; border-radius: 3px; background: var(--st); }
@media (max-width: 520px) {
  .week-stats { gap: .4rem; }
  .stat { padding: .55rem .5rem; }
  .stat-value { font-size: 1.2rem; }
  .stat-label { font-size: .68rem; letter-spacing: .02em; }
  .stat-label .i { display: none; }
}

/* cores por tipo de treino */
.type-descanso { --t: var(--c-slate); }
.type-facil, .type-recuperacao { --t: var(--c-green); }
.type-longao { --t: var(--c-blue); }
.type-intervalos, .type-tempo, .type-fartlek { --t: var(--c-rose); }
.type-subidas, .type-tecnico { --t: var(--c-orange); }
.type-forca { --t: var(--c-violet); }
.type-cruzado { --t: var(--c-teal); }
.type-prova { --t: var(--c-amber); }

/* dias */
.plan-days { list-style: none; padding: 0; margin: 0; display: grid; gap: .65rem; }
.day-card { border: 1px solid var(--border); border-left: 6px solid var(--t, var(--border)); border-radius: 12px;
  padding: .7rem .85rem; background: var(--surface); }
.day-card.type-descanso { background: color-mix(in srgb, var(--c-slate) 5%, var(--surface)); }
.day-card.is-today { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.day-date { display: flex; align-items: baseline; gap: .45rem; }
.day-name { font-weight: 800; font-size: 1.05rem; }
.day-num { color: var(--muted); font-size: .88rem; }
.rest-note { margin: .3rem 0 0; color: var(--muted); font-size: .9rem; }

/* estado do dia */
.status-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap; color: var(--sc, var(--muted));
  background: color-mix(in srgb, var(--sc, var(--muted)) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--sc, var(--muted)) 35%, transparent); }
.status-chip .i { width: 15px; height: 15px; }
.st-feito .status-chip { --sc: var(--c-green); }
.st-falhado .status-chip { --sc: var(--c-rose); }
.st-hoje .status-chip { --sc: var(--c-blue); }
.st-por-fazer .status-chip { --sc: var(--c-slate); }
.st-extra .status-chip { --sc: var(--c-amber); }
.st-descanso .status-chip { --sc: var(--c-slate); }

/* sessão */
.session { margin-top: .55rem; }
.session-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.type-chip { font-weight: 800; font-size: 1rem; color: var(--t); }
.zone { font-size: .75rem; font-weight: 800; padding: .05rem .45rem; border-radius: 6px; color: #fff; background: var(--z, var(--c-slate)); }
.zone-z1 { --z: #3b82f6; } .zone-z2 { --z: #16a34a; } .zone-z3 { --z: #ca8a04; }
.zone-z4 { --z: #ea580c; } .zone-z5 { --z: #dc2626; } .zone-misto { --z: #7c3aed; }
.session-metrics { display: flex; flex-wrap: wrap; gap: .35rem .5rem; margin-top: .35rem; }
.session-metrics span { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .5rem; border-radius: 8px;
  font-size: .86rem; font-weight: 600; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--t) 10%, var(--surface)); color: var(--text); }
.session-metrics .i { width: 15px; height: 15px; color: var(--t); }
.session-objective { margin: .4rem 0 0; font-size: .93rem; }
.ps-details > summary { display: inline-block; margin-top: .45rem; padding: .25rem .65rem; border-radius: 8px; cursor: pointer;
  font-size: .85rem; font-weight: 600; color: var(--t); border: 1px solid color-mix(in srgb, var(--t) 40%, var(--border)); }
.ps-details[open] > summary { background: color-mix(in srgb, var(--t) 10%, var(--surface)); }
.done-list { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .55rem; padding-top: .45rem;
  border-top: 1px dashed var(--border); font-size: .88rem; color: var(--c-green); font-weight: 600; }
.done-list .i { width: 16px; height: 16px; }
.done-list a { font-weight: 600; }
@media (max-width: 520px) {
  .callout-focus { font-size: .93rem; }
  .callout { gap: .55rem; padding: .65rem .7rem; }
  .callout-icon { padding: .3rem; }
  .callout-icon .i { width: 18px; height: 18px; }
}

/* ---------------------------------------------------------------------------
   Ficha do treino
   --------------------------------------------------------------------------- */
.back-link { margin: 0 0 .5rem; }
.back-link a { color: var(--muted); text-decoration: none; font-weight: 600; }
.back-link a:hover { color: var(--accent); }

.activity-hero { margin-bottom: 1rem; }
.activity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; margin-bottom: .5rem; }
.sport-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px;
  font-weight: 700; font-size: .88rem; color: var(--accent); background: var(--accent-soft); }
.sport-chip .i { width: 17px; height: 17px; }
.meta-item { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .9rem; }
.meta-item .i { width: 16px; height: 16px; }
.activity-hero .title-input {
  font-size: 1.55rem; font-weight: 800; border-color: transparent; background: transparent; padding-left: .3rem;
}
.activity-hero .title-input:hover { border-color: var(--border); }
.activity-hero .title-input:focus { border-color: var(--accent); background: var(--surface); }
.hero-tags { margin-top: .35rem; }

.activity-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: .6rem; }
.activity-stats.secondary { grid-template-columns: repeat(2, 1fr); margin-bottom: 1rem; }
.activity-stats .stat-value { font-size: 1.6rem; }
.stat-distance { --st: var(--c-blue); }
.stat-time { --st: var(--c-green); }
.stat-ascent { --st: var(--c-orange); }
.stat-pace { --st: var(--c-violet); }
.stat-hr { --st: var(--c-rose); }
.stat-cadence { --st: var(--c-teal); }
.activity-stats.secondary .stat-value { font-size: 1.3rem; }
@media (max-width: 640px) {
  .activity-stats { grid-template-columns: repeat(2, 1fr); gap: .45rem; }
  .activity-stats .stat-value { font-size: 1.35rem; }
  .activity-hero .title-input { font-size: 1.3rem; }
}

.activity-section .sec-body { display: block; }
.sec-tools { margin-left: auto; display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.sec-tools select { min-height: 38px; padding: .3rem .5rem; }
.activity-section .legend { margin-bottom: .6rem; }
.activity-section .map { border-radius: 10px; }
@media (max-width: 520px) {
  .activity-section .sec-head { flex-wrap: wrap; }
  .sec-tools { margin-left: 0; width: 100%; }
}
.field-title { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }
.field-title .i { color: var(--sec, var(--accent)); }
/* nome do treino: o botão só aparece quando há alterações por gravar (ou acabou de gravar) */
.activity-hero .name-form:not(.dirty) button[type="submit"]:not(.is-saved) { display: none; }

/* ---------------------------------------------------------------------------
   Componentes comuns: título de página
   --------------------------------------------------------------------------- */
.page-title { display: flex; align-items: center; gap: .8rem; margin: .25rem 0 1rem; }
.page-title .sec-icon { width: 46px; height: 46px; border-radius: 14px; }
.page-title .sec-icon .i { width: 25px; height: 25px; }
.page-title h1 { margin: 0; font-size: 1.6rem; line-height: 1.15; }
.page-sub { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }
.page-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
@media (max-width: 520px) {
  .page-title { flex-wrap: wrap; }
  .page-title h1 { font-size: 1.35rem; }
  .page-title .sec-icon { width: 40px; height: 40px; }
}

/* Lista de treinos */
.filters.card { padding: .75rem; }
.search-field { position: relative; }
.search-field .i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field input { width: 100%; padding-left: 2.3rem; }
.list-stats { margin: 0 0 1rem; }
.stat-count { --st: var(--c-slate); }
.activity { border-left: 5px solid var(--c-green); }
.activity-sub { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; margin-top: .3rem; }
.small-chip { font-size: .78rem; padding: .1rem .5rem; }
.card-metrics { --t: var(--c-green); margin-top: .5rem; }
.card-metrics b { font-weight: 800; }
.group-head { border-bottom: 2px solid color-mix(in srgb, var(--c-green) 35%, var(--border)); }
.group-title { display: inline-flex; align-items: center; gap: .4rem; color: var(--c-green); }
.group-totals { display: inline-flex; flex-wrap: wrap; gap: .25rem .75rem; }
.group-totals span { display: inline-flex; align-items: center; gap: .25rem; }
.group-totals .i { width: 15px; height: 15px; }

/* Importar */
.upload { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.dropzone { flex-direction: column; gap: .5rem; border-color: color-mix(in srgb, var(--c-slate) 40%, var(--border));
  background: color-mix(in srgb, var(--c-slate) 5%, var(--surface)); }
.dropzone-icon { color: var(--c-slate); }
.dropzone-icon .i { width: 34px; height: 34px; }
.import-stats { grid-template-columns: repeat(3, 1fr) !important; margin: 0; }
.stat-imported { --st: var(--c-green); }
.stat-duplicate { --st: var(--c-amber); }
.stat-error { --st: var(--c-rose); }
.result { grid-template-columns: auto 1fr; align-items: center; }
.result.importado .status-chip { --sc: var(--c-green); }
.result.duplicado .status-chip { --sc: var(--c-amber); }
.result.erro .status-chip { --sc: var(--c-rose); }

/* Mapa */
.map-hint { display: flex; align-items: center; gap: .35rem; margin: -.5rem 0 .75rem; }
.map-hint .i { color: var(--c-teal); }

/* Provas */
.race { border-left: 5px solid var(--pc, var(--c-slate)); }
.prio-a { --pc: var(--c-rose); }
.prio-b { --pc: var(--c-blue); }
.prio-c { --pc: var(--c-slate); }
.prio-none { --pc: var(--c-amber); }
.prio-chip { font-size: .75rem; font-weight: 800; padding: .1rem .5rem; border-radius: 999px; color: #fff; background: var(--pc); }
.countdown-chip { --sc: var(--c-blue); }
.race-status-concluida { --sc: var(--c-green); }
.race-status-dnf { --sc: var(--c-rose); }
.race-status-dns { --sc: var(--c-slate); }
.race-metrics { --t: var(--c-amber); margin-top: .45rem; }
.race-lines { display: grid; gap: .3rem; margin-top: .5rem; }
.race-goal, .race-result { display: flex; align-items: flex-start; gap: .4rem; margin: 0; }
.race-goal .i { color: var(--c-violet); margin-top: .15rem; }
.race-result .i { color: var(--c-green); margin-top: .15rem; }
.needs-result { margin-top: .5rem; font-size: .92rem; }
.race-edit > summary { display: inline-flex; align-items: center; gap: .35rem; }
details.section-card > summary.sec-head { cursor: pointer; list-style: none; }
details.section-card > summary.sec-head::-webkit-details-marker { display: none; }
details.section-card:not([open]) > summary.sec-head { border-bottom: 0; }
.history .race { opacity: .95; }
.injury-confirm { border: 1px solid var(--co-border); margin: 0; }
.injury-confirm ul { margin: .25rem 0 .5rem; }
.page-title-text { flex: 1 1 0; min-width: 0; }
@media (max-width: 520px) {
  .page-title { flex-wrap: nowrap; align-items: flex-start; }
  .page-title:has(.page-actions) { flex-wrap: wrap; align-items: center; }
  .page-title:has(.page-actions) .page-title-text { flex: 1 1 calc(100% - 60px); }
  .page-actions { margin-left: 0; }
}

/* ---------------------------------------------------------------------------
   Ilustrações dos tipos de treino e de prova
   --------------------------------------------------------------------------- */
.type-trail { --t: var(--c-orange); }
.type-corrida { --t: var(--c-green); }
.type-caminhada { --t: var(--c-teal); }
.type-ultra { --t: var(--c-violet); }
.type-endurance { --t: var(--c-blue); }
.type-sprint { --t: var(--c-rose); }

.illus {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 14px; color: var(--t, var(--accent));
  background: color-mix(in srgb, var(--t, var(--accent)) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--t, var(--accent)) 30%, transparent);
}
.illus svg { width: 86%; height: 86%; fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.illus-sm { width: 40px; height: 40px; border-radius: 11px; }
.illus-lg { width: 76px; height: 76px; border-radius: 18px; }

/* cartões com ilustração à esquerda */
.with-illus { display: flex; gap: .8rem; align-items: flex-start; }
.activity-body, .race-body, .activity-hero-body { flex: 1 1 auto; min-width: 0; }
.activity.with-illus { border-left-color: var(--t); }
.race.with-illus .illus { margin-top: .1rem; }
.hero-main { align-items: center; }
.activity-hero .sport-chip { color: var(--t); background: color-mix(in srgb, var(--t) 13%, var(--surface)); }
.day-head .illus { width: 44px; height: 44px; border-radius: 12px; }
.day-head { justify-content: flex-start; }
.day-head .status-chip { margin-left: auto; }
@media (max-width: 520px) {
  .with-illus { gap: .6rem; }
  .illus { width: 46px; height: 46px; }
  .illus-lg { width: 60px; height: 60px; }
  .day-head .illus { width: 40px; height: 40px; }
}

/* Botão «voltar» */
.back-btn {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; margin: 0 0 .9rem;
  padding: .35rem 1rem .35rem .7rem; border-radius: 999px; text-decoration: none; font-weight: 700;
  color: var(--sec); background: color-mix(in srgb, var(--sec) 12%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--sec) 45%, var(--border));
  transition: background .15s, box-shadow .15s;
}
.back-btn .i { width: 20px; height: 20px; stroke-width: 2.6; }
.back-btn:hover { background: color-mix(in srgb, var(--sec) 20%, var(--surface)); }
.back-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sec) 40%, transparent); }

/* Ilustrações maiores */
.illus { width: 84px; height: 84px; border-radius: 20px; }
.illus svg { width: 90%; height: 90%; }
.illus-lg { width: 120px; height: 120px; border-radius: 26px; }
.day-card .illus { width: 84px; height: 84px; border-radius: 20px; }
.day-body { flex: 1 1 auto; min-width: 0; }
.with-illus { gap: 1rem; }
@media (max-width: 520px) {
  .illus, .day-card .illus { width: 72px; height: 72px; border-radius: 18px; }
  .illus-lg { width: 96px; height: 96px; border-radius: 22px; }
  .with-illus { gap: .75rem; }
}

/* Barra do menu com cor de fundo própria */
.topbar { background: var(--nav-bg); border-bottom-color: var(--nav-border); }
.topbar .icon-nav a:not([aria-current="page"]) { color: color-mix(in srgb, var(--text) 70%, var(--nav-bg)); }
.topbar .icon-nav a[aria-current="page"] { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
@media (max-width: 520px) {
  .topbar .main-nav.icon-nav { background: var(--nav-bg); border-top-color: var(--nav-border); }
  .topbar .main-nav.icon-nav a[aria-current="page"] { background: var(--surface); box-shadow: inset 0 3px 0 var(--accent); }
}

/* Página da prova */
.race-title { margin: 0 0 .3rem; font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.race .stretched { color: inherit; text-decoration: none; display: block; }
.race:hover { border-color: color-mix(in srgb, var(--pc) 45%, var(--border)); }
@media (max-width: 520px) { .race-title { font-size: 1.3rem; } }

/* --- Lista de treinos: gráfico de volume ------------------------------------------------- */
.volume-card { --sec: var(--c-blue); }
.volume-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.volume-head h2 { margin: 0; font-size: 1.1rem; }
.volume-head select { width: auto; }
.volume-totals {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 0; margin: .75rem 0 .25rem;
  font-size: 1.05rem; font-variant-numeric: tabular-nums;
}
.volume-totals span { padding: 0 .9rem; border-left: 1px solid var(--border); }
.volume-totals span:first-child { border-left: 0; }
.volume-totals b { font-size: 1.25rem; font-weight: 800; }
.volume-chart { position: relative; height: 220px; margin: .5rem 0; }
.volume-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem 1.25rem; }
.volume-hint { text-align: center; margin: .5rem 0 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  appearance: none; border: 0; border-left: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; font-weight: 600; padding: .45rem .8rem; min-height: 40px; cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--sec); color: var(--surface); }
.seg button:focus-visible { outline: 2px solid var(--sec); outline-offset: -2px; }
@media (max-width: 520px) {
  .volume-totals { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; text-align: center; }
  .volume-totals span { padding: 0; border-left: 0; }
  .volume-totals b { font-size: 1.1rem; }
  .volume-chart { height: 190px; }
}

/* Provas: treino como fonte do resultado */
.race-source { margin: .75rem 0; padding: .75rem; border: 1px dashed var(--border); border-radius: var(--radius); }
.race-source select { width: 100%; }
.race-source-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .5rem; }
.race-source .hint { margin: .5rem 0 0; }

/* Provas: classificações */
.places { border: 0; padding: 0; margin: .75rem 0; min-width: 0; }
.places legend { font-weight: 600; margin-bottom: .35rem; }
.place-row {
  display: grid; grid-template-columns: 4.2rem minmax(0, 8rem) auto minmax(0, 8rem); align-items: center;
  gap: .4rem .5rem; margin: .35rem 0;
}
.place-row .place-label { font-weight: 600; }
.place-row input { width: 100%; min-width: 0; }
.place-row .field-error { grid-column: 1 / -1; }
.race-places { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: .75rem 0; }
.race-place {
  display: flex; flex-direction: column; gap: .15rem; padding: .65rem .8rem;
  border: 1px solid var(--border); border-left: 4px solid var(--c-violet); border-radius: var(--radius); background: var(--surface);
}
.race-place-label { display: flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; color: var(--c-violet); }
.race-place-label svg { width: 14px; height: 14px; }
.race-place-value b { font-size: 1.5rem; font-weight: 800; }
.race-place-value small { color: var(--muted); font-size: .95rem; }
.race-place-sub { color: var(--muted); font-size: .85rem; }

/* --- Análise do treino: esforço relativo e parciais --------------------------------------- */
.effort-body { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.effort-text { flex: 1 1 260px; }
.effort-text p { margin: 0 0 .4rem; }
.effort-title { font-size: 1.1rem; font-weight: 800; }
.level-dificil .effort-title, .level-muito-dificil .effort-title { color: var(--c-rose); }
.level-leve .effort-title { color: var(--c-green); }
.effort-values { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; color: var(--muted); font-size: .9rem; }
.effort-values b { color: var(--text); font-size: 1.15rem; font-weight: 800; }
.effort-chart { flex: 0 1 300px; width: 100%; max-width: 300px; height: auto; overflow: visible; }
.effort-area { fill: color-mix(in srgb, var(--c-rose) 14%, transparent); }
.effort-line { fill: none; stroke: color-mix(in srgb, var(--c-rose) 45%, transparent); stroke-width: 2; }
.effort-usual { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.effort-dot { fill: var(--surface); stroke: var(--c-rose); stroke-width: 2.5; }
.effort-dot.current { fill: var(--c-rose); stroke: var(--surface); stroke-width: 2; }
.effort-halo { fill: color-mix(in srgb, var(--c-rose) 30%, transparent); }
.effort-chart a:hover .effort-dot { stroke-width: 3.5; }

.route-layout.with-splits { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 1rem; align-items: start; }
.route-layout.with-splits .map { min-height: 420px; height: 100%; }
@media (max-width: 760px) {
  .route-layout.with-splits { grid-template-columns: 1fr; }
  .route-layout.with-splits .splits { order: 2; }
}
.splits-title { margin: 0 0 .4rem; font-size: 1rem; }
.splits-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .92rem; }
.splits-table th, .splits-table td { padding: .4rem .35rem; text-align: right; border-bottom: 1px solid var(--border); }
.splits-table thead th { color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; }
.splits-table th:first-child { text-align: center; width: 2.6rem; }
.splits-table small { color: var(--muted); font-weight: 400; }
.splits-table tbody tr { cursor: pointer; }
.splits-table tbody tr:hover, .splits-table tbody tr:focus-visible, .splits-table tbody tr.pinned {
  background: color-mix(in srgb, var(--c-blue) 10%, transparent); outline: none;
}
.split-pace { position: relative; width: 42%; }
.splits-table th.split-pace-h { text-align: left; padding-left: .5rem; }
.split-bar {
  position: absolute; left: .2rem; top: 50%; transform: translateY(-50%); height: 1.35rem; width: calc(var(--w) * .95);
  background: color-mix(in srgb, var(--c-blue) 22%, transparent); border-radius: 4px;
}
.split-val { position: relative; font-weight: 700; }
.fastest .split-bar { background: color-mix(in srgb, var(--c-green) 35%, transparent); }
.slowest .split-bar { background: color-mix(in srgb, var(--c-amber) 30%, transparent); }
.splits-hint { margin: .5rem 0 0; }
.splits-table td.split-pace { text-align: left; padding-left: .5rem; }

/* --- Carga & forma ------------------------------------------------------------------------- */

/* --- Carga & forma (fz-) ------------------------------------------------------------------- */
.fz-chip, .fz-card, .fz-hl, .fz-today { --t: var(--muted); }
.tone-good { --t: var(--c-green); }
.tone-warn { --t: var(--c-amber); }
.tone-bad { --t: var(--c-rose); }
.tone-neutral { --t: var(--c-slate); }

.fz-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 12px; color: var(--sec, var(--t));
  background: color-mix(in srgb, var(--sec, var(--t)) 14%, transparent);
}
.fz-icon .i { width: 24px; height: 24px; }
.fz-icon.sm { width: 34px; height: 34px; border-radius: 10px; }
.fz-icon.sm .i { width: 19px; height: 19px; }

/* Hoje */
.fz-today {
  margin: 0 0 1.5rem; padding: 1.1rem 1.2rem; border-radius: calc(var(--radius) + 4px);
  background: color-mix(in srgb, var(--t) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--t) 35%, var(--border));
}
.fz-today-head { display: flex; gap: .9rem; align-items: flex-start; flex-wrap: wrap; }
.fz-today-head > div { flex: 1 1 220px; }
.fz-today-icon { color: var(--t); flex: none; }
.fz-today-icon .i { width: 40px; height: 40px; }
.fz-kicker { margin: 0; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--t); }
.fz-today h2 { margin: .1rem 0 .25rem; font-size: 1.45rem; line-height: 1.2; }
.fz-today-text { margin: 0; color: var(--muted); }
.fz-race-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .75rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--c-orange); font-weight: 700; font-size: .88rem;
  text-decoration: none;
}
.fz-race-chip .i { width: 16px; height: 16px; }
.fz-highlights { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1rem 0 0; }
.fz-hl {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: .65rem; align-items: center;
  padding: .75rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  border-top: 4px solid var(--t); color: var(--text); text-decoration: none;
}
.fz-hl .fz-icon { grid-row: 1 / 4; --sec: var(--t); }
.fz-hl-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.fz-hl-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fz-hl-status { font-size: .88rem; font-weight: 700; color: var(--t); }
.fz-todo { margin-top: 1rem; padding: .8rem .95rem; border-radius: var(--radius); background: var(--surface); border: 1px dashed var(--border); }
.fz-todo-title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .35rem; font-weight: 800; }
.fz-todo-title .i { width: 20px; height: 20px; color: var(--c-amber); }
.fz-todo ul { margin: 0; padding-left: 1.6rem; }
.fz-todo li { margin: .2rem 0; }
@media (max-width: 620px) {
  .fz-highlights { grid-template-columns: 1fr; }
  .fz-hl { grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; }
  .fz-hl .fz-icon { grid-row: 1 / 3; }
  .fz-hl-value { grid-row: 1 / 3; grid-column: 3; font-size: 1.45rem; }
}

/* Secções */
.fz-section { margin: 0 0 1.5rem; }
.fz-section-head { display: flex; align-items: center; gap: .75rem; margin: 0 0 .8rem; }
.fz-section-head h2 { margin: 0; font-size: 1.2rem; color: var(--sec); }
.fz-section-head p { margin: .1rem 0 0; color: var(--muted); font-size: .9rem; }
.fz-foot { display: flex; gap: .4rem; align-items: flex-start; color: var(--muted); font-size: .85rem; margin: .6rem 0 0; }
.fz-foot .i { flex: none; width: 16px; height: 16px; margin-top: .1rem; }

/* Prognóstico */
.fz-prog { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.fz-prog-tile {
  display: flex; flex-direction: column; gap: .1rem; padding: .7rem .8rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c-blue);
}
.fz-prog-tile.is-race { border-left-color: var(--c-orange); grid-column: span 2; background: color-mix(in srgb, var(--c-orange) 6%, var(--surface)); }
.fz-prog-label { display: flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .9rem; color: var(--muted); }
.fz-prog-label .i { width: 16px; height: 16px; }
.is-race .fz-prog-label { color: var(--c-orange); }
.fz-prog-time { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.fz-prog-pace { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.fz-prog-note { color: var(--muted); font-size: .8rem; }
@media (max-width: 420px) { .fz-prog { grid-template-columns: 1fr 1fr; } }

/* Cartões dos indicadores */
.fz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .8rem; }
.fz-card {
  display: flex; flex-direction: column; gap: .45rem; padding: .9rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); scroll-margin-top: 80px;
}
.fz-card-head { display: flex; align-items: center; gap: .6rem; }
.fz-card-head h3 { margin: 0; font-size: 1rem; }
.fz-card-value { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.fz-value { font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.fz-chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px;
  font-size: .82rem; font-weight: 800; color: var(--t); background: color-mix(in srgb, var(--t) 13%, transparent);
}
.fz-chip .i { width: 15px; height: 15px; }
.fz-strip { position: relative; margin: .35rem 0 .1rem; }
.fz-zones { display: flex; gap: 2px; height: 10px; }
.fz-zones span { border-radius: 3px; background: color-mix(in srgb, var(--t) 45%, transparent); }
.fz-pin {
  position: absolute; top: -4px; width: 6px; height: 18px; margin-left: -3px; border-radius: 3px;
  background: var(--text); box-shadow: 0 0 0 2px var(--surface);
}
.fz-zone-labels { display: flex; margin-top: .25rem; }
.fz-zone-labels span { font-size: .68rem; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz-bar { display: block; height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--sec) 14%, transparent); margin: .35rem 0 .1rem; }
.fz-bar > span { display: block; height: 100%; border-radius: 5px; background: var(--sec); }
.fz-reading { margin: .1rem 0 0; }
.fz-more summary {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; font-weight: 700; font-size: .88rem; color: var(--sec);
}
.fz-more summary .i { width: 17px; height: 17px; }
.fz-advice { margin: .5rem 0 .4rem; padding: .55rem .7rem; border-radius: 8px; background: color-mix(in srgb, var(--c-amber) 10%, transparent); }
.fz-what { margin: .3rem 0 0; color: var(--muted); font-size: .88rem; }
.fz-prog-real { display: flex; align-items: center; gap: .3rem; margin-top: .2rem; font-size: .8rem; color: var(--c-amber); }
.fz-prog-real .i { width: 14px; height: 14px; flex: none; }
.fz-paces { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.fz-pace {
  display: flex; gap: .8rem; align-items: stretch; padding: .7rem .85rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--z);
}
.fz-pace-code {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 10px; font-weight: 900; font-size: 1.15rem; color: var(--z); background: color-mix(in srgb, var(--z) 14%, transparent);
}
.fz-pace-main { flex: 1; min-width: 0; }
.fz-pace-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.fz-pace-name { display: inline-flex; align-items: center; gap: .35rem; font-weight: 800; color: var(--z); }
.fz-pace-name .i { width: 17px; height: 17px; }
.fz-pace-range { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.fz-pace-range small { color: var(--muted); font-weight: 400; font-size: .8rem; }
.fz-pace-use { margin: .2rem 0 0; font-size: .92rem; }
.fz-pace-pct { margin: .15rem 0 0; font-size: .78rem; color: var(--muted); }

/* Evolução */
.fz-evo-head { flex-wrap: wrap; }
.fz-evo-head > div:not(.seg) { flex: 1 1 200px; }
.fz-period { --sec: var(--c-slate); }
.fz-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.fz-chart {
  margin: 0; padding: .9rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .5rem; min-width: 0;
}
.fz-chart.wide { grid-column: 1 / -1; }
.fz-chart-head { display: flex; align-items: center; gap: .6rem; }
.fz-chart-head h3 { margin: 0; font-size: 1rem; }
.fz-chart-canvas { position: relative; height: 230px; }
.fz-chart.wide .fz-chart-canvas { height: 280px; }
.fz-chart-how { display: flex; gap: .4rem; align-items: flex-start; margin: 0; color: var(--muted); font-size: .85rem; }
.fz-chart-how .i { flex: none; width: 15px; height: 15px; margin-top: .15rem; }
@media (max-width: 760px) {
  .fz-charts { grid-template-columns: 1fr; }
  .fz-chart-canvas, .fz-chart.wide .fz-chart-canvas { height: 220px; }
  .fz-period button { padding: .4rem .55rem; font-size: .85rem; }
}

/* --- Planear a semana -------------------------------------------------------------------- */
.wp-form { display: grid; gap: 1rem; }
.wp-week { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-weight: 700; }
.wp-week .i { width: 20px; height: 20px; color: var(--sec); }
.wp-week select { width: auto; }
.wp { display: grid; gap: .9rem; }
.wp-phase {
  display: flex; gap: .8rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius);
  background: color-mix(in srgb, var(--ph) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ph) 35%, var(--border));
}
.wp-phase h3 { margin: .05rem 0 .2rem; font-size: 1.3rem; color: var(--ph); }
.wp-phase p { margin: 0; }
.wp-timeline { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; }
.wp-seg {
  --s: var(--c-slate); flex: 1 1 0; min-width: 96px; padding: .45rem .55rem; border-radius: 8px;
  background: color-mix(in srgb, var(--s) 12%, transparent); border-top: 4px solid var(--s);
  display: flex; flex-direction: column; gap: .1rem; font-size: .82rem;
}
.wp-seg.seg-base { --s: var(--c-green); } .wp-seg.seg-especifico { --s: var(--c-blue); }
.wp-seg.seg-afinacao { --s: var(--c-orange); } .wp-seg.seg-prova { --s: var(--c-rose); flex-grow: 0; min-width: 110px; }
.wp-seg.seg-recuperacao { --s: var(--c-violet); }
.wp-seg-name { display: flex; align-items: center; gap: .25rem; font-weight: 800; color: var(--s); }
.wp-seg-name .i { width: 14px; height: 14px; }
.wp-seg-dates { color: var(--muted); font-variant-numeric: tabular-nums; }
.wp-seg.is-current { background: color-mix(in srgb, var(--s) 24%, transparent); box-shadow: inset 0 0 0 2px var(--s); }
.wp-seg-now { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--s); }
.wp-copilot { padding: .8rem .95rem; border-radius: var(--radius); border: 1px dashed var(--border); background: var(--surface); }
.wp-copilot-title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .35rem; font-size: 1.02rem; }
.wp-copilot-title .i { width: 20px; height: 20px; color: var(--c-amber); flex: none; }
.wp-copilot ul { margin: 0 0 .35rem; padding-left: 1.6rem; }
.wp-copilot-data { margin: 0; }
.wp-types { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.wp-types legend { font-weight: 800; margin-bottom: .45rem; }
.wp-type { position: relative; cursor: pointer; }
.wp-type input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.wp-type-card {
  display: flex; gap: .65rem; align-items: flex-start; height: 100%; padding: .75rem .8rem; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.wp-type.is-rec .wp-type-card { border-style: dashed; border-color: color-mix(in srgb, var(--c-amber) 60%, var(--border)); }
.wp-type input:checked + .wp-type-card { border-style: solid; border-color: var(--sec); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sec) 20%, transparent); }
.wp-type input:focus-visible + .wp-type-card { outline: 2px solid var(--sec); outline-offset: 2px; }
.wp-type input:disabled + .wp-type-card { cursor: default; }
.wp-type-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.wp-type-name { font-weight: 800; }
.wp-type-desc { font-size: .88rem; }
.wp-type-effect { font-size: .8rem; font-weight: 700; color: var(--sec); }
.wp-rec-chip { display: inline-block; margin-left: .25rem; padding: .05rem .45rem; border-radius: 999px; font-size: .7rem; font-weight: 800;
  color: var(--c-amber); background: color-mix(in srgb, var(--c-amber) 15%, transparent); vertical-align: middle; }
.wp-submit { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.wp-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .6rem; }
.wp-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 800;
  color: var(--b); background: color-mix(in srgb, var(--b) 14%, transparent); }
.wp-badge .i { width: 15px; height: 15px; }

/* Importação da intervals.icu */
.icu-form { display: grid; gap: .75rem; }
.icu-preview, .icu-job { display: grid; gap: .75rem; margin-top: 1rem; }
.icu-job-title { display: flex; align-items: center; gap: .45rem; margin: 0; font-weight: 800; font-size: 1.05rem; }
.icu-job-title .i { width: 20px; height: 20px; color: var(--c-teal); }
.icu-job.state-erro .icu-job-title .i { color: var(--c-rose); }
.icu-progress { height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--c-teal) 15%, transparent); overflow: hidden; }
.icu-progress span { display: block; height: 100%; background: var(--c-teal); border-radius: 6px; transition: width .4s; }
.icu-log summary { cursor: pointer; font-weight: 700; }

/* Lista de treinos: filtros rápidos e páginas */
.quick-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; margin: .65rem 0 .4rem; }
.qf { display: inline-flex; align-items: center; gap: .35rem; }
.qf .i { width: 18px; height: 18px; color: var(--muted); }
.qf select { width: auto; min-width: 0; }
.qf-races span { display: inline-flex; align-items: center; gap: .3rem; }
.qf-races .i { width: 15px; height: 15px; }
.qf-clear { margin-left: auto; }
.page-info { margin: .25rem 0 .5rem; color: var(--muted); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem; margin: .75rem 0; }
.pager-nums { display: inline-flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.pager-num {
  min-width: 2.4rem; height: 2.4rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 .4rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pager-num.is-current { background: var(--c-green); border-color: var(--c-green); color: var(--surface); }
.pager-gap { color: var(--muted); padding: 0 .2rem; }
.pager-step .flip { display: inline-flex; transform: scaleX(-1); }
@media (max-width: 520px) {
  .qf { flex: 1 1 calc(50% - .6rem); }
  .qf select { width: 100%; }
  .qf-clear { margin-left: 0; }
  .pager-step span:not(.flip) { display: none; }
}

/* intervals.icu nas Definições: interruptor e caixa desativada */
.icu-switch { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin: 0 0 .8rem; }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 800; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--border); transition: background .15s; flex: none; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--c-teal); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--c-teal); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.icu-box.is-off .switch-label { color: var(--muted); }
.icu-import { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.icu-import-title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .3rem; font-size: 1.05rem; }
.icu-import-title .i { width: 18px; height: 18px; color: var(--c-teal); }

/* --- Atletas ------------------------------------------------------------------------------- */
.athlete-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%; font-size: .82rem; font-weight: 900; letter-spacing: .02em;
  color: var(--surface); background: var(--ac, var(--c-green));
}
.athlete-avatar.lg { width: 52px; height: 52px; font-size: 1.1rem; }
.athlete-switch { position: relative; margin-left: .4rem; }
.athlete-switch summary {
  list-style: none; display: flex; align-items: center; gap: .45rem; cursor: pointer; padding: .25rem .55rem .25rem .25rem;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700;
}
.athlete-switch summary::-webkit-details-marker { display: none; }
.athlete-switch[open] summary { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.athlete-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 230px; padding: .35rem;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.athlete-menu form { margin: 0; }
.athlete-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .45rem .55rem; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: none;
}
.athlete-item:hover, .athlete-item:focus-visible { background: color-mix(in srgb, var(--accent) 10%, transparent); outline: none; }
.athlete-item.is-current { font-weight: 800; }
.athlete-item .i { width: 16px; height: 16px; margin-left: auto; color: var(--accent); }
.athlete-item.manage { border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: .25rem; color: var(--muted); }
.athlete-item.manage .i { margin-left: 0; color: var(--muted); }
.athletes { display: grid; gap: 1rem; }
.athlete-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.athlete-row { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; border-left: 5px solid var(--ac); }
.athlete-main { flex: 1 1 260px; min-width: 0; }
.athlete-main p { margin: .35rem 0 0; }
.athlete-edit { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.athlete-edit input { flex: 1 1 180px; min-width: 0; }
.athlete-edit select { width: auto; }
.athlete-actions { display: flex; gap: .4rem; }
.athlete-add h2 { display: flex; align-items: center; gap: .4rem; margin: 0 0 .6rem; font-size: 1.1rem; }
@media (max-width: 760px) {
  .athlete-name { display: none; }
  .athlete-switch summary { padding: .2rem; }
}

/* ---------------------------------------------------------------------------
   Calendário de provas (vista de mês e de ano)
   --------------------------------------------------------------------------- */
/* cor = tipo de prova; cheio = próxima, claro = já feita, tracejado = falta o resultado.
   --cs: cor do tipo · --cs-ink: texto sobre a cor cheia (tons «água» claros pedem texto escuro) */
.cal-ev, .cal-mini-day.has-race, .cal-agenda-item, .cal-legend li { --cs: var(--c-amber); --cs-ink: #1f1a10; }
.cal .type-trail, .cal-agenda .type-trail { --cs: #f5a97f; --cs-ink: #3d1e08; }          /* laranja-água */
.cal .type-ultra, .cal-agenda .type-ultra { --cs: #f28b82; --cs-ink: #3f0f0b; }          /* vermelho-água */
.cal .type-endurance, .cal-agenda .type-endurance { --cs: #d32f2f; --cs-ink: #ffffff; }  /* vermelho */
.cal .type-sprint, .cal-agenda .type-sprint { --cs: #5fd3bc; --cs-ink: #08332b; }        /* verde-água */

.cal { padding: .75rem; }
.cal-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; margin-bottom: .75rem; }
.cal-today { min-height: 40px; padding: .35rem .9rem; font-weight: 600; }
.cal-arrows { display: flex; gap: .15rem; }
.cal-arrow { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; color: var(--text); }
.cal-arrow:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.cal-arrow:focus-visible { outline: 2px solid var(--sec); outline-offset: 1px; }
.cal-arrow.next .i { transform: scaleX(-1); }
.cal-title { margin: 0; font-size: 1.3rem; font-weight: 600; flex: 1 1 auto; }
.cal-views { margin-left: auto; }
.seg a { display: inline-flex; align-items: center; padding: .45rem .9rem; min-height: 40px; font-size: .9rem; font-weight: 600;
  color: var(--text); text-decoration: none; border-left: 1px solid var(--border); background: var(--surface); }
.seg a:first-child { border-left: 0; }
.seg a[aria-current="page"] { background: var(--sec); color: var(--surface); }
.seg a:focus-visible { outline: 2px solid var(--sec); outline-offset: -2px; }

.cal-month { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top: 1px solid var(--border); }
.cal-wd { padding: .4rem .25rem; text-align: center; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.cal-day { min-height: 104px; padding: .3rem .25rem .4rem; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day + .cal-day { border-left: 1px solid var(--border); }
.cal-day.weekend { background: color-mix(in srgb, var(--text) 2.5%, var(--surface)); }
.cal-day.out .cal-num { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.cal-num { align-self: center; display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 .3rem;
  border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.cal-day.today .cal-num { background: var(--accent); color: var(--accent-contrast); }
.cal-ev { display: flex; align-items: center; gap: .25rem; min-width: 0; padding: .15rem .4rem; border-radius: 5px;
  font-size: .78rem; font-weight: 600; line-height: 1.3; text-decoration: none;
  color: var(--cs-ink); background: var(--cs); }
.cal-ev:hover { filter: brightness(1.08); }
.cal-ev:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-ev.cs-concluida, .cal-ev.cs-dnf, .cal-ev.cs-dns, .cal-ev.cs-passada {
  color: var(--text); background: color-mix(in srgb, var(--cs) 18%, var(--surface)); box-shadow: inset 3px 0 0 var(--cs); }
.cal-ev.cs-por-registar { color: var(--text); background: color-mix(in srgb, var(--cs) 12%, var(--surface));
  outline: 1px dashed var(--cs); outline-offset: -1px; }
.cal-ev-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-prio { flex: none; font-size: .68rem; padding: 0 .28rem; border-radius: 4px; background: color-mix(in srgb, var(--cs-ink) 18%, transparent); }
.cal-ev:not(.cs-proxima) .cal-prio { background: color-mix(in srgb, var(--cs) 30%, transparent); }

.cal-year { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.25rem 1rem; }
.cal-mini-title { display: inline-block; margin: 0 0 .35rem .3rem; font-weight: 700; color: var(--text); text-decoration: none; }
.cal-mini-title:hover { color: var(--sec); }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-mini-wd { font-size: .68rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal-mini-day { display: inline-grid; place-items: center; aspect-ratio: 1; border-radius: 999px; font-size: .78rem; color: var(--text); text-decoration: none; }
.cal-mini-day.today { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.cal-mini-day.has-race { font-weight: 800; color: var(--cs-ink); background: var(--cs); }
.cal-mini-day.has-race.cs-concluida, .cal-mini-day.has-race.cs-dnf, .cal-mini-day.has-race.cs-dns,
.cal-mini-day.has-race.cs-passada, .cal-mini-day.has-race.cs-por-registar {
  color: var(--text); background: color-mix(in srgb, var(--cs) 25%, var(--surface)); box-shadow: inset 0 0 0 2px var(--cs); }
.cal-mini-day.has-race:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.cal-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; list-style: none; margin: .8rem 0 0; padding: 0; font-size: .82rem; color: var(--muted); }
.cal-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.cal-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--cs); }
.cal-legend .cal-legend-note { margin-left: auto; --cs: var(--muted); }
.cal-legend-note .cal-swatch { margin-left: .4rem; }
.cal-legend-note .cal-swatch:first-child { margin-left: 0; }
.cal-swatch.tint { background: color-mix(in srgb, var(--cs) 25%, var(--surface)); box-shadow: inset 3px 0 0 var(--cs); }
.cal-swatch.dashed { background: transparent; outline: 1px dashed var(--cs); outline-offset: -1px; }

.cal-agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.cal-agenda-item { display: flex; align-items: center; gap: .75rem; padding: .5rem .6rem; border-radius: 10px; color: var(--text);
  text-decoration: none; border: 1px solid var(--border); border-left: 4px solid var(--cs); }
.cal-agenda-item:hover { background: color-mix(in srgb, var(--cs) 7%, var(--surface)); }
.cal-agenda-item .status-chip { --sc: var(--muted); margin-left: auto; }
.cal-agenda-item.cs-proxima .status-chip { color: var(--cs-ink); background: var(--cs); border-color: transparent; }
.cal-agenda-item.cs-por-registar .status-chip { --sc: var(--warn); }
.cal-date { display: grid; justify-items: center; min-width: 2.6rem; line-height: 1.05; }
.cal-date b { font-size: 1.3rem; }
.cal-date small { font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.cal-agenda-main { display: grid; min-width: 0; }
.cal-agenda-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-agenda-main .muted { font-size: .85rem; }

@media (max-width: 600px) {
  .cal { padding: .5rem; }
  .cal-title { order: -1; flex-basis: 100%; font-size: 1.15rem; }
  .cal-day { min-height: 68px; padding: .2rem 2px; }
  .cal-num { min-width: 22px; height: 22px; font-size: .74rem; padding: 0 .15rem; }
  .cal-ev { padding: .1rem .2rem; font-size: .66rem; border-radius: 4px; }
  .cal-prio { display: none; }
  .cal-wd { font-size: .64rem; letter-spacing: 0; }
  .cal-agenda-item { flex-wrap: wrap; }
  .cal-agenda-item .status-chip { margin-left: 3.35rem; }
}

/* ---------------------------------------------------------------------------
   Competições
   --------------------------------------------------------------------------- */
.race-comps { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem .75rem; margin: .5rem 0;
  min-width: 0; display: grid; gap: .6rem; }
.race-comps legend { padding: 0 .4rem; font-weight: 600; }
.race-comps > label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.race-comps .chip-toggle input:checked + span { background: var(--c-violet); border-color: var(--c-violet); color: var(--surface); }
.race-comps > a.hint { justify-self: start; }

.comp-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.comp-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; color: var(--c-violet); text-decoration: none;
  background: color-mix(in srgb, var(--c-violet) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c-violet) 35%, transparent); }
.comp-chip .i { width: 14px; height: 14px; }
a.comp-chip:hover { background: color-mix(in srgb, var(--c-violet) 20%, var(--surface)); }
.comp-line { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; color: var(--c-violet); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-line .i { width: 13px; height: 13px; flex: none; }

.table-wrap { overflow-x: auto; }
.comp-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.comp-table th, .comp-table td { padding: .55rem .5rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.comp-table thead th { color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.comp-table tbody th { font-weight: 600; }
.comp-table tbody th a { color: var(--text); text-decoration: none; }
.comp-table tbody th a:hover { color: var(--c-violet); text-decoration: underline; }
.comp-table tbody tr:hover { background: color-mix(in srgb, var(--c-violet) 5%, var(--surface)); }
.comp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .comp-table thead th:nth-child(3), .comp-table tbody td:nth-child(3) { display: none; }  /* organização */
}

/* ---------------------------------------------------------------------------
   Login
   --------------------------------------------------------------------------- */
.login-body { background: var(--bg); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem 16px; }
.login-card { width: min(380px, 100%); padding: 1.5rem; margin: 0; }
.login-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.3rem; color: var(--accent); margin-bottom: .75rem; }
.login-brand img { border-radius: 12px; }
.login-card h1 { margin: 0 0 .75rem; font-size: 1.4rem; }
.login-form { display: grid; gap: .75rem; }
.login-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.login-form .btn { width: 100%; }
.login-card .hint { margin: .9rem 0 0; }
.login-card code { font-size: .85rem; word-break: break-all; }
.topbar .icon-nav .nav-logout {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 12px; background: none; color: color-mix(in srgb, var(--text) 70%, var(--nav-bg)); cursor: pointer; }
.topbar .icon-nav .nav-logout:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.topbar .icon-nav .nav-logout:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
