/* Andrey Oliveira · Personal Trainer — folha única, mobile-first.
   Tokens no :root (tema escuro padrão) e em [data-theme="light"]. */

/* ============================================================
   TOKENS em 3 níveis
   1. Primitivos  (--p-*): a paleta crua e as escalas. Nunca usados direto nos componentes.
   2. Semânticos  (--bg, --text, --accent, --sp-*, --r-*…): o papel de cada valor;
      o tema claro troca só esta camada.
   3. Componente  (--btn-*, --input-*, --chart-*…): decisões de cada peça, montadas
      a partir dos semânticos.
   Regra: no resto da folha, nada de hex, sombra ou raio solto; use estas variáveis.
   Breakpoints (CSS não aceita var em @media), só estes 4: 420 (celular estreito),
   640 (celular → tablet; max-width 639 é o complemento), 960 (menu lateral) e 1200 (grade larga).
   Larguras de contêiner: tokens --w-xs/sm/md/lg/page (nada de max-width solto em px).
   ============================================================ */
:root {
  /* ---- 1. Primitivos: preto e prata (identidade Andrey Oliveira) ----
     O preto vem do fundo da logo (#0F0E0D). Grafites neutros, sem azulado.
     Prata = cor de marca e de ação (substitui o laranja e o verde-água). Verde, vermelho e
     âmbar ficam só como cores SEMÂNTICAS (sucesso, erro, aviso).
     Contrastes conferidos por script (WCAG 2.2 AA: texto 4,5:1; controles, bordas de campo,
     foco e marcas de gráfico 3:1); os valores estão nos comentários dos semânticos. */
  --p-black-950: #0f0e0d; /* fundo da logo */
  --p-graphite-900: #1a1918;
  --p-graphite-850: #242322;
  --p-graphite-800: #302f2d;
  --p-graphite-700: #3a3836;
  --p-graphite-750: #2c2b29;
  --p-neutral-500: #85888d;
  --p-neutral-400: #a9abaf;
  --p-neutral-50: #f5f5f4;
  --p-paper-100: #efefee;
  --p-paper-200: #e2e2e0;
  --p-paper-300: #d6d5d3;
  --p-paper-600: #56585d;
  --p-white: #ffffff;
  --p-black: #000000;
  --p-silver-100: #e5e7eb; /* prata claro */
  --p-silver-200: #d4d7dc;
  --p-silver-300: #c7cbd1; /* prata principal */
  --p-silver-400: #b4b9c0;
  --p-silver-500: #8b9099; /* prata escuro */
  --p-silver-550: #7d8189; /* borda de campo no escuro */
  --p-silver-600: #7a7e85; /* borda de campo no claro */
  --p-silver-700: #5b6068;
  --p-silver-800: #4b5058;
  --p-silver-900: #2e3136;
  --p-green-950: #052e16;
  --p-green-400: #4ade80;
  --p-green-500: #22c55e;
  --p-green-700: #15803d;
  --p-green-800: #166534;
  --p-red-400: #f87171;
  --p-red-500: #ef4444;
  --p-red-700: #b91c1c;
  --p-amber-400: #fbbf24;
  --p-amber-500: #f59e0b;
  --p-amber-800: #92400e;

  /* ---- 2. Semânticos (tema escuro, padrão) ---- */
  --bg: var(--p-black-950);
  --surface: var(--p-graphite-900);
  --surface-2: var(--p-graphite-850);
  --surface-3: var(--p-graphite-800);
  --line: var(--p-graphite-700); /* divisória decorativa (não identifica controle) */
  --line-soft: var(--p-graphite-750);
  --text: var(--p-neutral-50); /* 17,7:1 bg · 16,1:1 surface · 14,4:1 surface-2 */
  --muted: var(--p-neutral-400); /* 8,4:1 bg · 7,6:1 surface · 6,8:1 surface-2 */
  /* "fill" = superfície preenchida; "text" = texto/ícone sobre o fundo; "ink" = texto sobre o fill */
  --accent: var(--p-silver-300); /* prata: 11,8:1 contra o bg (forma do botão) */
  --accent-hover: var(--p-silver-100);
  --accent-ink: var(--p-black-950); /* preto sobre prata: 11,8:1 (hover 15,6:1) */
  --accent-text: var(--p-silver-200); /* links e item ativo: 13,4:1 bg · 10,9:1 surface-2 */
  --accent-soft: rgb(199 203 209 / 0.14); /* pílula: accent-text sobre ela 8,9:1 */
  --accent-mark: var(
    --p-silver-300
  ); /* indicadores (aba ativa, ponto, borda de destaque): 9,6:1+ */
  --control-border: var(
    --p-silver-550
  ); /* borda de campo: 4,9:1 bg · 4,5:1 surface · 4,0:1 surface-2 */
  --badge-bg: var(--p-silver-300);
  --badge-ink: var(--p-black-950); /* 11,8:1 */
  --ok: var(--p-green-500);
  --ok-ink: var(--p-green-950); /* 6,5:1 sobre o verde */
  --ok-text: var(--p-green-400); /* 11,1:1 bg · 9,0:1 surface-2 · 8,0:1 sobre ok-soft */
  --ok-soft: rgb(34 197 94 / 0.14);
  --danger: var(--p-red-500);
  --danger-strong: var(--p-red-700); /* fill com texto branco: 6,5:1 */
  --danger-ink: var(--p-white);
  --danger-text: var(--p-red-400); /* 7,0:1 bg · 5,7:1 surface-2 */
  --danger-soft: rgb(239 68 68 / 0.14);
  --warn-text: var(--p-amber-400); /* 11,6:1 bg · 9,4:1 surface-2 */
  --warn-soft: rgb(251 191 36 / 0.12);
  --focus: var(--p-white); /* anel de foco branco: 19,3:1 bg · 15,7:1 surface-2 */
  --overlay: rgb(15 14 13 / 0.78);
  --scrim: rgb(15 14 13 / 0.85); /* degradê sobre foto */
  --scrim-soft: rgb(15 14 13 / 0.6);
  --on-media: var(--p-neutral-50); /* texto/ícone sobre foto ou vídeo */
  --media-bg: var(--p-black);
  --glow-accent: rgb(199 203 209 / 0.1);

  --font:
    ui-sans-serif, system-ui, -apple-system, 'Segoe UI Variable Text', 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.75rem; /* mínimo legível: 12 px */
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5625rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.5rem;
  --fs-display: 5.5rem; /* letra da ficha (A, B, C) */

  /* Espaço: escala 4/8/12/16/24 (+ 32/48 só para respiro de layout) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --hairline: 2px; /* traços e folgas de 2 px (indicador de aba, trilho) */

  /* Raio: peças pequenas < controles < cartões < folhas (modal, destaque) */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Sombra: uma só, para o que flutua (toast, timer, avisos) */
  --shadow-pop: 0 12px 32px rgb(0 0 0 / 0.38);

  /* Ícones: um traço só (2 px, 24x24), três tamanhos */
  --icon-xs: 14px;
  --icon-sm: 18px;
  --icon-md: 20px;
  --icon-lg: 24px;
  --icon-xl: 28px;
  --icon-state: 40px;
  --icon-state-lg: 64px;
  /* Marcas e pontos (não são ícones de traço): caixinhas, contadores e bolinhas */
  --mark-lg: 22px; /* caixa de seleção, spinner */
  --mark-badge: 20px; /* contador de não lidas */
  --mark-md: 18px; /* contador compacto (barra de baixo) */
  --mark-sm: 10px; /* ponto de não lida, quadradinho da legenda */
  --mark-xs: 6px; /* bolinha das pílulas */

  /* Movimento: curto (150–250 ms); prefers-reduced-motion zera tudo no fim da folha */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --dur-slow: 250ms;

  /* Camadas */
  --z-raised: 2;
  --z-sticky: 10;
  --z-topbar: 20;
  --z-nav: 30;
  --z-float: 40;
  --z-banner: 60;
  --z-toast: 90;
  --z-skip: 100;

  /* Larguras de contêiner */
  --w-xs: 460px; /* cartão de login, toast, balão de mensagem, avisos flutuantes */
  --w-sm: 560px; /* modal comum, formulários estreitos */
  --w-md: 760px; /* coluna do aluno no computador */
  --w-lg: 820px; /* modal largo */
  --w-page: 1180px; /* conteúdo do personal */

  --tap: 44px;
  --tap-sm: 36px; /* visual; a área de toque continua 44 px com ::after */
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --sidebar-w: 248px;

  /* ---- 3. Componentes ---- */
  --btn-radius: var(--r-md);
  --input-radius: var(--r-md);
  /* Preenchimento automático (Chrome/Brave/Safari pintam o campo de azul-acinzentado):
     mantém o grafite do campo e o texto claro, nos dois temas (segue --surface-2/--text). */
  --autofill-bg: var(--surface-2);
  --autofill-ink: var(--text); /* 14,4:1 escuro · 16,8:1 claro */
  --autofill-shadow: 0 0 0 1000px var(--autofill-bg) inset; /* cobre o fundo do navegador */
  --autofill-hold: 600000s; /* adia para sempre o fundo que o navegador tenta aplicar */
  /* Anel de aderência: tamanho do anel e folga do texto dentro do furo (furo = 71% da largura) */
  --ring-size: 124px;
  --ring-label-pad: 22%; /* recuo do rótulo em relação à borda do anel */
  --card-radius: var(--r-lg);
  --sheet-radius: var(--r-xl);
  --chip-radius: var(--r-pill);
  --tab-indicator: 3px;
  --timer-h: 48px;
  /* Botão primário: prata com texto preto (11,8:1); no claro ganha borda prata escura (5,5:1+) */
  --btn-primary-bg: var(--accent);
  --btn-primary-ink: var(--accent-ink);
  --btn-primary-border: var(--accent);
  /* Gráficos: série principal em prata claro; verde só para "meta atingida" (semântico);
     abaixo da meta neutro e vazado (achado 22). Marcas >= 3:1 contra surface e surface-2. */
  --chart-1: var(--p-silver-100); /* 14,2:1 surface · 12,7:1 surface-2 */
  --today-letter: var(--accent); /* letra decorativa da ficha (Hoje) */
  --chart-good: var(--p-green-500); /* 7,7:1 surface · 6,9:1 surface-2 */
  --chart-off: var(--p-neutral-500); /* abaixo da meta: 4,9:1 surface · 4,4:1 surface-2 */
  --chart-below: var(--chart-off);
  --chart-target: var(--text);
  --chart-grid: var(--line);
  --chart-axis: var(--muted); /* rótulos: 7,6:1 */
  color-scheme: dark;
}

