:root {
  --bg-primary: #0b1120;
  --bg-card: #151f32;
  --bg-card-hover: #1c2942;
  --border-color: #2a3752;
  --text-muted: #8b98b3;

  /* Azul da marca — ações primárias, ícones e destaques.
     -blue        superfícies e gradientes
     -blue-strong fundo de botão (contraste AA com texto branco)
     -blue-soft   texto/ícones sobre fundo escuro (contraste AA em corpo pequeno) */
  --accent-blue: #3b82f6;
  --accent-blue-strong: #2563eb;
  --accent-blue-soft: #60a5fa;

  --accent-amber: #f59e0b;
  --accent-sky: #38bdf8;      /* azul-claro informativo (gráficos, .text-info) */
  --accent-violet: #a78bfa;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.28);
  --radius-lg: 16px;
  --radius-md: 12px;

  --font-family: 'Lato', 'Segoe UI Variable', 'Segoe UI', Inter, system-ui, -apple-system, sans-serif;
  --heading-weight: 700;

  /* Refresca as cores funcionais do Bootstrap para uma paleta mais atual,
     mantendo os componentes (botões, badges, alerts) do próprio Bootstrap.
     O "success" do Bootstrap é o que o markup usa para as ações primárias
     (.btn-success, .text-success), por isso aponta para o azul da marca. */
  --bs-success: var(--accent-blue);
  --bs-success-rgb: 59, 130, 246;
  --bs-warning: var(--accent-amber);
  --bs-warning-rgb: 245, 158, 11;
  --bs-info: var(--accent-sky);
  --bs-info-rgb: 56, 189, 248;
  --bs-body-bg: var(--bg-primary);
  --bs-body-color: #e5eaf3;
  --bs-border-color: var(--border-color);
}

/* Tipos de letra da plataforma. Uma regra por código de platform_fonts() —
   manter as duas listas em sincronia. O peso dos títulos acompanha o desenho:
   uma condensada não precisa de 700 para se impor, uma geométrica fica pesada
   com ele. */
html[data-font="inter"] {
  --font-family: 'Inter', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --heading-weight: 700;
}

html[data-font="barlow"] {
  --font-family: 'Barlow', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --heading-weight: 600;
}

html[data-font="rubik"] {
  --font-family: 'Rubik', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --heading-weight: 600;
}

html[data-font="source"] {
  --font-family: 'Source Sans 3', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --heading-weight: 700;
}

html[data-font="strait"] {
  --font-family: 'Strait', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --heading-weight: 400;
}

body {
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(59, 130, 246, 0.08), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(56, 189, 248, 0.05), transparent 55%),
    var(--bg-primary);
  /* Sem isto, um fundo mais pequeno do que a página — como estes dois brilhos,
     pensados para aparecer uma vez a ancorar o topo — repete-se por baixo em
     ladrilhos, e a costura de cada ladrilho aparece como uma linha divisória
     numa página comprida (só visível depois de login: as páginas públicas
     cabem no ecrã e nunca chegavam a esticar o suficiente para repetir). */
  background-repeat: no-repeat;
  color: #e5eaf3;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .stat-value {
  font-weight: var(--heading-weight);
}

/* ---- Login ---- */
.login-card {
  background: linear-gradient(180deg, var(--bg-card), var(--bg-card-hover));
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-soft);
}

/* ---- Cards ---- */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s;
}

.chart-title {
  color: #9aa7c2;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Stat Cards ---- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, transform 0.18s, box-shadow 0.18s;
}

.stat-card:hover {
  border-color: #3d4d70;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.stat-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.6rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: rgba(255, 255, 255, 0.05);
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: white;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-mini {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.5rem;
}

/* ---- Sidebar ---- */
:root {
  --sidebar-w-collapsed: 72px;
  --sidebar-w-expanded: 234px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w-collapsed);
  background: rgba(11, 17, 32, 0.96);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: width 0.2s ease, transform 0.25s ease;
}