[data-theme='light'] body {
  background-image: none;
}

[data-theme='light'] {
  /* Tema claro: preto sobre prata e branco */
  --bg: var(--p-neutral-50);
  --surface: var(--p-white);
  --surface-2: var(--p-paper-100);
  --surface-3: var(--p-paper-200);
  --line: var(--p-paper-300);
  --line-soft: var(--p-paper-200);
  --text: var(--p-black-950); /* 17,7:1 bg · 19,3:1 surface · 16,8:1 surface-2 */
  --muted: var(--p-paper-600); /* 6,5:1 bg · 7,1:1 surface · 6,2:1 surface-2 */
  --accent: var(--p-silver-300); /* botão prata com texto preto: 11,8:1 */
  --accent-hover: var(--p-silver-400); /* 9,8:1 */
  --accent-text: var(--p-silver-900); /* 12,0:1 bg · 11,3:1 surface-2 */
  --accent-soft: rgb(199 203 209 / 0.3); /* pílula: 11,4:1 */
  --accent-mark: var(--p-silver-800); /* indicadores: 7,4:1 bg · 7,1:1 surface-2 */
  --control-border: var(--p-silver-600); /* 3,7:1 bg · 4,1:1 surface · 3,5:1 surface-2 */
  --badge-bg: var(--p-black-950);
  --badge-ink: var(--p-white); /* 19,3:1 */
  --ok: var(--p-green-700);
  --ok-ink: var(--p-white); /* 5,0:1 */
  --ok-text: var(--p-green-800); /* 6,5:1 bg · 6,2:1 surface-2 · 6,4:1 sobre ok-soft */
  --ok-soft: rgb(34 197 94 / 0.12);
  --danger-text: var(--p-red-700); /* 5,9:1 bg · 5,6:1 surface-2 */
  --danger-soft: rgb(239 68 68 / 0.1);
  --warn-text: var(--p-amber-800); /* 6,5:1 bg · 6,2:1 surface-2 */
  --warn-soft: rgb(245 158 11 / 0.14);
  --focus: var(--p-black-950); /* 17,7:1 bg; também visível sobre o botão prata (11,8:1) */
  --overlay: rgb(15 14 13 / 0.45);
  --shadow-pop: 0 12px 32px rgb(15 14 13 / 0.18);
  --btn-primary-border: var(--p-silver-700); /* 5,8:1 bg · 6,3:1 surface · 5,5:1 surface-2 */
  --chart-1: var(--p-silver-900); /* 13,1:1 surface · 11,3:1 surface-2 */
  --today-letter: var(--p-silver-800); /* 7,4:1 sobre o fundo claro */
  --chart-good: var(--p-green-700); /* 5,0:1 surface · 4,4:1 surface-2 */
  --chart-off: var(--p-silver-600); /* 4,1:1 surface · 3,5:1 surface-2 */
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background-color: var(--bg);
  background-image: url('/static/img/textura-areia.png');
  background-size: 256px 256px;
  background-repeat: repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* palavra enorme sem espaço quebra em vez de estourar (não mexe no min-content das tabelas) */
  overflow-wrap: break-word;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
h1 {
  font-size: var(--fs-xl);
  font-weight: 750;
}
h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
}
h3 {
  font-size: var(--fs-md);
  font-weight: 650;
}
p {
  margin: 0;
}
a {
  color: var(--accent-text);
}
img,
video {
  max-width: 100%;
  display: block;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -60px;
  z-index: var(--z-skip);
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus {
  top: var(--sp-3);
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: var(--fs-sm);
}
.xs {
  font-size: var(--fs-xs);
}
.ok-text {
  color: var(--ok-text);
}
.danger-text {
  color: var(--danger-text);
}
.warn-text {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  color: var(--warn-text);
  font-weight: 600;
}
.warn-text svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex: none;
  margin-top: var(--hairline);
}
.accent-text {
  color: var(--accent-text);
}
.nowrap {
  white-space: nowrap;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  min-width: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ---------- Estrutura ---------- */
.app {
  min-height: 100dvh;
}
.main-col {
  min-width: 0;
}
.sidebar {
  display: none;
}
.view {
  padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--sp-6) + env(safe-area-inset-bottom));
  max-width: var(--w-page);
  margin: 0 auto;
  outline: none;
}
.app[data-layout='public'] .view {
  padding-bottom: var(--sp-6);
}
.app[data-layout='public'] .topbar,
.app[data-layout='public'] .tabbar {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: var(--sp-2) var(--sp-4);
  padding-top: calc(var(--sp-2) + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .brand {
  flex: 1;
  min-width: 0;
}
.topbar-actions {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  min-height: var(--tap); /* área de toque ≥ 44 px */
  gap: var(--sp-3);
  text-decoration: none;
  color: var(--text);
}
/* Logo (SVG branco sobre transparente). No tema claro vira preta, sem outro arquivo. */
.brand-logo {
  display: block;
  flex: none;
  max-width: 100%;
  height: auto;
  user-select: none;
}
[data-theme='light'] .brand-logo {
  filter: brightness(0);
}
.brand-mark {
  width: auto;
  height: 34px;
}
.brand-name {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.brand-role {
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand-name {
  font-weight: 750;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-role {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Barra inferior (celular) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-nav);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--hairline);
  min-height: var(--tabbar-h);
  padding: var(--sp-1) var(--hairline);
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: none;
  border: 0;
  cursor: pointer;
}
.tab svg {
  width: var(--icon-lg);
  height: var(--icon-lg);
}
.tab[aria-current='page'] {
  color: var(--text);
}
.tab[aria-current='page']::before {
  content: '';
  position: absolute;
  top: 0;
  left: 28%;
  right: 28%;
  height: var(--tab-indicator);
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  background: var(--accent-mark);
}
.tab[aria-current='page'] svg {
  color: var(--accent-text);
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--mark-badge);
  height: var(--mark-badge);
  padding: 0 var(--sp-1);
  border-radius: var(--r-pill);
  background: var(--badge-bg);
  color: var(--badge-ink);
  font-size: var(--fs-xs);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.tab .badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 6px);
  min-width: var(--mark-md);
  height: var(--mark-md);
  font-size: var(--fs-xs);
}

/* Menu lateral (desktop) */
@media (min-width: 960px) {
  .app[data-layout='trainer'] {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .app[data-layout='trainer'] .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: var(--sp-5) var(--sp-3);
    border-right: 1px solid var(--line-soft);
    background: var(--bg);
  }
  .app[data-layout='trainer'] .tabbar,
  .app[data-layout='trainer'] .topbar .brand {
    display: none;
  }
  /* No computador o personal navega pelo menu lateral: o topo ficaria vazio (Mensagens está no
     menu e "Mais" é só do celular) */
  .app[data-layout='trainer'] .topbar {
    display: none;
  }
  .app[data-layout='trainer'] .view {
    padding: var(--sp-5) var(--sp-6) var(--sp-7);
  }
  .app[data-layout='student'] .view {
    max-width: var(--w-md);
  }
  /* Aluno no computador: barra inferior com a largura do conteúdo, não da tela toda */
  .app[data-layout='student'] .tabbar {
    left: 50%;
    right: auto;
    width: min(var(--w-md), 100%);
    translate: -50% 0;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
}
.sidebar .brand {
  padding: 0 var(--sp-3) var(--sp-5);
}
/* Menu lateral do computador: logo completa centralizada */
.sidebar .brand-side {
  justify-content: center;
  padding-top: var(--sp-2);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
}
.brand-side .brand-logo {
  width: 152px;
  height: auto;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: var(--hairline);
}
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
button.side-link {
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.side-link svg {
  width: var(--icon-md);
  height: var(--icon-md);
}
.side-link:hover {
  background: var(--surface);
  color: var(--text);
}
.side-link[aria-current='page'] {
  background: var(--surface);
  color: var(--text);
}
.side-link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 10px;
  bottom: 10px;
  width: var(--tab-indicator);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: var(--accent-mark);
}
.side-link[aria-current='page'] svg {
  color: var(--accent-text);
}
.side-link .badge {
  margin-left: auto;
}
.side-foot {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-3) 0;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.net-banner {
  margin: 0;
  padding: var(--sp-2) var(--sp-4);
  background: var(--warn-soft);
  color: var(--warn-text);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
}

/* ---------- Componentes ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border-radius: var(--btn-radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.btn svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex: none;
}
.btn:hover {
  border-color: var(--muted);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: var(--btn-primary-ink);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--btn-primary-border);
}
.btn-ok {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--ok-ink);
}
.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  color: var(--danger-text);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
}
.btn-block {
  width: 100%;
}
.btn-lg {
  min-height: calc(var(--tap) + var(--sp-2));
  font-size: var(--fs-md);
  padding: 0 var(--sp-5);
}
.btn-sm {
  min-height: var(--tap-sm);
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
}
/* Botões pequenos mantêm alvo de toque de 44px com área invisível */
.btn-sm,
.icon-btn {
  position: relative;
}
.btn-sm::after {
  content: '';
  position: absolute;
  inset: -4px 0;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--btn-radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.icon-btn svg {
  width: var(--icon-md);
  height: var(--icon-md);
}
.icon-btn .badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: var(--mark-md);
  height: var(--mark-md);
  font-size: var(--fs-xs);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  min-width: 0;
}
.card-flat {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.card-head h2,
.card-head h3 {
  font-size: var(--fs-md);
}
@media (min-width: 640px) {
  .card {
    padding: var(--sp-5);
  }
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-2) 0 var(--sp-5);
}
.page-head h1 {
  font-size: clamp(var(--fs-xl), 6vw, var(--fs-2xl));
}
.page-head .sub {
  color: var(--muted);
  margin-top: var(--sp-1);
}
.row.center {
  justify-content: center;
}
.results-count {
  margin-bottom: var(--sp-3);
}
.page-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--tap);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-sm);
}
.back-link svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-width: 0;
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.grid {
  display: grid;
  gap: var(--sp-4);
}
.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: minmax(0, 1fr);
  align-items: start; /* cartão curto não estica até a altura do vizinho */
}
@media (min-width: 640px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.span-2 {
  grid-column: 1 / -1;
}

/* Formulários */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.field > span,
.field > label,
.label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}
.field .hint {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 400;
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--input-radius);
  border: 1px solid var(--control-border); /* 3:1+ (WCAG 1.4.11) */
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-md);
}
.textarea {
  min-height: 96px;
  resize: vertical;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}
.input[aria-invalid='true'] {
  border-color: var(--danger);
}
/* Preenchimento automático: o box-shadow interno cobre o fundo do navegador, o
   text-fill-color mantém o texto claro e a transition longa segura o background-color.
   Regras separadas: um seletor desconhecido invalidaria a lista inteira. */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active,
.select:-webkit-autofill,
.textarea:-webkit-autofill {
  -webkit-box-shadow: var(--autofill-shadow);
  box-shadow: var(--autofill-shadow);
  -webkit-text-fill-color: var(--autofill-ink);
  caret-color: var(--autofill-ink);
  transition:
    background-color var(--autofill-hold) step-end,
    color var(--autofill-hold) step-end;
}
.input:-webkit-autofill::first-line {
  font: inherit;
  color: var(--autofill-ink);
}
.input:autofill,
.select:autofill,
.textarea:autofill {
  box-shadow: var(--autofill-shadow);
  -webkit-text-fill-color: var(--autofill-ink);
  caret-color: var(--autofill-ink);
  transition:
    background-color var(--autofill-hold) step-end,
    color var(--autofill-hold) step-end;
}
.form-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid .full {
    grid-column: 1 / -1;
  }
}
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-2) 0;
  cursor: pointer;
}
.check input {
  width: var(--mark-lg);
  height: var(--mark-lg);
  margin: 1px 0 0;
  accent-color: var(--accent-mark);
  flex: none;
}
.form-error {
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.form-error:focus {
  outline: 2px solid var(--danger-text);
  outline-offset: 2px;
}
.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  margin: var(--sp-1) 0 0;
  color: var(--danger-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.field-error-cell {
  font-size: var(--fs-xs);
  min-width: 9rem;
}
.field-error svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
  flex: none;
  margin-top: 3px;
}
.select[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--danger);
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
}
.search {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search svg {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  translate: 0 -50%;
  width: var(--icon-sm);
  height: var(--icon-sm);
  color: var(--muted);
  pointer-events: none;
}
.search .input {
  padding-left: calc(var(--sp-3) + var(--icon-md) + var(--sp-2));
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-4);
}
.toolbar .select {
  width: auto;
  min-width: 10rem; /* "Todos os grupos" inteiro; sem espaço, desce para a linha de baixo */
  flex: 1 1 10rem;
}
/* Celular estreito: busca e cada filtro numa linha (texto do select inteiro) */
@media (max-width: 420px) {
  .toolbar-filters .search,
  .toolbar-filters .select {
    flex: 1 1 100%;
  }
}
@media (min-width: 640px) {
  .toolbar .select {
    flex: 0 1 200px;
  }
}