html[data-sidebar="expanded"] .sidebar {
  width: var(--sidebar-w-expanded);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1rem;
  min-height: 64px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Colapsada (só ícones): o botão de expandir não cabe ao lado da marca
   sem cortar nada, por isso empilha por cima em vez de lado a lado. */
@media (min-width: 992px) {
  html[data-sidebar="collapsed"] .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem 0.5rem;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  /* Branco, a par do logotipo: em azul o conjunto lia-se como duas peças
     diferentes, e o branco tem muito mais contraste sobre a sidebar. */
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
}

/* Em maiúsculas "BAISSANDANDO" é bem mais largo do que em minúsculas e não cabia
   na sidebar expandida — ficava cortado no último "O". Menos corpo e menos
   espaçamento resolvem sem mexer na largura da sidebar. */
.sidebar-brand .wordmark {
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.sidebar-brand i { font-size: 1.4rem; flex-shrink: 0; }

.sidebar-collapse-btn {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #9aa7c2;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.14); color: white; }
.sidebar-collapse-btn i { transition: transform 0.2s ease; display: inline-block; }
html[data-sidebar="collapsed"] .sidebar-collapse-btn i { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.6rem;
  flex-shrink: 0;
  position: relative;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #9aa7c2;
  font-size: 0.88rem;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.sidebar-link i { font-size: 1.2rem; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover, .sidebar-link.active { color: white; background: rgba(255, 255, 255, 0.08); }

.sidebar-label {
  opacity: 1;
  transition: opacity 0.15s ease;
  min-width: 0;
}

html[data-sidebar="collapsed"] .sidebar-label {
  opacity: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  position: absolute;
  pointer-events: none;
}

/* Main content offset to make room for the fixed sidebar.
   .container-fluid já define width:100%, por isso o offset também tem de
   reduzir a largura explicitamente — só o margin-left "empurrava" o
   conteúdo para fora do lado direito da página. */
.main-content.has-sidebar {
  margin-left: var(--sidebar-w-collapsed);
  width: calc(100% - var(--sidebar-w-collapsed));
  transition: margin-left 0.2s ease, width 0.2s ease;
}

html[data-sidebar="expanded"] .main-content.has-sidebar {
  margin-left: var(--sidebar-w-expanded);
  width: calc(100% - var(--sidebar-w-expanded));
}

/* Mobile: sidebar becomes an off-canvas drawer */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1040;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: white;
  font-size: 1.2rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1025;
}

.sidebar-backdrop.show { display: block; }
.sidebar-mobile-toggle.is-hidden { display: none !important; }

@media (max-width: 991.98px) {
  .sidebar {
    width: var(--sidebar-w-expanded) !important;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar .sidebar-label {
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    position: static !important;
  }
  .sidebar-collapse-btn { display: none !important; }
  .main-content.has-sidebar {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 4.5rem !important;
  }
  .sidebar-mobile-toggle { display: flex; }
}

/* ---- Form Controls ---- */
.form-control, .form-select {
  border-radius: 9px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22) !important;
}

.form-control::placeholder {
  color: #57678a;
}

/* ---- Buttons ---- */
.btn {
  border-radius: 9px;
  font-weight: 500;
}

/* Ação primária. Fundo no tom forte para o texto branco cumprir contraste AA. */
.btn-success {
  --bs-btn-bg: var(--accent-blue-strong);
  --bs-btn-border-color: var(--accent-blue-strong);
  --bs-btn-hover-bg: #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
  --bs-btn-active-bg: #1e40af;
  --bs-btn-active-border-color: #1e40af;
}

.btn-outline-success {
  --bs-btn-color: var(--accent-blue-soft);
  --bs-btn-border-color: var(--accent-blue-strong);
  --bs-btn-hover-bg: var(--accent-blue-strong);
  --bs-btn-hover-border-color: var(--accent-blue-strong);
  --bs-btn-hover-color: #fff;
}

/* ---- Scroll horizontal genérico ----
   Para qualquer faixa mais larga do que um ecrã de telemóvel tem margem para
   ceder (grelhas de colunas fixas, grupos de botões, filtros com um botão por
   valor): em vez de deixar o conteúdo sair do ecrã ou espremer-se até ficar
   ilegível, fica dentro das margens e o resto lê-se a deslizar. */
.hscroll {
  overflow-x: auto;
  /* Dentro de uma linha flex, um item por omissão recusa-se a encolher abaixo
     do tamanho do próprio conteúdo (min-width:auto) — e sem isso o overflow-x
     nunca chega a fazer falta, porque é a CAIXA-MÃE que transborda primeiro. */
  min-width: 0;
}

/* ---- Reps table ----
   As colunas fixas de .rep-main/.rep-rest (ver abaixo) já passam dos ~360px de
   ecrã de um telemóvel — sem minmax() nem scroll, a coluna "auto" da distância
   era a única a ceder espaço, e encolhia até ficar invisível. O minmax() trava
   um mínimo; o invólucro .hscroll dá o scroll horizontal. */
.rep-row-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 480px;
}

/* Cada rep tem duas linhas: os dados de trabalho (.rep-main, igual a sempre) e,
   por baixo, a pausa que se segue (.rep-rest) — ver GLOSSARIO.md sobre porque a
   pausa deixou de ser só um número escondido no total da sessão. */
.rep-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 480px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s;
}

.rep-row:hover {
  border-color: #3d4d70;
}

.rep-main {
  display: grid;
  grid-template-columns: 36px minmax(64px, 1fr) 62px 62px 62px 100px 36px;
  gap: 8px;
  align-items: center;
}

.rep-rest {
  display: grid;
  grid-template-columns: 36px 100px 56px 56px 90px;
  gap: 8px;
  align-items: center;
  opacity: .82;
}

.rep-number {
  width: 28px;
  height: 28px;
  background: #263354;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9aa7c2;
}

.rep-pace-badge {
  font-family: 'Cascadia Code', 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--accent-blue-soft);
  font-weight: 600;
}

/* ---- Template reps table (Treinos Pré-definidos) ---- */
.tpl-row-header {
  display: grid;
  grid-template-columns: 36px minmax(64px, 1fr) 100px 56px 56px 90px 36px;
  gap: 8px;
  min-width: 490px;
}

.tpl-row {
  display: grid;
  grid-template-columns: 36px minmax(64px, 1fr) 100px 56px 56px 90px 36px;
  gap: 8px;
  min-width: 490px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s;
}

.tpl-row:hover {
  border-color: #3d4d70;
}

/* ---- Tables ---- */
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
  --bs-table-border-color: var(--border-color);
}