/* Chips e segmentos: quebram linha em vez de rolar escondidos ("Vencem em 7 di" cortado) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding-bottom: var(--hairline);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap-sm);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
}
.chip::after {
  content: '';
  position: absolute;
  inset: -4px 0;
}
.chip[aria-pressed='true'],
.chip[aria-selected='true'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chips {
  min-width: 0;
  max-width: 100%;
}
.tabs-wrap {
  position: relative;
  margin-bottom: var(--sp-5);
}
/* Sombra nas bordas quando há abas escondidas: pista de que dá para rolar */
.tabs-wrap::before,
.tabs-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 1px;
  width: var(--sp-6);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.tabs-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg), transparent);
}
.tabs-wrap::after {
  right: 0;
  background: linear-gradient(270deg, var(--bg), transparent);
}
.tabs-wrap.more-left::before,
.tabs-wrap.more-right::after {
  opacity: 1;
}
.tabs {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-padding-inline: var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar,
.chips::-webkit-scrollbar {
  display: none;
}
.tabs [role='tab'] {
  position: relative;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  background: none;
  border: 0;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}
.tabs [role='tab'][aria-selected='true'] {
  color: var(--text);
}
.tabs [role='tab'][aria-selected='true']::after {
  content: '';
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: -1px;
  height: var(--tab-indicator);
  border-radius: var(--r-xs) var(--r-xs) 0 0;
  background: var(--accent-mark);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--hairline) var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text);
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: var(--mark-xs);
  height: var(--mark-xs);
  border-radius: 50%;
  background: currentColor;
}
.pill-ok {
  background: var(--ok-soft);
  color: var(--ok-text);
}
.pill-warn {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.pill-danger {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.pill-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.pill-muted {
  /* surface-2 + muted: 5,0:1 no escuro e 7:1 no claro (WCAG AA) */
  background: var(--surface-2);
  color: var(--muted);
}

/* Listas */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.list > li + li {
  border-top: 1px solid var(--line-soft);
}
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 60px;
  padding: var(--sp-3) 0;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
a.list-item:hover .list-title {
  color: var(--accent-text);
}
.list-title {
  font-weight: 650;
}
.list-sub {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 750;
  font-size: var(--fs-sm);
  flex: none;
  letter-spacing: 0.02em;
}
.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: var(--fs-lg);
}
.dot {
  width: var(--mark-sm);
  height: var(--mark-sm);
  border-radius: 50%;
  background: var(--accent-mark);
  flex: none;
}

/* Tabelas */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th,
.table td {
  text-align: left;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table th {
  color: var(--muted);
  font-weight: 600;
}
.table td.r,
.table th.r {
  text-align: right;
}

/* Tabela compacta com rolagem lateral (avaliações): a 1ª coluna fica fixa à esquerda */
.table-scroll {
  position: relative; /* o texto sr-only das colunas fica dentro da rolagem */
  overflow-x: auto;
}
.table-compact th,
.table-compact td {
  padding: var(--sp-2) var(--sp-3);
  white-space: nowrap;
}
.table-compact tbody th {
  position: sticky;
  left: 0;
  z-index: var(--z-raised);
  background: var(--surface);
  color: var(--text);
}
.delta-sm {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 639px) {
  table.table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  table.table-cards,
  table.table-cards tbody,
  table.table-cards tr,
  table.table-cards th,
  table.table-cards td {
    display: block;
  }
  table.table-cards tr {
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--line-soft);
  }
  table.table-cards tr:last-child {
    border-bottom: 0;
  }
  table.table-cards td,
  table.table-cards tbody th {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-1) 0;
    border: 0;
    text-align: right;
  }
  table.table-cards td::before,
  table.table-cards tbody th::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
  }
  table.table-cards td:not([data-label]) {
    justify-content: flex-end;
    padding-top: var(--sp-2);
  }
  table.table-cards td:not([data-label])::before {
    content: none;
  }
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}
@media (min-width: 960px) {
  .kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-4);
  }
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}
a.kpi:hover {
  border-color: var(--line);
}
.kpi-label {
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.kpi-value {
  font-size: clamp(1.25rem, 5.4vw, var(--fs-2xl));
  overflow-wrap: anywhere;
  font-weight: 780;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi-foot {
  font-size: var(--fs-xs);
  color: var(--muted);
}
.kpi-danger .kpi-value {
  color: var(--danger-text);
}

/* Assinatura visual: anel de aderência (anilha) */
.ring {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  flex: none;
}
@media (min-width: 640px) {
  :root {
    --ring-size: 140px;
  }
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring .ring-track {
  stroke: var(--surface-3);
}
.ring .ring-bar {
  stroke: var(--chart-below);
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-slow) var(--ease);
}
.ring .ring-bar.ok {
  stroke: var(--chart-good);
}
/* Marca da meta (80%) atravessando o anel */
.ring .ring-goal {
  stroke: var(--chart-target);
  stroke-width: 3;
  stroke-linecap: round;
}
.ring-label {
  position: absolute;
  inset: 0;
  /* % do padding é da largura do anel: o texto fica no miolo do furo em qualquer tamanho */
  padding: var(--ring-label-pad);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--hairline);
  line-height: 1.05;
}
.ring-label strong {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 640px) {
  .ring-label strong {
    font-size: var(--fs-xl);
  }
}
.ring-label span {
  max-width: 100%;
  text-align: center;
  line-height: 1.2;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.adherence-box {
  min-width: 0;
}
.adh-title {
  font-size: var(--fs-md);
}
.adh-empty {
  max-width: 32ch;
}
.rings {
  display: flex;
  gap: var(--sp-5);
  align-items: center;
  flex-wrap: wrap;
}

.hero {
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border-radius: var(--sheet-radius);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--glow-accent), transparent 55%), var(--surface);
  border: 1px solid var(--line-soft);
}
@media (min-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: var(--sp-6);
  }
}
.hero h1 {
  font-size: var(--fs-2xl);
}
@media (min-width: 960px) {
  .hero h1 {
    font-size: var(--fs-3xl);
  }
}