.table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: #7c8bab;
  border-bottom-color: var(--border-color) !important;
}

/* ---- Badges ---- */
.badge {
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 0.4em 0.75em;
}

/* ---- Alerts ---- */
.alert {
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

/* ---- Zonas de treino (badges) ---- */
/* Escala de intensidade: das zonas suaves (azul/verde) às intensas (vermelho/roxo). */
.zone-badge { font-weight: 600; }
.zone-recuperacao { background: #0ea5e9; color: #04222e; }  /* azul   — recuperação */
.zone-resistencia { background: #22c55e; color: #052e14; }  /* verde  — resistência aeróbia */
.zone-lan-v2      { background: #14b8a6; color: #032420; }  /* teal   — limiar aeróbio */
.zone-lan-v4      { background: #f59e0b; color: #2a1a00; }  /* âmbar  — limiar anaeróbio (V4) */
.zone-vo2max      { background: #ef4444; color: #2a0606; }  /* vermelho — VO2 Máx */
.zone-velocidade  { background: #a855f7; color: #1e0733; }  /* roxo   — velocidade / anaeróbio */

/* ---- Mesociclos (tipos de bloco) ----
   A cor de cada tipo é a da sua zona dominante típica (ver mesocycle_types()).
   Tratamento em tom suave — preenchido é reservado aos badges de zona, para os
   dois níveis não competirem visualmente na mesma linha. */
/* A cor do tipo viaja numa custom property, não em `color` — senão o cartão
   inteiro herdaria a cor do tipo em vez de só a barra lateral e o badge. */
.meso-acumulacao    { --meso-color: #22c55e; }   /* verde    — volume / base aeróbia */
.meso-transformacao { --meso-color: #f59e0b; }   /* âmbar    — limiar / lactato */
.meso-realizacao    { --meso-color: #ef4444; }   /* vermelho — específico / afinamento */
.meso-regenerativo  { --meso-color: #0ea5e9; }   /* azul     — recuperação */

.meso-badge {
  font-weight: 600;
  background: transparent;
  color: var(--meso-color, var(--text-muted));
  border: 1px solid var(--meso-color, var(--border-color));
}

/* Cartão de bloco: só a barra lateral usa a cor do tipo */
.meso-card {
  border-left: 3px solid var(--meso-color, var(--border-color));
  transition: border-color 0.2s, transform 0.18s;
}

.meso-card:hover { transform: translateY(-2px); }
.meso-card.is-current { box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35), var(--shadow-soft); }

.meso-current { border-left: 3px solid var(--accent-blue); }

/* Seletor de tipo no formulário */
.meso-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.meso-type-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-color: var(--border-color);
}

.meso-type-label { font-weight: 600; font-size: 0.9rem; }
.meso-type-goal { font-size: 0.72rem; opacity: 0.75; line-height: 1.25; }

.btn-check:checked + .meso-type-btn {
  border-color: var(--meso-color, var(--accent-blue));
  color: var(--meso-color, #fff);
  background: rgba(255, 255, 255, 0.06);
}

/* ================================================================
   Dashboard — KPIs em cima, painéis selecionáveis em baixo.
   ================================================================ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.75rem;
}

.kpi-tile {
  background:
    radial-gradient(420px 160px at 0% 0%, rgba(59, 130, 246, 0.09), transparent 70%),
    var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 148px;
}

/* A pergunta de treino a que o cartão responde — é o que lhe dá direito ao espaço. */
.kpi-question {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7f8db0;
  margin-bottom: 0.35rem;
}

/* Figura de destaque: mesma sans do resto, algarismos proporcionais. */
.kpi-value {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.02em;
  font-variant-numeric: normal;
}

.kpi-unit { font-size: 1.3rem; color: var(--text-muted); font-weight: 600; }

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-note { font-size: 0.73rem; line-height: 1.3; }
.kpi-sub { font-size: 0.78rem; margin-top: auto; padding-top: 0.5rem; line-height: 1.4; }
.kpi-sub a { color: var(--accent-blue-soft); text-decoration: none; }
.kpi-alert { color: #fcd34d; }

/* Estado: cor + ícone + rótulo. A cor nunca vai sozinha. */
.kpi-status { font-weight: 600; }
.kpi-status.is-ok { color: #6ee7b7; }
.kpi-status.is-warning { color: #fcd34d; }
.kpi-status.is-danger { color: #fca5a5; }

/* Barra de polarização: segmentos separados por 2px da superfície. */
.kpi-pol-bar {
  display: flex;
  gap: 2px;
  height: 26px;
  margin: 0.35rem 0 0.5rem;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.kpi-pol-seg { height: 100%; }

.kpi-pol-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kpi-legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.kpi-legend-item strong { color: #cfd8ea; }

.kpi-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0 0.15rem;
}

.kpi-strip strong { color: #cfd8ea; }

/* ---- Grelha de painéis ----
   grid-auto-flow: dense é o que faz o "ajuste automático": esconder um painel
   deixa os restantes fecharem o espaço sem nada a acertar à mão. */
.dash-grid {
  display: grid;
  /* minmax(0, 1fr) e não só 1fr: uma faixa de grid tem por omissão uma largura
     mínima igual ao conteúdo mais largo lá dentro (ex.: a tabela de "Treinos
     recentes"), e é isso — não o ecrã — que decidia a largura da página. O
     min-width:0 no painel faz o mesmo pelo lado do item. */
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 0.85rem;
  transition: opacity 0.15s ease;
}

.dash-grid.is-loading { opacity: 0.55; }   /* mantém o render anterior, sem salto */

.dash-panel { grid-column: span 12; min-width: 0; }

@media (min-width: 992px) {
  .dash-panel.span-6 { grid-column: span 6; }
  .dash-panel.span-4 { grid-column: span 4; }
  .dash-panel.span-12 { grid-column: span 12; }
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

/* Altura que inclui a faixa do eixo x — senão o cartão ganha um scroll interno
   e os rótulos do eixo ficam cortados. */
.chart-container {
  position: relative;
  height: 260px;
}

.dash-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0.6rem 0 0;
}

.dash-note a { color: var(--accent-blue-soft); }

.dash-table {
  margin-top: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;   /* aqui alinham em coluna, aqui faz sentido */
}

.dash-table table { font-size: 0.78rem; }

/* Barras horizontais das zonas: rótulo direto, ordem da escala = ordem das linhas */
.zone-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) 3fr minmax(96px, auto);
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
}

.zone-row-label { font-size: 0.8rem; color: #c2cbe0; }

.zone-row-track {
  height: 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  overflow: hidden;
}

.zone-row-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.zone-row-val { font-size: 0.78rem; text-align: right; white-space: nowrap; }
.zone-row-val strong { color: #fff; }

/* Distribuição realizada vs. alvo do bloco: o traço marca a referência. */
.distrib-row {
  display: grid;
  grid-template-columns: minmax(64px, auto) 1fr minmax(150px, auto);
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0;
}

.distrib-name { font-size: 0.82rem; color: #c2cbe0; }

.distrib-track {
  position: relative;
  height: 18px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.distrib-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  max-width: 100%;
}

.distrib-target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #e5eaf3;
  border-radius: 1px;
}

.distrib-val {
  font-size: 0.76rem;
  text-align: right;
  white-space: nowrap;
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
}

.distrib-val strong { color: #fff; }

/* As duas colunas de largura fixa (rótulo + valor) já somam mais do que o
   espaço livre dentro de um cartão em ecrã de telemóvel — a faixa da barra,
   a única elástica, ficava espremida a um risco quase invisível. Abaixo
   deste ecrã passam a duas linhas: rótulo/valor em cima, barra a toda a
   largura em baixo — continua legível sem precisar de scroll. */
@media (max-width: 480px) {
  .zone-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label val" "bar bar";
    row-gap: 0.3rem;
  }
  .zone-row-label { grid-area: label; }
  .zone-row-val   { grid-area: val; }
  .zone-row-track { grid-area: bar; }

  .distrib-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name val" "bar bar";
    row-gap: 0.3rem;
  }
  .distrib-name  { grid-area: name; }
  .distrib-val   { grid-area: val; }
  .distrib-track { grid-area: bar; }
}

/* ---- Guia recolhível (como medir a FC máxima) ---- */
.hr-guide {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.hr-guide > summary {
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--accent-blue-soft);
  list-style: none;
}

.hr-guide > summary::-webkit-details-marker { display: none; }
.hr-guide > summary::after {
  content: "▾";
  float: right;
  transition: transform 0.2s ease;
  display: inline-block;
}

.hr-guide[open] > summary::after { transform: rotate(180deg); }
.hr-guide > summary:hover { background: rgba(255, 255, 255, 0.04); }

.hr-guide-body {
  padding: 0 0.85rem 0.85rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #c2cbe0;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.hr-guide-body ul, .hr-guide-body ol { padding-left: 1.2rem; }
.hr-guide-body li { margin-bottom: 0.3rem; }
.hr-guide-body strong { color: #e5eaf3; }

/* ---- Validador do plano ---- */
.plan-warnings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.plan-warning {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.5rem 0.7rem;
  border-radius: 9px;
  border-left: 3px solid var(--warn-color);
  background: rgba(255, 255, 255, 0.03);
  color: #c2cbe0;
}

.plan-warning i { color: var(--warn-color); margin-top: 2px; flex-shrink: 0; }

.plan-warning.is-danger  { --warn-color: #ef4444; }
.plan-warning.is-warning { --warn-color: #f59e0b; }
.plan-warning.is-info    { --warn-color: var(--accent-sky); }

.acwr-ok      { background: rgba(34, 197, 94, 0.18);  color: #6ee7b7; }
.acwr-warning { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.acwr-danger  { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }

/* ---- Calendário de planeamento ---- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(108px, 1fr)) minmax(104px, 0.8fr);
  gap: 1px;
  background: var(--border-color);
  min-width: 900px;   /* abaixo disto, o cartão faz scroll horizontal */
}

.plan-head {
  background: var(--bg-card);
  padding: 0.5rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa7c2;
}

.plan-head-sum { text-align: right; }

.plan-day {
  background: var(--bg-card);
  min-height: 104px;
  padding: 0.35rem 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 2px solid var(--meso-color, transparent);
}

.plan-day.is-outside { background: rgba(21, 31, 50, 0.45); }
.plan-day.is-outside .plan-day-num { opacity: 0.4; }
.plan-day.is-today { background: rgba(59, 130, 246, 0.08); }

.plan-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}

.plan-day-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: #cfd8ea;
}

.plan-day.is-today .plan-day-num {
  background: var(--accent-blue-strong);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

.plan-add-btn {
  border: none;
  background: transparent;
  color: #57678a;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.plan-day:hover .plan-add-btn { opacity: 1; }
.plan-add-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.plan-add-btn:focus-visible { opacity: 1; outline: 2px solid var(--accent-blue); }

/* Etiquetas de treino dentro do dia */
.plan-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 0.72rem;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  color: #c2cbe0;
}

.plan-chip:hover { background: rgba(255, 255, 255, 0.1); }
.plan-chip i { font-size: 0.68rem; flex-shrink: 0; }

.plan-chip-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-chip-km {
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.68rem;
  opacity: 0.8;
}

.plan-planned { border-color: rgba(255, 255, 255, 0.12); }
.plan-done    { border-color: rgba(16, 185, 129, 0.4); color: #6ee7b7; }
.plan-missed  { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.plan-skipped { opacity: 0.55; text-decoration: line-through; }

/* Treino efetivamente registado */
.plan-actual {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--accent-blue-soft);
}

/* Coluna de resumo do microciclo */
.plan-week-sum {
  background: rgba(255, 255, 255, 0.02);
  padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
}

.plan-week-label {
  font-weight: 700;
  font-size: 0.68rem;
  color: #9aa7c2;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.plan-sum-row {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #2a3752; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3d4d70; }

/* ---- Distance filter buttons ---- */
#distance-filters .btn.active {
  background-color: #263354;
  color: white;
  border-color: #3d4d70;
}

/* ---- Quick-select / extra-small buttons ---- */
.btn-xs {
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  line-height: 1.4;
  border-radius: 999px;
}

/* ---- Season badge ---- */
.bg-season {
  background-color: rgba(167, 139, 250, 0.18) !important;
  color: var(--accent-violet);
}

/* ---- Marca: o título «Baissandando» ----
   Chakra Petch tem cantos chanfrados e formas retangulares — os mesmos cortes
   angulares do logotipo. Sempre em maiúsculas.

   Não usa var(--font-family) de propósito: a marca não muda quando o
   administrador muda o tipo de letra da interface. */
.wordmark {
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  /* As maiúsculas de uma condensada não precisam de tanto peso vertical. */
  line-height: 1.1;
}

/* Itálico onde a marca é EXIBIDA (hero, cartões de autenticação): o logotipo é
   inclinado, e a prumo o conjunto lia-se desirmanado.
   Vertical onde ela ROTULA (sidebar, nav, rodapé): a 0,9 rem a inclinação não se
   lê como gesto, só como instabilidade ao lado de itens de navegação verticais. */
.wordmark-display {
  font-style: italic;
}

/* Nos cartões de registo e reset a marca acompanha o logotipo em pequeno, acima
   do título da própria página. */
.wordmark-sm {
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  display: block;
}

/* ---- Logo ----
   O ficheiro é branco com fundo transparente, por isso assenta em qualquer
   superfície escura sem tratamento. Servem-se três tamanhos (64/160/320) em vez
   do original de 5000 px: o browser deixa de redimensionar 23 megapixels para
   desenhar 30. */
.brand-logo {
  height: 26px;
  width: auto;
  flex-shrink: 0;
}

.public-brand-logo {
  height: 30px;
  width: auto;
  flex-shrink: 0;
}

.login-logo {
  height: 64px;
  width: auto;
}

/* O logotipo do Sobre leva o MESMO gradiente do título, para o conjunto ler como
   uma peça só em vez de logotipo branco + título em degradê. O PNG branco serve
   de máscara alfa; a cor vem do gradiente por baixo.
   Proporção do ficheiro: 761×862 → 85×96. */
.sobre-logo {
  display: block;
  width: 85px;
  height: 96px;
  margin: 0 auto 0.85rem;
  background: linear-gradient(120deg, #ffffff 20%, var(--accent-blue-soft) 95%);
  -webkit-mask: url('/img/s_baissandando_white_320.png') center / contain no-repeat;
  mask: url('/img/s_baissandando_white_320.png') center / contain no-repeat;
}

.footer-logo {
  height: 34px;
  width: auto;
  opacity: 0.7;
}

/* ---- Escolha de tipo de letra (só administração) ---- */
.font-option {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.font-option:hover { border-color: #3d4d70; }

.font-option.is-active {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.07);
}

.font-option-name { font-weight: 600; color: #fff; }

/* A amostra é escrita no próprio tipo de letra, para a escolha ser informada. */
.font-option-sample {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.02rem;
  color: #cfd8ea;
}

/* Amostras na página de configurações: cada uma no seu próprio tipo de letra. */
[data-font-sample="lato"]   { font-family: 'Lato', system-ui, sans-serif; }
[data-font-sample="inter"]  { font-family: 'Inter', system-ui, sans-serif; }
[data-font-sample="barlow"] { font-family: 'Barlow', system-ui, sans-serif; }
[data-font-sample="rubik"]  { font-family: 'Rubik', system-ui, sans-serif; }
[data-font-sample="source"] { font-family: 'Source Sans 3', system-ui, sans-serif; }
[data-font-sample="strait"] { font-family: 'Strait', system-ui, sans-serif; }

/* ---- Âmbito de cada papel (administração) ---- */
.admin-scope dt {
  color: var(--accent-blue-soft);
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 0.6rem;
}

.admin-scope dt:first-child { margin-top: 0; }

.admin-scope dd {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #c2cbe0;
}

/* ---- Páginas de autenticação (login, registo, reset) ----
   Partilham o mesmo enquadramento das páginas públicas: nav em cima, cartão
   centrado, rodapé em baixo — sem fundos próprios por página. */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Desconta a nav e o rodapé para o cartão ficar centrado no espaço restante
     e o rodapé assentar no fim do ecrã, sem fundo sobrante por baixo. */
  min-height: calc(100vh - 250px);
  padding: 3rem 1.25rem;
}

/* Os links auxiliares do cartão seguem o mesmo tratamento dos da nav/rodapé. */
.login-card a {
  text-decoration: none;
}

.login-card a:hover {
  color: var(--accent-blue-soft) !important;
}

/* ================================================================
   Página pública "Sobre" (/sobre.php)
   Única página com conteúdo indexável — layout próprio, sem sidebar.
   ================================================================ */

/* ---- Barra de navegação pública ---- */
.public-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(11, 17, 32, 0.88);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.public-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.public-page {
  padding: 2.5rem 0 1rem;
}

.public-page .container {
  max-width: 860px;
}

/* ---- Hero ---- */
.sobre-hero {
  text-align: center;
  padding: 1rem 0 2.5rem;
}

.sobre-h1 {
  /* Menos do que em minúsculas: as maiúsculas de "BAISSANDANDO" são bem mais
     largas, e a .wordmark ainda acrescenta espaçamento entre letras. */
  font-size: clamp(1.7rem, 7.5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
  background: linear-gradient(120deg, #ffffff 20%, var(--accent-blue-soft) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sobre-pron {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.4rem;
}

.sobre-pron strong { color: #cfd8ea; }

.sobre-lead {
  font-size: 1.12rem;
  line-height: 1.65;
  color: #cfd8ea;
  max-width: 620px;
  margin: 0 auto 1.75rem;
}

/* ---- Secções ---- */
.sobre-section {
  padding: 2.25rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sobre-h2 {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  color: white;
  margin-bottom: 1rem;
}

.sobre-h2 em { color: var(--accent-blue-soft); font-style: normal; }

.sobre-section > p {
  line-height: 1.7;
  color: #c2cbe0;
}

/* ---- Cartão de dicionário ---- */
.dict-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-blue);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.6rem;
  box-shadow: var(--shadow-soft);
}

.dict-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.dict-word {
  font-size: 1.5rem;
  font-weight: var(--heading-weight);
  color: white;
  letter-spacing: -0.02em;
}

.dict-class {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

.dict-senses {
  margin: 0 0 1rem;
  padding-left: 1.3rem;
  color: #c2cbe0;
  line-height: 1.65;
}

.dict-senses li { margin-bottom: 0.4rem; }

.dict-extra {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.dict-usage {
  background: rgba(59, 130, 246, 0.08);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin: 0;
  font-size: 0.95rem;
  color: #cfd8ea;
}

.dict-usage i { color: var(--accent-blue-soft); margin-right: 0.35rem; }

/* ---- Bloco de anáfora ---- */
.anaphora {
  margin-top: 1.75rem;
  background: linear-gradient(180deg, var(--bg-card), rgba(21, 31, 50, 0.35));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
}

.anaphora-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9aa7c2;
  margin-bottom: 0.9rem;
}

.anaphora-title em { color: var(--accent-blue-soft); font-style: normal; }

.anaphora-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.anaphora-list li {
  padding: 0.5rem 0 0.5rem 1.5rem;
  position: relative;
  line-height: 1.6;
  color: #c2cbe0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.anaphora-list li:last-child { border-bottom: 0; }

.anaphora-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05rem;
  width: 11px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-blue);
}

.anaphora-list strong { color: white; }

/* ---- Baissandómetro ---- */
.meter {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.meter-step {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  transition: border-color 0.2s, transform 0.18s;
}

.meter-step:hover {
  border-color: #3d4d70;
  transform: translateX(3px);
}

.meter-dot {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.meter-name {
  font-weight: 600;
  color: white;
  margin-bottom: 0.15rem;
}

.meter-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ---- Funcionalidades ---- */
.feature-card { transition: border-color 0.2s, transform 0.18s; }
.feature-card:hover { border-color: #3d4d70; transform: translateY(-3px); }

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.14);
  color: var(--accent-blue-soft);
  font-size: 1.1rem;
  margin-bottom: 0.7rem;
}

.feature-title {
  font-size: 1rem;
  font-weight: 600;
  color: white;
  margin-bottom: 0.3rem;
}

.feature-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- Glossário ---- */
.glossary { margin: 0; }

.glossary-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.glossary-item:last-child { border-bottom: 0; }

.glossary dt {
  color: var(--accent-amber);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.glossary dd {
  margin: 0;
  color: #c2cbe0;
  font-size: 0.93rem;
  line-height: 1.6;
}

/* ---- FAQ ---- */
.faq-accordion .accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md) !important;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.faq-accordion .accordion-button {
  background: transparent;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: none;
}

.faq-accordion .accordion-button:not(.collapsed) { color: var(--accent-blue-soft); }

.faq-accordion .accordion-body {
  color: #c2cbe0;
  line-height: 1.7;
  font-size: 0.95rem;
  padding-top: 0;
}

/* ---- CTA final ---- */
.sobre-cta {
  text-align: center;
  padding: 3rem 1.25rem;
  margin: 2.5rem 0 1rem;
  background:
    radial-gradient(600px 220px at 50% 0%, rgba(59, 130, 246, 0.12), transparent 70%),
    var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
}

/* ---- Rodapé público ---- */
.public-footer {
  border-top: 1px solid var(--border-color);
  padding: 2rem 1.25rem 2.5rem;
  margin-top: 2rem;
}

.public-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.public-footer a:hover { color: var(--accent-blue-soft); }