/* Estados */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-4);
  color: var(--muted);
}
.state > svg {
  width: var(--icon-state);
  height: var(--icon-state);
  color: var(--muted);
}
.state h2,
.state h3 {
  color: var(--text);
  font-size: var(--fs-md);
}
.state p {
  max-width: 44ch;
}
.state-error > svg {
  color: var(--danger-text);
}
.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  min-height: 70vh;
  color: var(--muted);
}
.boot-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.boot-logo {
  width: auto;
  height: 72px;
}
.spinner {
  width: var(--mark-lg);
  height: var(--mark-lg);
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent-mark);
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  min-height: 72px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Avisos */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--warn-text);
  border: 1px solid color-mix(in srgb, var(--warn-text) 35%, transparent);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.notice svg {
  width: var(--icon-md);
  height: var(--icon-md);
  flex: none;
  margin-top: 1px;
}
.notice-info {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

/* Toasts */
.toasts {
  position: fixed;
  z-index: var(--z-toast);
  left: 50%;
  translate: -50% 0;
  /* No topo, logo abaixo do cabeçalho: não cobre a barra de baixo, os botões de um modal
     (que no celular abre por baixo) nem o fim do formulário. */
  top: calc(var(--topbar-h) + var(--sp-2) + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(92vw, var(--w-xs));
  pointer-events: none;
}
/* #toasts é um popover (top layer): fica acima de um <dialog> aberto. Zera o estilo padrão. */
.toasts[popover] {
  inset: auto;
  left: 50%;
  top: calc(var(--topbar-h) + var(--sp-2) + env(safe-area-inset-top));
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
  height: auto;
}
.toast {
  pointer-events: auto;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-pop);
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast-error {
  background: var(--danger-strong);
  color: var(--danger-ink);
}
.toast-ok {
  background: var(--ok);
  color: var(--ok-ink);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Modal (dialog nativo) */
dialog.modal {
  width: min(100vw, var(--w-sm));
  /* folga no topo para os avisos (toasts), que aparecem logo abaixo do cabeçalho */
  max-height: calc(100dvh - var(--topbar-h) - var(--sp-6));
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  background: var(--surface);
  color: var(--text);
}
@media (min-width: 640px) {
  dialog.modal {
    margin: auto;
    border-radius: var(--sheet-radius);
  }
  dialog.modal.modal-wide {
    width: min(94vw, var(--w-lg));
  }
}
dialog.modal::backdrop {
  background: var(--overlay);
}
.modal-head {
  position: sticky;
  top: 0;
  z-index: var(--z-raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 {
  font-size: var(--fs-lg);
}
.modal-body {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
/* Botões do fim do modal ficam sempre à vista (modais longos, como Nova avaliação) */
.modal-body > .form-actions:last-child,
.modal-body > form > .form-actions:last-child {
  position: sticky;
  bottom: 0;
  z-index: var(--z-raised);
  margin: 0 calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5));
  padding: var(--sp-3) var(--sp-5);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line-soft);
}

/* Login e telas públicas */
.auth {
  min-height: calc(100dvh - var(--sp-6));
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(100%, var(--w-xs));
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
/* Login e convite: logo completa centralizada, sem animação */
.auth-brand {
  display: flex;
  justify-content: center;
  padding-bottom: var(--sp-2);
}
.auth-brand .brand-logo {
  width: min(70%, 220px);
  height: auto;
}
.terms-brand {
  display: flex;
  justify-content: center;
}
.terms-brand .brand-logo {
  width: auto;
  height: 56px;
}
.auth-title {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.02;
}
.auth-lede {
  color: var(--muted);
  margin-top: var(--sp-2);
}
.terms {
  max-height: 220px;
  overflow: auto;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.terms h3 {
  color: var(--text);
  font-size: var(--fs-sm);
  margin: var(--sp-3) 0 var(--sp-1);
}
.terms h3:first-child {
  margin-top: 0;
}
.terms p + p {
  margin-top: var(--sp-2);
}
.offline-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--sp-4);
  max-width: var(--w-xs);
  margin: 0 auto;
  padding: var(--sp-5);
}
.offline-page p {
  color: var(--muted);
}
.offline-page .brand-logo {
  width: 160px;
  height: auto;
  align-self: center;
}

/* Lista de alunos */
.student-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 640px) {
  .student-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .student-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.student-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  text-decoration: none;
  color: var(--text);
}
.student-card:hover {
  border-color: var(--line);
}
.meter {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--chart-below);
}
.meter > span.ok {
  background: var(--ok);
}

.profile-head {
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.profile-head > .grow {
  flex: 1 1 12rem;
  min-width: 0;
}
.profile-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
}
.profile-head h1 {
  font-size: clamp(var(--fs-xl), 6vw, var(--fs-2xl));
}
.dl {
  display: grid;
  /* rótulo nunca passa de 40% da linha: o valor sempre tem espaço (antes a pergunta longa
     comia a coluna e a resposta saía uma letra por linha) */
  grid-template-columns: fit-content(40%) minmax(0, 1fr);
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  font-size: var(--fs-sm);
}
.dl dt {
  color: var(--muted);
}
.dl dd {
  margin: 0;
  overflow-wrap: break-word;
}
/* Perguntas e respostas (anamnese): pergunta em cima, resposta embaixo */
.qa {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.qa > li {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.qa > li:first-child {
  border-top: 0;
  padding-top: 0;
}
.qa-q {
  color: var(--muted);
}
.qa-a {
  font-weight: 650;
  overflow-wrap: break-word;
}
.qa-a.qa-yes {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  align-self: flex-start;
  padding: var(--hairline) var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--danger-soft);
  color: var(--danger-text);
}
.qa-a.qa-yes svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
}
@media (min-width: 640px) {
  .qa > li {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-5);
  }
  .qa-q {
    flex: 1;
    min-width: 0;
  }
  .qa-a {
    flex: none;
    max-width: 45%;
    text-align: right;
  }
}
.copy-box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.copy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.copy-actions .btn {
  flex: 1 1 160px;
}
.req {
  color: var(--muted);
  font-weight: 400;
}
.copy-box .input {
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}

/* Fotos */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--sp-3);
}
.photo {
  position: relative;
  margin: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 3 / 4;
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--sp-4) var(--sp-2) var(--sp-2);
  background: linear-gradient(transparent, var(--scrim));
  color: var(--on-media);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.photo-select {
  position: absolute;
  top: var(--sp-1);
  right: var(--sp-1);
  width: var(--tap);
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-select input {
  width: var(--mark-lg);
  height: var(--mark-lg);
  accent-color: var(--accent-mark);
}
.photo-del {
  position: absolute;
  top: var(--sp-1);
  left: var(--sp-1);
}
.photo-del .icon-btn,
.photo-select {
  background: var(--scrim-soft);
  border-radius: var(--r-sm);
  color: var(--on-media);
}
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

/* Gráficos (cores em --chart-*, validadas nos dois temas) */
.chart {
  position: relative;
  width: 100%;
  margin: 0;
}
.chart svg {
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
  border-radius: var(--r-sm);
}
.delta {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
}
.delta strong {
  font-size: var(--fs-lg);
  font-weight: 800;
}
.chart .grid-line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}
.chart .axis-text {
  fill: var(--chart-axis);
  font-size: var(--fs-xs);
  font-family: var(--font);
}
.chart .line {
  fill: none;
  stroke: var(--chart-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .pt {
  fill: var(--surface);
  stroke: var(--chart-1);
  stroke-width: 2;
}
.chart .pt-last {
  fill: var(--chart-1);
}
.chart .bar.hit {
  fill: var(--chart-good);
}
/* Abaixo da meta: vazada (contorno 1,5 px + fundo fraco). Forma diferente, não só cor. */
.chart .bar.off {
  fill: color-mix(in srgb, var(--chart-off) 28%, transparent);
  stroke: var(--chart-off);
  stroke-width: 1.5;
}
.chart .bar.partial {
  fill: transparent;
  stroke: var(--chart-off);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}
.chart .target {
  stroke: var(--chart-target);
  stroke-dasharray: 4 4;
  stroke-width: 1.5;
}
.chart .value-text {
  fill: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-family: var(--font);
}
.chart .cursor {
  stroke: var(--muted);
  stroke-width: 1;
}
.chart .cursor-dot {
  fill: none;
  stroke: var(--text);
  stroke-width: 2;
}
.chart-tip {
  position: absolute;
  z-index: var(--z-raised);
  translate: 0 -100%; /* left em px calculado no JS (cabe inteira no gráfico) */
  display: flex;
  flex-direction: column;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-xs);
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
}
.chart-tip strong {
  font-size: var(--fs-sm);
}
.chart-legend {
  display: flex;
  gap: var(--sp-2) var(--sp-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: var(--sp-2);
}
.chart-legend i {
  display: inline-block;
  width: var(--mark-sm);
  height: var(--mark-sm);
  border-radius: var(--r-xs);
  margin-right: var(--sp-1);
  vertical-align: -1px;
}
.chart-legend i.ok {
  background: var(--chart-good);
}
.chart-legend i.off {
  background: color-mix(in srgb, var(--chart-off) 28%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--chart-off);
}
.chart-legend i.partial {
  border: 1.5px dashed var(--chart-off);
}
.chart-legend i.target {
  height: 0;
  border-radius: 0;
  border-top: 2px dashed var(--chart-target);
  vertical-align: 3px;
}
details.data-table {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
}
details.data-table summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

/* Treino (editor e hoje) */
.workout-tabs {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.workout-tab {
  min-width: 56px;
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  font-size: var(--fs-lg);
  cursor: pointer;
}
.workout-tab[aria-selected='true'] {
  background: var(--accent);
  border-color: var(--accent-mark);
  color: var(--accent-ink);
}
.ex-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.ex-card:focus {
  /* foco levado pelo app (depois de adicionar ou reordenar): mostra onde a pessoa está */
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.ex-card.dragging {
  opacity: 0.5;
}
.ex-card.drop-target {
  border-color: var(--accent-mark);
}
.ex-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--sp-3);
}
/* Nome do exercício quebra entre palavras; os botões descem de linha se faltar espaço */
.ex-head > .grow {
  flex: 1 1 9rem;
}
.ex-head h2,
.ex-head h3 {
  overflow-wrap: break-word;
}
.ex-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-2);
}
.ex-title-row .btn {
  margin-left: auto;
}
.ex-tools {
  display: flex;
  margin-left: auto;
}
.ex-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  font-weight: 800;
  font-size: var(--fs-sm);
  flex: none;
  font-variant-numeric: tabular-nums;
}
.drag-handle {
  cursor: grab;
  color: var(--muted);
}
.sets-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 var(--sp-2);
  font-size: var(--fs-sm);
}
.sets-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 0 var(--sp-1);
}
.sets-table td {
  padding: 0 var(--sp-1);
}
.sets-table th:first-child,
.sets-table td:first-child {
  width: 2.25rem;
}
.sets-table .input {
  width: 100%;
  min-width: 3rem;
  padding: var(--sp-2) var(--sp-1);
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield; /* sem as setinhas: no celular elas cortavam "47,5" */
}
.sets-table .input::-webkit-inner-spin-button,
.sets-table .input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}
.sets-table .input-load {
  min-width: 4.5rem; /* cabe "147,5" em 360 px */
}

/* Seletor de exercícios (lista de botões grandes) */
.pick-status:empty {
  display: none;
}
.pick-error[hidden] {
  display: none;
}
.pick-list > li + li {
  border-top: 1px solid var(--line-soft);
}
.pick-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3) var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.pick-item:hover {
  background: var(--surface-2);
}
.pick-item .list-title,
.pick-item .list-sub {
  display: block;
}
.pick-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-sm);
  height: var(--tap-sm);
  flex: none;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--accent-text);
}
.pick-mark svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
}
.pick-item.added .pick-mark {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--ok-ink);
}

/* Editor de treino: um só "Salvar" fixo embaixo */
/* Sem nada pendente fica no fim da página; com alteração, gruda embaixo (sempre à vista) */
.save-bar[data-dirty='true'] {
  position: sticky;
}
.save-bar {
  z-index: var(--z-sticky);
  bottom: calc(var(--tabbar-h) + var(--sp-2) + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow-pop);
}
.save-bar[data-dirty='true'] {
  border-color: var(--accent-mark);
}
.save-state {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}
.save-bar[data-dirty='true'] .save-state {
  color: var(--text);
}
.save-bar .field-error {
  margin: 0;
}
@media (min-width: 960px) {
  .app[data-layout='trainer'] .save-bar {
    bottom: var(--sp-3);
  }
}
.workout-tab-title {
  display: none;
}
@media (min-width: 640px) {
  .workout-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
  }
  .workout-tab-title {
    display: inline;
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fs-sm);
    font-weight: 600;
  }
}

/* Tela "Hoje" do aluno */
.hero.today-hero {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-4);
}
.today-letter {
  font-size: var(--fs-display);
  font-weight: 850;
  line-height: 0.85;
  letter-spacing: -0.06em;
  color: var(--today-letter);
}
.set-track {
  display: flex;
  gap: var(--sp-1);
}
.set-track span {
  flex: 1;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}
.set-track span.done {
  background: var(--ok);
}
.set-row {
  display: grid;
  /* kg ganha mais espaço: "122,5" cabe inteiro em 360 px */
  grid-template-columns: var(--sp-5) minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) var(--tap);
  gap: var(--sp-1);
  align-items: center;
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.set-row.done {
  background: var(--ok-soft);
}
.set-row .set-n {
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.set-row .input {
  padding: var(--sp-2) var(--hairline);
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.set-row .field > span {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.check-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--r-md);
  border: 2px solid var(--line);
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.check-btn svg {
  width: var(--icon-xl);
  height: var(--icon-xl);
}
.check-btn[aria-pressed='true'] {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--ok-ink);
}
.last-load {
  font-size: var(--fs-xs);
  color: var(--muted);
}
/* Modo foco (treino em andamento): sem barra de baixo; timer e Finalizar descem junto */
body.focus-mode {
  --tabbar-h: 0px;
}
body.focus-mode .tabbar {
  display: none;
}

/* Aviso de mensalidade em Hoje (Pagamentos fica em Conta) */
.due-slot:empty {
  display: none;
}
.due-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--warn-text);
  border: 1px solid color-mix(in srgb, var(--warn-text) 35%, transparent);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
}
.due-card svg {
  width: var(--icon-md);
  height: var(--icon-md);
  flex: none;
}
.due-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  text-decoration: underline;
}
.timer {
  position: fixed;
  z-index: var(--z-float);
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: calc(var(--tabbar-h) + var(--sp-2) + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--timer-h);
  padding: 0 var(--sp-2) 0 var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-pop);
  max-width: var(--w-sm);
  margin: 0 auto;
  overflow: hidden;
}
.timer svg {
  width: var(--icon-lg);
  height: var(--icon-lg);
  flex: none;
}
.timer-body {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  min-width: 0;
  white-space: nowrap;
}
.timer-label {
  font-size: var(--fs-xs);
  font-weight: 600;
}
.timer-time {
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
}
.timer .btn {
  flex: none;
  background: transparent;
  color: var(--bg);
  border-color: color-mix(in srgb, var(--bg) 30%, transparent);
  padding-inline: var(--sp-3);
}
.timer.done {
  background: var(--ok);
  color: var(--ok-ink);
}
/* Finalizar: no fim da página enquanto há séries por fazer (não cobre nada); flutua só
   quando todas estão feitas. */
.finish-bar.ready {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--sp-2) + env(safe-area-inset-bottom));
  z-index: var(--z-sticky);
  transition: bottom var(--dur-base) var(--ease);
}
/* Com o timer na tela, o botão Finalizar sobe para ficar acima dele (nunca coberto). */
body.has-timer .finish-bar.ready {
  bottom: calc(
    var(--tabbar-h) + var(--sp-2) + var(--timer-h) + var(--sp-2) + env(safe-area-inset-bottom)
  );
}
body.has-timer .view {
  padding-bottom: calc(
    var(--tabbar-h) + var(--sp-6) + var(--timer-h) + env(safe-area-inset-bottom)
  );
}
.summary-tap {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  cursor: pointer;
}
.congrats {
  text-align: center;
  align-items: center;
  padding: var(--sp-6) var(--sp-4);
}
.congrats > svg {
  width: var(--icon-state-lg);
  height: var(--icon-state-lg);
  color: var(--ok);
}
.congrats .big {
  font-size: var(--fs-3xl);
  font-weight: 850;
  letter-spacing: -0.04em;
}
.pending-flag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--warn-text);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.pending-flag svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
  flex: none;
}
/* Celular estreito: a marca encolhe e o aviso de pendência mostra só o número */
@media (max-width: 420px) {
  .topbar .pending-flag .pf-long {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Chat */
.inbox {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 960px) {
  .inbox {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }
}
.chat {
  display: flex;
  flex-direction: column;
  height: calc(
    100dvh - var(--topbar-h) - var(--tabbar-h) - var(--sp-7) - env(safe-area-inset-bottom)
  );
  min-height: 380px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}
/* Conversa aberta com "voltar" em cima (personal no celular): desconta o link para o campo de
   texto não ficar atrás da barra de abas */
.chat-with-back .chat {
  height: calc(
    100dvh - var(--topbar-h) - var(--tabbar-h) - var(--sp-7) - var(--tap) - var(--sp-2) -
      env(safe-area-inset-bottom)
  );
}
@media (min-width: 960px) {
  .app[data-layout='trainer'] .chat {
    height: calc(100dvh - var(--topbar-h) - 160px);
  }
}
.chat-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.msg {
  max-width: min(80%, var(--w-xs));
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-xs);
  background: var(--surface-2);
  align-self: flex-start;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg.mine .msg-time {
  color: inherit; /* sobre a bolha prata: tinta preta, 11,8:1 */
}
.msg.mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg);
}
.msg-time {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: var(--hairline);
  text-align: right;
}
.msg img,
.msg video {
  border-radius: var(--r-sm);
  width: 240px; /* largura fixa: a altura reservada não depende do balão (que encolhe) */
  max-width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  margin: var(--sp-1) 0;
  background: var(--media-bg);
}
/* Espaço reservado antes de carregar (4:3 foto, 16:9 vídeo); depois vale a proporção real. */
.msg img {
  aspect-ratio: auto 4 / 3;
  max-height: 320px; /* retrato 3:4 inteiro, sem faixas */
}
.msg video {
  aspect-ratio: 16 / 9;
}
.msg.pending {
  opacity: 0.7;
}
.day-sep {
  align-self: center;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: var(--sp-2) 0;
}
.composer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
}
.composer .textarea {
  min-height: var(--tap);
  max-height: 140px;
  resize: none;
  padding: var(--sp-2) var(--sp-3);
}
.attach-preview {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.attach-preview img,
.attach-preview video {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--r-sm);
}

/* Agenda */
.week {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 1200px) {
  .week .appt {
    padding: var(--sp-1) var(--sp-2);
  }
  .week .appt-time {
    font-size: var(--fs-xs);
  }
  .week {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--sp-2);
  }
  .week .day-col {
    min-height: 260px;
  }
}
.day-col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
}
.day-col.today {
  border-color: var(--accent-mark);
}
.day-col h3 {
  font-size: var(--fs-sm);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
}
.appt {
  display: flex;
  flex-direction: column;
  gap: var(--hairline);
  width: 100%;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  border: 0;
  border-left: 3px solid var(--accent-mark);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  min-height: var(--tap);
  font-size: var(--fs-sm);
}
.appt.realizado {
  border-left-color: var(--ok);
}
.appt.cancelado,
.appt.faltou {
  border-left-color: var(--muted);
  opacity: 0.75;
}
.appt.cancelado .appt-title {
  text-decoration: line-through;
}
.appt-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}
.appt-status svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
  flex: none;
}
.appt-status-realizado {
  color: var(--ok-text);
}
.appt-time {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.appt-title {
  color: var(--muted);
}

.next-appt {
  border-color: color-mix(in srgb, var(--accent-mark) 45%, var(--line-soft));
}
.next-when {
  font-size: var(--fs-lg);
  font-weight: 750;
  letter-spacing: -0.01em;
}

.range-nav {
  flex: 1 1 100%;
  order: 3;
}
.range-label {
  font-size: var(--fs-md);
  text-align: center;
}
@media (min-width: 640px) {
  .range-nav {
    flex: 1 1 auto;
    order: 0;
  }
}
.day-col h3 span:first-child,
.capitalize {
  text-transform: capitalize;
}

/* Financeiro */
.plan-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.price {
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.pix {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
  color: var(--muted);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

/* Cobranças: agrupadas por situação, 3 linhas no celular e 1 no computador */
.charge-groups {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
.charge-group-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-1);
}
.charge-group-vencida .charge-group-title > span:first-child {
  color: var(--danger-text);
}
.charge-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.charge {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: 'main' 'meta' 'actions';
  gap: var(--sp-1) var(--sp-3);
  align-items: center;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line-soft);
}
.charge-main {
  grid-area: main;
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-weight: 650;
}
.charge-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.charge-amount {
  white-space: nowrap;
}
.charge-vencida .charge-amount {
  color: var(--danger-text);
}
.charge-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.charge-vencida .charge-due {
  color: var(--danger-text);
  font-weight: 650;
}
.charge-desc {
  overflow-wrap: break-word;
  min-width: 0;
}
.charge-actions {
  grid-area: actions;
  display: flex;
  gap: var(--sp-1);
  justify-content: flex-end;
}
@media (min-width: 960px) {
  .charge {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) auto 14rem;
    grid-template-areas: 'main meta amount actions';
  }
  .charge-main {
    display: contents;
  }
  .charge-who {
    grid-area: main;
  }
  .charge-amount {
    grid-area: amount;
    text-align: right;
  }
}

/* Menu "Mais" no celular */
.more-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}
.more-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 64px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}
.more-link svg {
  flex: none; /* não encolhe com texto longo (media 14 px no celular) */
  width: var(--icon-md);
  height: var(--icon-md);
  color: var(--accent-text);
}

/* Guia de primeiros passos */
.guide {
  border-color: color-mix(in srgb, var(--accent-mark) 45%, var(--line-soft));
}
.guide-steps {
  list-style: none;
  margin: 0 0 var(--sp-3);
  padding: 0;
  display: flex;
  flex-direction: column;
}
.guide-step {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.guide-step:first-child {
  border-top: 0;
}
.guide-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-lg);
  height: var(--icon-lg);
  flex: none;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  font-size: var(--fs-xs);
  font-weight: 800;
}
.guide-mark svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
}
.guide-step.done {
  color: var(--muted);
}
.guide-step.done .guide-mark {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--ok-ink);
}
.guide-tips .guide-mark {
  border-color: var(--accent-mark);
  color: var(--accent-text);
}
.guide .form-actions {
  align-items: center;
}

/* Aviso discreto de texto provisório nos termos */
.terms-draft {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.terms-draft svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
  flex: none;
  margin-top: 2px;
}

/* Privacidade do aluno (exportar/apagar) recolhida: o botão vermelho não fica exposto */
.privacy-box > summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}
.privacy-box > summary::-webkit-details-marker {
  display: none;
}
.privacy-box > summary::after {
  content: '+';
  font-weight: 800;
  color: var(--muted);
}
.privacy-box[open] > summary::after {
  content: '–';
}
.privacy-box > summary svg {
  width: var(--icon-md);
  height: var(--icon-md);
  color: var(--muted);
}
.privacy-box[open] {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* "Mais" em lista (ícone, nome e para que serve) */
.more-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.more-list .more-link .list-title,
.more-list .more-link .list-sub {
  display: block;
}
.more-list .more-link .list-sub {
  font-weight: 400;
}
.more-list .more-link > svg:last-child {
  width: var(--icon-sm);
  height: var(--icon-sm);
  color: var(--muted);
}
@media (min-width: 960px) {
  .app[data-layout='trainer'] .mobile-only {
    display: none;
  }
}

.section-title {
  font-size: var(--fs-lg);
  margin: var(--sp-6) 0 var(--sp-3);
}
.section-title:first-child {
  margin-top: 0;
}
hr.sep {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: var(--sp-2) 0;
}

@media (min-width: 960px) {
  .toasts,
  .toasts[popover] {
    bottom: var(--sp-5);
  }
  .app[data-layout='trainer'] .timer {
    bottom: var(--sp-5);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* exceção: a "transition" do preenchimento automático não anima nada, só segura o fundo */
  .input:-webkit-autofill,
  .select:-webkit-autofill,
  .textarea:-webkit-autofill {
    transition-duration: var(--autofill-hold) !important;
  }
}

/* Texto longo sem espaços (nomes, títulos) quebra em vez de estourar a tela */
h1,
h2,
h3,
.list-title,
.list-sub,
.page-head,
.card-head,
.msg,
.notice,
p,
.back-link {
  overflow-wrap: anywhere;
}
.back-link {
  max-width: 100%;
}
/* Linha de botões que não cabe: o texto do botão quebra em vez de vazar o cartão */
.row.wrap > .btn {
  white-space: normal;
  max-width: 100%;
}
.dl dd {
  min-width: 0;
}

/* Aviso de versão nova do app e avisos ao personal (convites aceitos, logins bloqueados) */
.update-banner {
  position: fixed;
  z-index: var(--z-banner);
  left: var(--sp-3);
  right: var(--sp-3);
  top: calc(var(--sp-3) + env(safe-area-inset-top));
  max-width: var(--w-xs);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.notice-banner p {
  margin: 0;
}
/* Aviso ao personal (aluno ativou o acesso, tentativas bloqueadas): no fluxo da página, logo
   abaixo do cabeçalho, sem cobri-lo; rola junto com o conteúdo. */
.notice-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: calc(100% - 2 * var(--sp-4));
  max-width: calc(var(--w-page) - 2 * var(--sp-4));
  margin: var(--sp-3) auto 0;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.notice-banner .small {
  font-weight: 500;
}
.notice-banner-alert {
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-color: color-mix(in srgb, var(--warn-text) 45%, transparent);
  background: var(--warn-soft);
}
.notice-title {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
}
.notice-title svg {
  width: var(--icon-md);
  height: var(--icon-md);
  flex: none;
  color: var(--warn-text);
}
.notice-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}
.notice-banner-alert > .grow {
  flex: 1 1 16rem;
  min-width: 0;
}
.notice-banner-alert .notice-actions {
  margin-left: auto;
}

/* Perfil do aluno: zona de exclusão e lista de pendências */
.danger-zone {
  border-top: 1px solid var(--line-soft);
  padding-top: var(--sp-4);
}
.danger-zone h3 {
  color: var(--danger-text);
}
.pending-list:empty {
  display: none;
}
.terms-gate .terms {
  max-height: 40vh;
}

/* ---------- Vídeos dos exercícios (Como fazer, execução, vídeo próprio) ---------- */
.ex-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: var(--r-md);
  background: var(--media-bg);
}
.pre-line {
  white-space: pre-line;
}
.howto h3,
.record-title {
  font-size: var(--fs-md);
}
.record-box {
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-soft);
}
.record-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.record-title svg,
.record-ok svg,
.exec-tag svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex: none;
}
.record-ok {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--ok-text);
  font-size: var(--fs-md);
}
.record-actions .btn,
.video-ref .btn {
  white-space: normal;
  text-align: left;
}
.video-ref .btn {
  align-self: flex-start;
  max-width: 100%;
  min-height: var(--tap);
}
.upload-progress {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
}
progress.progress {
  appearance: none;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface-3);
  color: var(--accent-mark);
}
progress.progress::-webkit-progress-bar {
  background: var(--surface-3);
  border-radius: var(--r-pill);
}
progress.progress::-webkit-progress-value {
  background: var(--accent-mark);
  border-radius: var(--r-pill);
}
progress.progress::-moz-progress-bar {
  background: var(--accent-mark);
  border-radius: var(--r-pill);
}
/* Lista de exercícios: estado do vídeo e acompanhamento "N de 41 com o seu vídeo" */
.video-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}
.video-progress {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  max-width: var(--w-xs);
  margin-bottom: var(--sp-3);
}
.video-progress:empty {
  display: none;
}
.video-progress-text {
  font-size: var(--fs-sm);
  color: var(--muted);
}
.video-progress-text strong {
  color: var(--text);
}
.chip svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
  flex: none;
}
/* Etiqueta "Execução: <nome>" (chat, conversas, execuções) */
.exec-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: normal;
}
.msg-tag {
  display: flex;
  margin-bottom: var(--sp-1);
}
.msg.msg-focus {
  outline: 2px solid var(--accent-mark);
  outline-offset: 2px;
}
.ex-howto {
  display: flex;
}
.howto-btn {
  flex: none;
}
/* Execuções na ficha do aluno */
.exec-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-4);
}
.exec-item {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 640px) {
  .exec-item {
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    align-items: start;
  }
}
.exec-group + .exec-group {
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-soft);
}
.exec-group h3 {
  font-size: var(--fs-md);
  gap: var(--sp-2);
}
.exec-item .btn {
  align-self: flex-start;
}
.list-item .ex-howto {
  margin-top: var(--sp-2);
}

/* ---------- Exercícios unilaterais e biblioteca grande ---------- */
.uni-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-2);
  border: 1px solid var(--control-border);
  border-radius: var(--r-pill);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1.6;
  white-space: nowrap;
}
.uni-badge svg {
  width: var(--icon-xs);
  height: var(--icon-xs);
  flex: none;
}
.ex-meta,
.ex-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
}
.uni-hint {
  color: var(--muted);
  margin-top: var(--sp-1);
}
.chips-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.ex-groups {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
.ex-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.ex-group-title {
  font-size: var(--fs-md);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ex-group-title span {
  text-transform: none;
  letter-spacing: 0;
}
.ex-lib-name {
  font-size: var(--fs-lg);
}
.show-more:not(:empty) {
  margin-top: var(--sp-4);
}
.pick-item .ex-meta {
  display: flex;
}
/* Vídeo indisponível (bloqueado pela LGPD ou que não carregou): aviso no lugar do player */
.video-unavailable {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  margin: var(--sp-1) 0;
  border: 1px dashed var(--control-border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  white-space: normal;
  max-width: var(--w-xs);
}
.video-unavailable svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex: none;
  margin-top: 2px;
}
.msg.mine .video-unavailable {
  border-color: currentColor;
}

/* Instalar o app (tela depois de criar a senha) */
.install-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-3);
}
.install-step {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.install-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--accent);
  color: var(--accent-ink);
}
.install-ico {
  color: var(--accent-text);
  display: grid;
  place-items: center;
}
.install-ico svg {
  width: 26px;
  height: 26px;
}
.install-step p {
  margin: 2px 0 0;
  color: var(--muted);
}
.install-after,
.install-note {
  color: var(--muted);
}
.notice-inline {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.notice-inline svg {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}
